mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
code syntax don directory
This commit is contained in:
parent
f7c119e48c
commit
8670cc2d6f
|
|
@ -30,12 +30,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('admin', 'donations', 'accountancy', 'other'));
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$value = GETPOST('value');
|
||||
|
|
@ -49,8 +53,7 @@ $type = 'donation';
|
|||
* Action
|
||||
*/
|
||||
|
||||
if ($action == 'specimen')
|
||||
{
|
||||
if ($action == 'specimen') {
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
|
||||
$don = new Don($db);
|
||||
|
|
@ -59,15 +62,13 @@ if ($action == 'specimen')
|
|||
// Search template files
|
||||
$dir = DOL_DOCUMENT_ROOT."/core/modules/dons/";
|
||||
$file = $modele.".modules.php";
|
||||
if (file_exists($dir.$file))
|
||||
{
|
||||
if (file_exists($dir.$file)) {
|
||||
$classname = $modele;
|
||||
require_once $dir.$file;
|
||||
|
||||
$obj = new $classname($db);
|
||||
|
||||
if ($obj->write_file($don, $langs) > 0)
|
||||
{
|
||||
if ($obj->write_file($don, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=donation&file=SPECIMEN.html");
|
||||
return;
|
||||
} else {
|
||||
|
|
@ -78,13 +79,9 @@ if ($action == 'specimen')
|
|||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
// Set default model
|
||||
elseif ($action == 'setdoc')
|
||||
{
|
||||
if (dolibarr_set_const($db, "DON_ADDON_MODEL", $value, 'chaine', 0, '', $conf->entity))
|
||||
{
|
||||
} elseif ($action == 'setdoc') {
|
||||
// Set default model
|
||||
if (dolibarr_set_const($db, "DON_ADDON_MODEL", $value, 'chaine', 0, '', $conf->entity)) {
|
||||
// The constant that was read before the new set
|
||||
// So we go through a variable for a coherent display
|
||||
$conf->global->DON_ADDON_MODEL = $value;
|
||||
|
|
@ -92,52 +89,48 @@ elseif ($action == 'setdoc')
|
|||
|
||||
// It enables the model
|
||||
$ret = delDocumentModel($value, $type);
|
||||
if ($ret > 0)
|
||||
{
|
||||
if ($ret > 0) {
|
||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||
}
|
||||
}
|
||||
|
||||
// Activate a model
|
||||
elseif ($action == 'set')
|
||||
{
|
||||
} elseif ($action == 'set') {
|
||||
// Activate a model
|
||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||
} elseif ($action == 'del')
|
||||
{
|
||||
} elseif ($action == 'del') {
|
||||
$ret = delDocumentModel($value, $type);
|
||||
if ($ret > 0)
|
||||
{
|
||||
if ($conf->global->DON_ADDON_MODEL == "$value") dolibarr_del_const($db, 'DON_ADDON_MODEL', $conf->entity);
|
||||
if ($ret > 0) {
|
||||
if ($conf->global->DON_ADDON_MODEL == "$value") {
|
||||
dolibarr_del_const($db, 'DON_ADDON_MODEL', $conf->entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Options
|
||||
if ($action == 'set_DONATION_ACCOUNTINGACCOUNT')
|
||||
{
|
||||
if ($action == 'set_DONATION_ACCOUNTINGACCOUNT') {
|
||||
$account = GETPOST('DONATION_ACCOUNTINGACCOUNT', 'alpha');
|
||||
|
||||
$res = dolibarr_set_const($db, "DONATION_ACCOUNTINGACCOUNT", $account, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (!($res > 0)) $error++;
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'set_DONATION_MESSAGE')
|
||||
{
|
||||
if ($action == 'set_DONATION_MESSAGE') {
|
||||
$freemessage = GETPOST('DONATION_MESSAGE', 'restricthtml'); // No alpha here, we want exact string
|
||||
|
||||
$res = dolibarr_set_const($db, "DONATION_MESSAGE", $freemessage, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (!($res > 0)) $error++;
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
|
|
@ -147,11 +140,9 @@ if ($action == 'set_DONATION_MESSAGE')
|
|||
/*
|
||||
* Action
|
||||
*/
|
||||
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
||||
{
|
||||
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
|
||||
$code = $reg[1];
|
||||
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
|
|
@ -159,11 +150,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
|||
}
|
||||
}
|
||||
|
||||
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
|
||||
{
|
||||
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
|
||||
$code = $reg[1];
|
||||
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
|
||||
{
|
||||
if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
|
|
@ -177,7 +166,9 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
|
|||
|
||||
$dir = "../../core/modules/dons/";
|
||||
$form = new Form($db);
|
||||
if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$formaccounting = new FormAccounting($db);
|
||||
}
|
||||
|
||||
llxHeader('', $langs->trans("DonationsSetup"), 'DonConfiguration');
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
|
|
@ -198,12 +189,10 @@ $sql = "SELECT nom";
|
|||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = '".$db->escape($type)."'";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num_rows = $db->num_rows($resql);
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
while ($i < $num_rows) {
|
||||
$array = $db->fetch_array($resql);
|
||||
array_push($def, $array[0]);
|
||||
$i++;
|
||||
|
|
@ -226,12 +215,9 @@ clearstatcache();
|
|||
|
||||
$handle = opendir($dir);
|
||||
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file))
|
||||
{
|
||||
if (is_resource($handle)) {
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
if (preg_match('/\.modules\.php$/i', $file)) {
|
||||
$name = substr($file, 0, dol_strlen($file) - 12);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
|
|
@ -239,11 +225,14 @@ if (is_resource($handle))
|
|||
$module = new $classname($db);
|
||||
|
||||
// Show modules according to features level
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||
continue;
|
||||
}
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($module->isEnabled())
|
||||
{
|
||||
if ($module->isEnabled()) {
|
||||
print '<tr class="oddeven"><td width=\"100\">';
|
||||
echo $module->name;
|
||||
print '</td>';
|
||||
|
|
@ -252,10 +241,8 @@ if (is_resource($handle))
|
|||
print '</td>';
|
||||
|
||||
// Active
|
||||
if (in_array($name, $def))
|
||||
{
|
||||
if ($conf->global->DON_ADDON_MODEL == $name)
|
||||
{
|
||||
if (in_array($name, $def)) {
|
||||
if ($conf->global->DON_ADDON_MODEL == $name) {
|
||||
print "<td class=\"center\">\n";
|
||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||
print '</td>';
|
||||
|
|
@ -271,8 +258,7 @@ if (is_resource($handle))
|
|||
}
|
||||
|
||||
// Default
|
||||
if ($conf->global->DON_ADDON_MODEL == "$name")
|
||||
{
|
||||
if ($conf->global->DON_ADDON_MODEL == "$name") {
|
||||
print "<td class=\"center\">";
|
||||
print img_picto($langs->trans("Default"), 'on');
|
||||
print '</td>';
|
||||
|
|
@ -285,8 +271,7 @@ if (is_resource($handle))
|
|||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||
if ($module->type == 'pdf')
|
||||
{
|
||||
if ($module->type == 'pdf') {
|
||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
}
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
|
|
@ -345,8 +330,7 @@ print '<td>';
|
|||
$label = $langs->trans("AccountAccounting");
|
||||
print '<label for="DONATION_ACCOUNTINGACCOUNT">'.$label.'</label></td>';
|
||||
print '<td class="center">';
|
||||
if (!empty($conf->accounting->enabled))
|
||||
{
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
print $formaccounting->select_account($conf->global->DONATION_ACCOUNTINGACCOUNT, 'DONATION_ACCOUNTINGACCOUNT', 1, '', 1, 1);
|
||||
} else {
|
||||
print '<input type="text" size="10" id="DONATION_ACCOUNTINGACCOUNT" name="DONATION_ACCOUNTINGACCOUNT" value="'.$conf->global->DONATION_ACCOUNTINGACCOUNT.'">';
|
||||
|
|
@ -373,8 +357,7 @@ print '</form>';
|
|||
/*
|
||||
* French params
|
||||
*/
|
||||
if (preg_match('/fr/i', $conf->global->MAIN_INFO_SOCIETE_COUNTRY))
|
||||
{
|
||||
if (preg_match('/fr/i', $conf->global->MAIN_INFO_SOCIETE_COUNTRY)) {
|
||||
print '<br>';
|
||||
print load_fiche_titre($langs->trans("FrenchOptions"), '', '');
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,17 @@ $form = new Form($db);
|
|||
// List of supported format
|
||||
$tmptype2label = ExtraFields::$type2label;
|
||||
$type2label = array('');
|
||||
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
|
||||
foreach ($tmptype2label as $key => $val) {
|
||||
$type2label[$key] = $langs->transnoentitiesnoconv($val);
|
||||
}
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$attrname = GETPOST('attrname', 'alpha');
|
||||
$elementtype = 'don'; //Must be the $table_element of the class that manage extrafield
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -74,8 +78,7 @@ print dol_get_fiche_end();
|
|||
|
||||
|
||||
// Buttons
|
||||
if ($action != 'create' && $action != 'edit')
|
||||
{
|
||||
if ($action != 'create' && $action != 'edit') {
|
||||
print '<div class="tabsAction">';
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a></div>';
|
||||
print "</div>";
|
||||
|
|
@ -88,8 +91,7 @@ if ($action != 'create' && $action != 'edit')
|
|||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
print "<br>";
|
||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||
|
||||
|
|
@ -101,8 +103,7 @@ if ($action == 'create')
|
|||
/* Edit optional field */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
if ($action == 'edit' && !empty($attrname))
|
||||
{
|
||||
if ($action == 'edit' && !empty($attrname)) {
|
||||
print "<br>";
|
||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||
|
||||
|
|
|
|||
|
|
@ -79,23 +79,27 @@ $permissiontoadd = $user->rights->don->creer;
|
|||
$parameters = array();
|
||||
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
// Action reopen object
|
||||
if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd)
|
||||
{
|
||||
if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) {
|
||||
$object->fetch($id);
|
||||
|
||||
$result = $object->reopen($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
// Define output language
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
if (method_exists($object, 'generateDocument')) {
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
|
||||
$newlang = GETPOST('lang_id', 'aZ09');
|
||||
}
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
}
|
||||
if (!empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
|
|
@ -114,32 +118,27 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd)
|
|||
}
|
||||
}
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
if (!empty($cancel))
|
||||
{
|
||||
if ($action == 'update') {
|
||||
if (!empty($cancel)) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (empty($donation_date))
|
||||
{
|
||||
if (empty($donation_date)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (empty($amount))
|
||||
{
|
||||
if (empty($amount)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$object->fetch($id);
|
||||
|
||||
$object->firstname = (string) GETPOST("firstname", 'alpha');
|
||||
|
|
@ -160,7 +159,9 @@ if ($action == 'update')
|
|||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||
if ($ret < 0) $error++;
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if ($object->update($user) > 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
|
|
@ -169,32 +170,27 @@ if ($action == 'update')
|
|||
}
|
||||
}
|
||||
|
||||
if ($action == 'add')
|
||||
{
|
||||
if (!empty($cancel))
|
||||
{
|
||||
if ($action == 'add') {
|
||||
if (!empty($cancel)) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (empty($donation_date))
|
||||
{
|
||||
if (empty($donation_date)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (empty($amount))
|
||||
{
|
||||
if (empty($amount)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$object->socid = (int) GETPOST("socid", 'int');
|
||||
$object->firstname = (string) GETPOST("firstname", 'alpha');
|
||||
$object->lastname = (string) GETPOST("lastname", 'alpha');
|
||||
|
|
@ -214,7 +210,9 @@ if ($action == 'add')
|
|||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||
if ($ret < 0) $error++;
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
$res = $object->create($user);
|
||||
if ($res > 0) {
|
||||
|
|
@ -331,10 +329,11 @@ llxHeader('', $langs->trans("Donation"), 'EN:Module_Donations|FR:Module_Dons|ES:
|
|||
$form = new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$formproject = new FormProjets($db);
|
||||
}
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
print load_fiche_titre($langs->trans("AddDonation"), '', 'object_donation');
|
||||
|
||||
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
|
|
@ -350,12 +349,10 @@ if ($action == 'create')
|
|||
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>';
|
||||
|
||||
// Company
|
||||
if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES))
|
||||
{
|
||||
if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
|
||||
// Thirdparty
|
||||
print '<td>'.$langs->trans('Customer').'</td>';
|
||||
if ($soc->id > 0 && !GETPOST('fac_rec', 'alpha'))
|
||||
{
|
||||
if ($soc->id > 0 && !GETPOST('fac_rec', 'alpha')) {
|
||||
print '<td colspan="2">';
|
||||
print $soc->getNomUrl(1);
|
||||
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
|
||||
|
|
@ -364,9 +361,10 @@ if ($action == 'create')
|
|||
$outstandingBills = $arrayoutstandingbills['opened'];
|
||||
print ' ('.$langs->trans('CurrentOutstandingBill').': ';
|
||||
print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency);
|
||||
if ($soc->outstanding_limit != '')
|
||||
{
|
||||
if ($outstandingBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached"));
|
||||
if ($soc->outstanding_limit != '') {
|
||||
if ($outstandingBills > $soc->outstanding_limit) {
|
||||
print img_warning($langs->trans("OutstandingBillReached"));
|
||||
}
|
||||
print ' / '.price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency);
|
||||
}
|
||||
print ')';
|
||||
|
|
@ -375,8 +373,7 @@ if ($action == 'create')
|
|||
print '<td colspan="2">';
|
||||
print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
|
||||
// Option to reload page to retrieve customer informations. Note, this clear other input
|
||||
if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED))
|
||||
{
|
||||
if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) {
|
||||
print '<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#socid").change(function() {
|
||||
|
|
@ -408,8 +405,7 @@ if ($action == 'create')
|
|||
print $form->selectyesno("public", $public_donation, 1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
if (empty($conf->societe->enabled) || empty($conf->global->DONATION_USE_THIRDPARTIES))
|
||||
{
|
||||
if (empty($conf->societe->enabled) || empty($conf->global->DONATION_USE_THIRDPARTIES)) {
|
||||
print "<tr>".'<td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" value="'.dol_escape_htmltag(GETPOST("societe")).'" class="maxwidth200"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" value="'.dol_escape_htmltag(GETPOST("lastname")).'" class="maxwidth200"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" value="'.dol_escape_htmltag(GETPOST("firstname")).'" class="maxwidth200"></td></tr>';
|
||||
|
|
@ -426,7 +422,9 @@ if ($action == 'create')
|
|||
// Country
|
||||
print '<tr><td><label for="selectcountry_id">'.$langs->trans('Country').'</label></td><td class="maxwidthonsmartphone">';
|
||||
print img_picto('', 'globe-americas', 'class="paddingrightonly"').$form->select_country(GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id);
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
if ($user->admin) {
|
||||
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print "<tr>".'<td>'.$langs->trans("EMail").'</td><td>'.img_picto('', 'object_email', 'class="paddingrightonly"').'<input type="text" name="email" value="'.dol_escape_htmltag(GETPOST("email")).'" class="maxwidth200"></td></tr>';
|
||||
|
|
@ -458,8 +456,7 @@ if ($action == 'create')
|
|||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
print "<tr><td>".$langs->trans("Project")."</td><td>";
|
||||
$formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
|
||||
print "</td></tr>\n";
|
||||
|
|
@ -469,8 +466,7 @@ if ($action == 'create')
|
|||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
print $object->showOptionals($extrafields, 'edit', $parameters);
|
||||
}
|
||||
|
||||
|
|
@ -495,8 +491,7 @@ if ($action == 'create')
|
|||
/* */
|
||||
/* ************************************************************ */
|
||||
|
||||
if (!empty($id) && $action == 'edit')
|
||||
{
|
||||
if (!empty($id) && $action == 'edit') {
|
||||
$result = $object->fetch($id);
|
||||
if ($result < 0) {
|
||||
dol_print_error($db, $object->error); exit;
|
||||
|
|
@ -577,8 +572,11 @@ if (!empty($id) && $action == 'edit')
|
|||
}
|
||||
// Payment mode
|
||||
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
|
||||
if ($object->mode_reglement_id) $selected = $object->mode_reglement_id;
|
||||
else $selected = '';
|
||||
if ($object->mode_reglement_id) {
|
||||
$selected = $object->mode_reglement_id;
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
$form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
|
|
@ -599,9 +597,8 @@ if (!empty($id) && $action == 'edit')
|
|||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook))
|
||||
{
|
||||
print $object->showOptionals($extrafields, 'edit', $parameters);
|
||||
if (empty($reshook)) {
|
||||
print $object->showOptionals($extrafields, 'edit', $parameters);
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
|
|
@ -620,11 +617,9 @@ if (!empty($id) && $action == 'edit')
|
|||
/* Donation card in view mode */
|
||||
/* */
|
||||
/* ************************************************************ */
|
||||
if (!empty($id) && $action != 'edit')
|
||||
{
|
||||
if (!empty($id) && $action != 'edit') {
|
||||
// Confirmation delete
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
$text = $langs->trans("ConfirmDeleteADonation");
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteADonation"), $text, "confirm_delete", '', '', 1);
|
||||
}
|
||||
|
|
@ -650,12 +645,10 @@ if (!empty($id) && $action != 'edit')
|
|||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$langs->load("projects");
|
||||
$morehtmlref .= $langs->trans('Project').' ';
|
||||
if ($user->rights->don->creer)
|
||||
{
|
||||
if ($user->rights->don->creer) {
|
||||
if ($action != 'classify') {
|
||||
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
|
||||
}
|
||||
|
|
@ -749,8 +742,7 @@ if (!empty($id) && $action != 'edit')
|
|||
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0; $total = 0;
|
||||
print '<table class="noborder paymenttable centpercent">';
|
||||
|
|
@ -758,11 +750,10 @@ if (!empty($id) && $action != 'edit')
|
|||
print '<td>'.$langs->trans("RefPayment").'</td>';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.$langs->trans("Type").'</td>';
|
||||
print '<td class="right">'.$langs->trans("Amount").'</td>';
|
||||
print '</tr>';
|
||||
print '<td class="right">'.$langs->trans("Amount").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
|
|
@ -776,8 +767,7 @@ if (!empty($id) && $action != 'edit')
|
|||
$i++;
|
||||
}
|
||||
|
||||
if ($object->paid == 0)
|
||||
{
|
||||
if ($object->paid == 0) {
|
||||
print "<tr><td colspan=\"3\" class=\"right\">".$langs->trans("AlreadyPaid")." :</td><td class=\"right\">".price($totalpaid)."</td></tr>\n";
|
||||
print "<tr><td colspan=\"3\" class=\"right\">".$langs->trans("AmountExpected")." :</td><td class=\"right\">".price($object->amount)."</td></tr>\n";
|
||||
|
||||
|
|
@ -807,28 +797,23 @@ if (!empty($id) && $action != 'edit')
|
|||
print '<div class="tabsAction">';
|
||||
|
||||
// Re-open
|
||||
if ($permissiontoadd && $object->statut == $object::STATUS_CANCELED)
|
||||
{
|
||||
if ($permissiontoadd && $object->statut == $object::STATUS_CANCELED) {
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken().'">'.$langs->trans("ReOpen").'</a>';
|
||||
}
|
||||
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$object->id.'">'.$langs->trans('Modify').'</a></div>';
|
||||
|
||||
if ($object->statut == $object::STATUS_DRAFT)
|
||||
{
|
||||
if ($object->statut == $object::STATUS_DRAFT) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=valid_promesse&token='.newToken().'">'.$langs->trans("ValidPromess").'</a></div>';
|
||||
}
|
||||
|
||||
if (($object->statut == $object::STATUS_DRAFT || $object->statut == $object::STATUS_VALIDATED) && $totalpaid == 0 && $object->paid == 0)
|
||||
{
|
||||
if (($object->statut == $object::STATUS_DRAFT || $object->statut == $object::STATUS_VALIDATED) && $totalpaid == 0 && $object->paid == 0) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=set_cancel&token='.newToken().'">'.$langs->trans("ClassifyCanceled")."</a></div>";
|
||||
}
|
||||
|
||||
// Create payment
|
||||
if ($object->statut == $object::STATUS_VALIDATED && $object->paid == 0 && $user->rights->don->creer)
|
||||
{
|
||||
if ($remaintopay == 0)
|
||||
{
|
||||
if ($object->statut == $object::STATUS_VALIDATED && $object->paid == 0 && $user->rights->don->creer) {
|
||||
if ($remaintopay == 0) {
|
||||
print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseRemainderToPayIsZero").'">'.$langs->trans('DoPayment').'</span></div>';
|
||||
} else {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/don/payment/payment.php?rowid='.$object->id.'&action=create">'.$langs->trans('DoPayment').'</a></div>';
|
||||
|
|
@ -836,16 +821,13 @@ if (!empty($id) && $action != 'edit')
|
|||
}
|
||||
|
||||
// Classify 'paid'
|
||||
if ($object->statut == $object::STATUS_VALIDATED && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer)
|
||||
{
|
||||
if ($object->statut == $object::STATUS_VALIDATED && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=set_paid">'.$langs->trans("ClassifyPaid")."</a></div>";
|
||||
}
|
||||
|
||||
// Delete
|
||||
if ($user->rights->don->supprimer)
|
||||
{
|
||||
if ($object->statut == $object::STATUS_CANCELED || $object->statut == $object::STATUS_DRAFT)
|
||||
{
|
||||
if ($user->rights->don->supprimer) {
|
||||
if ($object->statut == $object::STATUS_CANCELED || $object->statut == $object::STATUS_DRAFT) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete")."</a></div>";
|
||||
} else {
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete")."</a></div>";
|
||||
|
|
@ -877,8 +859,7 @@ if (!empty($id) && $action != 'edit')
|
|||
// Show online payment link
|
||||
$useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
|
||||
|
||||
if ($useonlinepayment) //$object->statut != Facture::STATUS_DRAFT &&
|
||||
{
|
||||
if ($useonlinepayment) { //$object->statut != Facture::STATUS_DRAFT &&
|
||||
print '<br><!-- Link to pay -->'."\n";
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||
print showOnlinePaymentUrl('donation', $object->ref).'<br>';
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Donations extends DolibarrApi
|
|||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
public static $FIELDS = array(
|
||||
'socid'
|
||||
);
|
||||
|
||||
|
|
@ -109,18 +109,22 @@ class Donations extends DolibarrApi
|
|||
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
|
||||
|
||||
$sql = "SELECT t.rowid";
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) {
|
||||
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||
}
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as t";
|
||||
|
||||
$sql .= ' WHERE t.entity IN ('.getEntity('don').')';
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) $sql .= " AND t.fk_soc = sc.fk_soc";
|
||||
if ($thirdparty_ids) $sql .= " AND t.fk_soc = ".$thirdparty_ids." ";
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) {
|
||||
$sql .= " AND t.fk_soc = sc.fk_soc";
|
||||
}
|
||||
if ($thirdparty_ids) {
|
||||
$sql .= " AND t.fk_soc = ".$thirdparty_ids." ";
|
||||
}
|
||||
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
|
|
@ -129,8 +133,7 @@ class Donations extends DolibarrApi
|
|||
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
{
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
|
@ -141,13 +144,11 @@ class Donations extends DolibarrApi
|
|||
dol_syslog("API Rest request");
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
$i = 0;
|
||||
while ($i < $min)
|
||||
{
|
||||
while ($i < $min) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$don_static = new Don($this->db);
|
||||
if ($don_static->fetch($obj->rowid)) {
|
||||
|
|
@ -185,12 +186,12 @@ class Donations extends DolibarrApi
|
|||
$this->don->$field = $value;
|
||||
}
|
||||
/*if (isset($request_data["lines"])) {
|
||||
$lines = array();
|
||||
foreach ($request_data["lines"] as $line) {
|
||||
array_push($lines, (object) $line);
|
||||
}
|
||||
$this->don->lines = $lines;
|
||||
}*/
|
||||
$lines = array();
|
||||
foreach ($request_data["lines"] as $line) {
|
||||
array_push($lines, (object) $line);
|
||||
}
|
||||
$this->don->lines = $lines;
|
||||
}*/
|
||||
|
||||
if ($this->don->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, "Error creating order", array_merge(array($this->don->error), $this->don->errors));
|
||||
|
|
@ -222,12 +223,13 @@ class Donations extends DolibarrApi
|
|||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field == 'id') continue;
|
||||
if ($field == 'id') {
|
||||
continue;
|
||||
}
|
||||
$this->don->$field = $value;
|
||||
}
|
||||
|
||||
if ($this->don->update(DolibarrApiAccess::$user) > 0)
|
||||
{
|
||||
if ($this->don->update(DolibarrApiAccess::$user) > 0) {
|
||||
return $this->get($id);
|
||||
} else {
|
||||
throw new RestException(500, $this->don->error);
|
||||
|
|
@ -356,8 +358,9 @@ class Donations extends DolibarrApi
|
|||
{
|
||||
$don = array();
|
||||
foreach (Orders::$FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
if (!isset($data[$field])) {
|
||||
throw new RestException(400, $field." field missing");
|
||||
}
|
||||
$don[$field] = $data[$field];
|
||||
}
|
||||
return $don;
|
||||
|
|
|
|||
|
|
@ -171,8 +171,7 @@ class Don extends CommonObject
|
|||
public function LibStatut($status, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort))
|
||||
{
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||
global $langs;
|
||||
$langs->load("donations");
|
||||
$this->labelStatus[-1] = $langs->transnoentitiesnoconv("Canceled");
|
||||
|
|
@ -186,8 +185,12 @@ class Don extends CommonObject
|
|||
}
|
||||
|
||||
$statusType = 'status'.$status;
|
||||
if ($status == self::STATUS_CANCELED) $statusType = 'status9';
|
||||
if ($status == self::STATUS_PAID) $statusType = 'status6';
|
||||
if ($status == self::STATUS_CANCELED) {
|
||||
$statusType = 'status9';
|
||||
}
|
||||
if ($status == self::STATUS_PAID) {
|
||||
$statusType = 'status6';
|
||||
}
|
||||
|
||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||
}
|
||||
|
|
@ -216,12 +219,10 @@ class Don extends CommonObject
|
|||
$sql .= " LIMIT 10";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num_socs = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_socs)
|
||||
{
|
||||
while ($i < $num_socs) {
|
||||
$i++;
|
||||
|
||||
$row = $this->db->fetch_row($resql);
|
||||
|
|
@ -269,35 +270,29 @@ class Don extends CommonObject
|
|||
$error_string = array();
|
||||
$err = 0;
|
||||
|
||||
if (dol_strlen(trim($this->societe)) == 0)
|
||||
{
|
||||
if ((dol_strlen(trim($this->lastname)) + dol_strlen(trim($this->firstname))) == 0)
|
||||
{
|
||||
if (dol_strlen(trim($this->societe)) == 0) {
|
||||
if ((dol_strlen(trim($this->lastname)) + dol_strlen(trim($this->firstname))) == 0) {
|
||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Company').'/'.$langs->transnoentitiesnoconv('Firstname').'-'.$langs->transnoentitiesnoconv('Lastname'));
|
||||
$err++;
|
||||
}
|
||||
}
|
||||
|
||||
if (dol_strlen(trim($this->address)) == 0)
|
||||
{
|
||||
if (dol_strlen(trim($this->address)) == 0) {
|
||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Address'));
|
||||
$err++;
|
||||
}
|
||||
|
||||
if (dol_strlen(trim($this->zip)) == 0)
|
||||
{
|
||||
if (dol_strlen(trim($this->zip)) == 0) {
|
||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Zip'));
|
||||
$err++;
|
||||
}
|
||||
|
||||
if (dol_strlen(trim($this->town)) == 0)
|
||||
{
|
||||
if (dol_strlen(trim($this->town)) == 0) {
|
||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Town'));
|
||||
$err++;
|
||||
}
|
||||
|
||||
if (dol_strlen(trim($this->email)) == 0)
|
||||
{
|
||||
if (dol_strlen(trim($this->email)) == 0) {
|
||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('EMail'));
|
||||
$err++;
|
||||
}
|
||||
|
|
@ -306,10 +301,8 @@ class Don extends CommonObject
|
|||
|
||||
$map = range(0, 9);
|
||||
$len = dol_strlen($this->amount);
|
||||
for ($i = 0; $i < $len; $i++)
|
||||
{
|
||||
if (!isset($map[substr($this->amount, $i, 1)]))
|
||||
{
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
if (!isset($map[substr($this->amount, $i, 1)])) {
|
||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Amount'));
|
||||
$err++;
|
||||
$amount_invalid = 1;
|
||||
|
|
@ -317,23 +310,19 @@ class Don extends CommonObject
|
|||
}
|
||||
}
|
||||
|
||||
if (!$amount_invalid)
|
||||
{
|
||||
if ($this->amount == 0)
|
||||
{
|
||||
if (!$amount_invalid) {
|
||||
if ($this->amount == 0) {
|
||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Amount'));
|
||||
$err++;
|
||||
} else {
|
||||
if ($this->amount < $minimum && $minimum > 0)
|
||||
{
|
||||
if ($this->amount < $minimum && $minimum > 0) {
|
||||
$error_string[] = $langs->trans('MinimumAmount', $langs->transnoentitiesnoconv('$minimum'));
|
||||
$err++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($err)
|
||||
{
|
||||
if ($err) {
|
||||
$this->errors = $error_string;
|
||||
return 0;
|
||||
} else {
|
||||
|
|
@ -404,7 +393,7 @@ class Don extends CommonObject
|
|||
$sql .= ", ".(int) ($this->country_id > 0 ? $this->country_id : 0);
|
||||
$sql .= ", ".(int) $this->public;
|
||||
$sql .= ", ".($this->fk_project > 0 ? (int) $this->fk_project : "null");
|
||||
$sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL");
|
||||
$sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL");
|
||||
$sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL");
|
||||
$sql .= ", ".$user->id;
|
||||
$sql .= ", null";
|
||||
|
|
@ -415,16 +404,16 @@ class Don extends CommonObject
|
|||
$sql .= ")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."don");
|
||||
$ret = $this->id;
|
||||
|
||||
if (!$notrigger)
|
||||
{
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('DON_CREATE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
} else {
|
||||
|
|
@ -441,14 +430,12 @@ class Don extends CommonObject
|
|||
}
|
||||
}
|
||||
|
||||
if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS))
|
||||
{
|
||||
if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) {
|
||||
//$res = $this->setValid($user);
|
||||
//if ($res < 0) $error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return $ret;
|
||||
} else {
|
||||
|
|
@ -503,28 +490,25 @@ class Don extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::Update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if (!$notrigger)
|
||||
{
|
||||
if ($resql) {
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('DON_MODIFY', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
// Update extrafield
|
||||
if (!$error)
|
||||
{
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
if (!$error) {
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
$result = 1;
|
||||
} else {
|
||||
|
|
@ -557,7 +541,7 @@ class Don extends CommonObject
|
|||
|
||||
$this->db->begin();
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('DON_DELETE', $user);
|
||||
|
||||
|
|
@ -568,39 +552,33 @@ class Don extends CommonObject
|
|||
}
|
||||
|
||||
// Delete donation
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."don_extrafields";
|
||||
$sql .= " WHERE fk_object=".$this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."don";
|
||||
$sql .= " WHERE rowid=".$this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
|
|
@ -633,20 +611,16 @@ class Don extends CommonObject
|
|||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_country = c.rowid";
|
||||
$sql .= " WHERE d.entity IN (".getEntity('donation').")";
|
||||
if (!empty($id))
|
||||
{
|
||||
if (!empty($id)) {
|
||||
$sql .= " AND d.rowid=".$id;
|
||||
} elseif (!empty($ref))
|
||||
{
|
||||
} elseif (!empty($ref)) {
|
||||
$sql .= " AND d.ref='".$this->db->escape($ref)."'";
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
|
|
@ -731,14 +705,14 @@ class Don extends CommonObject
|
|||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = ".$userid." WHERE rowid = ".$id." AND fk_statut = 0";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->affected_rows($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->affected_rows($resql)) {
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('DON_VALIDATE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
|
@ -784,8 +758,7 @@ class Don extends CommonObject
|
|||
public function setPaid($id, $modepayment = 0)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2";
|
||||
if ($modepayment)
|
||||
{
|
||||
if ($modepayment) {
|
||||
$sql .= ", fk_payment=".$modepayment;
|
||||
}
|
||||
$sql .= " WHERE rowid = ".$id." AND fk_statut = 1";
|
||||
|
|
@ -874,8 +847,7 @@ class Don extends CommonObject
|
|||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$result = $obj->total;
|
||||
}
|
||||
|
|
@ -902,10 +874,8 @@ class Don extends CommonObject
|
|||
$sql .= " AND d.entity IN (".getEntity('donation').")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$this->nb["donations"] = $obj->nb;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
|
@ -930,7 +900,9 @@ class Don extends CommonObject
|
|||
{
|
||||
global $conf, $langs;
|
||||
|
||||
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
|
||||
if (!empty($conf->dol_no_mouse_hover)) {
|
||||
$notooltip = 1; // Force disable tooltips
|
||||
}
|
||||
|
||||
$result = '';
|
||||
$label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Donation").'</u>';
|
||||
|
|
@ -941,20 +913,30 @@ class Don extends CommonObject
|
|||
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->id;
|
||||
$label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->date, 'day');
|
||||
}
|
||||
if ($moretitle) $label .= ' - '.$moretitle;
|
||||
if ($moretitle) {
|
||||
$label .= ' - '.$moretitle;
|
||||
}
|
||||
|
||||
$url = DOL_URL_ROOT.'/don/card.php?id='.$this->id;
|
||||
|
||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
|
||||
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
|
||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
|
||||
$add_save_lastsearch_values = 1;
|
||||
}
|
||||
if ($add_save_lastsearch_values) {
|
||||
$url .= '&save_lastsearch_values=1';
|
||||
}
|
||||
|
||||
$linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$linkend = '</a>';
|
||||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
if ($withpicto != 2) $result .= $this->ref;
|
||||
if ($withpicto) {
|
||||
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= $this->ref;
|
||||
}
|
||||
$result .= $linkend;
|
||||
|
||||
return $result;
|
||||
|
|
@ -976,20 +958,16 @@ class Don extends CommonObject
|
|||
dol_syslog(get_class($this).'::info', LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
if ($result) {
|
||||
if ($this->db->num_rows($result)) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
if ($obj->fk_user_author)
|
||||
{
|
||||
if ($obj->fk_user_author) {
|
||||
$cuser = new User($this->db);
|
||||
$cuser->fetch($obj->fk_user_author);
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
if ($obj->fk_user_valid)
|
||||
{
|
||||
if ($obj->fk_user_valid) {
|
||||
$vuser = new User($this->db);
|
||||
$vuser->fetch($obj->fk_user_valid);
|
||||
$this->user_modification = $vuser;
|
||||
|
|
@ -1045,8 +1023,7 @@ class Don extends CommonObject
|
|||
|
||||
// If selected modele is a filename template (then $modele="modelname:filename")
|
||||
$tmp = explode(':', $modele, 2);
|
||||
if (!empty($tmp[1]))
|
||||
{
|
||||
if (!empty($tmp[1])) {
|
||||
$modele = $tmp[0];
|
||||
$srctemplatepath = $tmp[1];
|
||||
}
|
||||
|
|
@ -1054,28 +1031,28 @@ class Don extends CommonObject
|
|||
// Search template files
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array('/');
|
||||
if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
foreach (array('html', 'doc', 'pdf') as $prefix)
|
||||
{
|
||||
if (is_array($conf->modules_parts['models'])) {
|
||||
$dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
|
||||
}
|
||||
foreach ($dirmodels as $reldir) {
|
||||
foreach (array('html', 'doc', 'pdf') as $prefix) {
|
||||
$file = $prefix."_".preg_replace('/^html_/', '', $modele).".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = dol_buildpath($reldir."core/modules/dons/".$file, 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
if (file_exists($file)) {
|
||||
$filefound = 1;
|
||||
$classname = $prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($filefound) break;
|
||||
if ($filefound) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Charge le modele
|
||||
if ($filefound)
|
||||
{
|
||||
if ($filefound) {
|
||||
require_once $file;
|
||||
|
||||
$object = $this;
|
||||
|
|
@ -1086,8 +1063,7 @@ class Don extends CommonObject
|
|||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
$sav_charset_output = $outputlangs->charset_output;
|
||||
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0)
|
||||
{
|
||||
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) {
|
||||
$outputlangs->charset_output = $sav_charset_output;
|
||||
|
||||
// we delete preview files
|
||||
|
|
|
|||
|
|
@ -84,7 +84,9 @@ class DonationStats extends Stats
|
|||
|
||||
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
|
||||
$this->where .= " AND d.entity = ".$conf->entity;
|
||||
if ($this->userid > 0) $this->where .= ' WHERE c.fk_user_author = '.$this->userid;
|
||||
if ($this->userid > 0) {
|
||||
$this->where .= ' WHERE c.fk_user_author = '.$this->userid;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -120,25 +120,39 @@ class PaymentDonation extends CommonObject
|
|||
$now = dol_now();
|
||||
|
||||
// Validate parameters
|
||||
if (!$this->datepaid)
|
||||
{
|
||||
if (!$this->datepaid) {
|
||||
$this->error = 'ErrorBadValueForParameterCreatePaymentDonation';
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation;
|
||||
if (isset($this->amount)) $this->amount = trim($this->amount);
|
||||
if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment);
|
||||
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
|
||||
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
|
||||
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
if (isset($this->fk_donation)) {
|
||||
$this->fk_donation = (int) $this->fk_donation;
|
||||
}
|
||||
if (isset($this->amount)) {
|
||||
$this->amount = trim($this->amount);
|
||||
}
|
||||
if (isset($this->fk_typepayment)) {
|
||||
$this->fk_typepayment = trim($this->fk_typepayment);
|
||||
}
|
||||
if (isset($this->num_payment)) {
|
||||
$this->num_payment = trim($this->num_payment);
|
||||
}
|
||||
if (isset($this->note_public)) {
|
||||
$this->note_public = trim($this->note_public);
|
||||
}
|
||||
if (isset($this->fk_bank)) {
|
||||
$this->fk_bank = (int) $this->fk_bank;
|
||||
}
|
||||
if (isset($this->fk_user_creat)) {
|
||||
$this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
}
|
||||
if (isset($this->fk_user_modif)) {
|
||||
$this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
}
|
||||
|
||||
$totalamount = 0;
|
||||
foreach ($this->amounts as $key => $value) // How payment is dispatch
|
||||
{
|
||||
foreach ($this->amounts as $key => $value) { // How payment is dispatch
|
||||
$newvalue = price2num($value, 'MT');
|
||||
$this->amounts[$key] = $newvalue;
|
||||
$totalamount += $newvalue;
|
||||
|
|
@ -146,13 +160,14 @@ class PaymentDonation extends CommonObject
|
|||
$totalamount = price2num($totalamount);
|
||||
|
||||
// Check parameters
|
||||
if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null
|
||||
if ($totalamount == 0) {
|
||||
return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null
|
||||
}
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if ($totalamount != 0)
|
||||
{
|
||||
if ($totalamount != 0) {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_donation (fk_donation, datec, datep, amount,";
|
||||
$sql .= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)";
|
||||
$sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',";
|
||||
|
|
@ -163,8 +178,7 @@ class PaymentDonation extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_donation");
|
||||
$this->ref = $this->id;
|
||||
} else {
|
||||
|
|
@ -172,16 +186,16 @@ class PaymentDonation extends CommonObject
|
|||
}
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
if (!$error && !$notrigger) {
|
||||
// Call triggers
|
||||
$result = $this->call_trigger('DONATION_PAYMENT_CREATE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if ($totalamount != 0 && !$error)
|
||||
{
|
||||
if ($totalamount != 0 && !$error) {
|
||||
$this->amount = $totalamount;
|
||||
$this->total = $totalamount; // deprecated
|
||||
$this->db->commit();
|
||||
|
|
@ -224,10 +238,8 @@ class PaymentDonation extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
|
|
@ -275,14 +287,30 @@ class PaymentDonation extends CommonObject
|
|||
|
||||
// Clean parameters
|
||||
|
||||
if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation;
|
||||
if (isset($this->amount)) $this->amount = trim($this->amount);
|
||||
if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment);
|
||||
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
|
||||
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
|
||||
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
if (isset($this->fk_donation)) {
|
||||
$this->fk_donation = (int) $this->fk_donation;
|
||||
}
|
||||
if (isset($this->amount)) {
|
||||
$this->amount = trim($this->amount);
|
||||
}
|
||||
if (isset($this->fk_typepayment)) {
|
||||
$this->fk_typepayment = trim($this->fk_typepayment);
|
||||
}
|
||||
if (isset($this->num_payment)) {
|
||||
$this->num_payment = trim($this->num_payment);
|
||||
}
|
||||
if (isset($this->note_public)) {
|
||||
$this->note_public = trim($this->note_public);
|
||||
}
|
||||
if (isset($this->fk_bank)) {
|
||||
$this->fk_bank = (int) $this->fk_bank;
|
||||
}
|
||||
if (isset($this->fk_user_creat)) {
|
||||
$this->fk_user_creat = (int) $this->fk_user_creat;
|
||||
}
|
||||
if (isset($this->fk_user_modif)) {
|
||||
$this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
|
|
@ -311,25 +339,22 @@ class PaymentDonation extends CommonObject
|
|||
$this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$notrigger)
|
||||
{
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
if (!$error && !$notrigger) {
|
||||
// Call triggers
|
||||
$result = $this->call_trigger('DONATION_PAYMENT_MODIFY', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
|
|
@ -356,18 +381,18 @@ class PaymentDonation extends CommonObject
|
|||
|
||||
$this->db->begin();
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
|
||||
$sql .= " WHERE type='payment_donation' AND url_id=".(int) $this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
||||
if (!$resql) {
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_donation";
|
||||
$sql .= " WHERE rowid=".$this->id;
|
||||
|
||||
|
|
@ -379,25 +404,22 @@ class PaymentDonation extends CommonObject
|
|||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$notrigger)
|
||||
{
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
if (!$error && !$notrigger) {
|
||||
// Call triggers
|
||||
$result = $this->call_trigger('DONATION_PAYMENT_DELETE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
|
|
@ -439,21 +461,18 @@ class PaymentDonation extends CommonObject
|
|||
$result = $object->create($user);
|
||||
|
||||
// Other options
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
$this->error = $object->error;
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
}
|
||||
|
||||
unset($object->context['createfromclone']);
|
||||
|
||||
// End
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return $object->id;
|
||||
} else {
|
||||
|
|
@ -534,15 +553,16 @@ class PaymentDonation extends CommonObject
|
|||
|
||||
$error = 0;
|
||||
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
$acc = new Account($this->db);
|
||||
$acc->fetch($accountid);
|
||||
|
||||
$total = $this->total;
|
||||
if ($mode == 'payment_donation') $amount = $total;
|
||||
if ($mode == 'payment_donation') {
|
||||
$amount = $total;
|
||||
}
|
||||
|
||||
// Insert payment into llx_bank
|
||||
$bank_line_id = $acc->addline(
|
||||
|
|
@ -559,23 +579,21 @@ class PaymentDonation extends CommonObject
|
|||
|
||||
// Update fk_bank in llx_paiement.
|
||||
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
||||
if ($bank_line_id > 0)
|
||||
{
|
||||
if ($bank_line_id > 0) {
|
||||
$result = $this->update_fk_bank($bank_line_id);
|
||||
if ($result <= 0)
|
||||
{
|
||||
if ($result <= 0) {
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
// Add link 'payment', 'payment_supplier', 'payment_donation' in bank_url between payment and bank transaction
|
||||
$url = '';
|
||||
if ($mode == 'payment_donation') $url = DOL_URL_ROOT.'/don/payment/card.php?rowid=';
|
||||
if ($url)
|
||||
{
|
||||
if ($mode == 'payment_donation') {
|
||||
$url = DOL_URL_ROOT.'/don/payment/card.php?rowid=';
|
||||
}
|
||||
if ($url) {
|
||||
$result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
|
||||
if ($result <= 0)
|
||||
{
|
||||
if ($result <= 0) {
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
|
@ -586,8 +604,7 @@ class PaymentDonation extends CommonObject
|
|||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
|
|
@ -609,8 +626,7 @@ class PaymentDonation extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $this->db->error();
|
||||
|
|
@ -635,14 +651,19 @@ class PaymentDonation extends CommonObject
|
|||
$label .= '<br>';
|
||||
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
||||
|
||||
if (!empty($this->id))
|
||||
{
|
||||
if (!empty($this->id)) {
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$linkend = '</a>';
|
||||
|
||||
if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' ');
|
||||
if ($withpicto && $withpicto != 2) $result .= ' ';
|
||||
if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend;
|
||||
if ($withpicto) {
|
||||
$result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' ');
|
||||
}
|
||||
if ($withpicto && $withpicto != 2) {
|
||||
$result .= ' ';
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
}
|
||||
|
|
@ -50,7 +49,9 @@ $confirm = GETPOST('confirm', 'alpha');
|
|||
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'don', $id, '');
|
||||
|
||||
|
||||
|
|
@ -59,12 +60,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
|||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) $sortfield = "name";
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "name";
|
||||
}
|
||||
|
||||
|
||||
$object = new Don($db);
|
||||
|
|
@ -80,8 +87,7 @@ $modulepart = 'don';
|
|||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
|
||||
|
||||
if ($action == 'classin' && $user->rights->don->creer)
|
||||
{
|
||||
if ($action == 'classin' && $user->rights->don->creer) {
|
||||
$object->fetch($id);
|
||||
$object->setProject($projectid);
|
||||
}
|
||||
|
|
@ -91,15 +97,16 @@ if ($action == 'classin' && $user->rights->don->creer)
|
|||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$formproject = new FormProjets($db);
|
||||
}
|
||||
|
||||
$title = $langs->trans('Donation')." - ".$langs->trans('Documents');
|
||||
$helpurl = "";
|
||||
llxHeader('', $title, $helpurl);
|
||||
|
||||
|
||||
if ($object->id)
|
||||
{
|
||||
if ($object->id) {
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$head = donation_prepare_head($object);
|
||||
|
|
@ -110,8 +117,7 @@ if ($object->id)
|
|||
// Build file list
|
||||
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
|
||||
$totalsize = 0;
|
||||
foreach ($filearray as $key => $file)
|
||||
{
|
||||
foreach ($filearray as $key => $file) {
|
||||
$totalsize += $file['size'];
|
||||
}
|
||||
|
||||
|
|
@ -119,12 +125,10 @@ if ($object->id)
|
|||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$langs->load("projects");
|
||||
$morehtmlref .= $langs->trans('Project').' ';
|
||||
if ($user->rights->don->creer)
|
||||
{
|
||||
if ($user->rights->don->creer) {
|
||||
if ($action != 'classify') {
|
||||
// $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
}
|
||||
|
|
@ -166,7 +170,7 @@ if ($object->id)
|
|||
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
|
||||
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
|
||||
print '</td></tr>';
|
||||
*/
|
||||
*/
|
||||
|
||||
// Societe
|
||||
//print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>";
|
||||
|
|
|
|||
|
|
@ -66,12 +66,10 @@ $sql .= " GROUP BY d.fk_statut";
|
|||
$sql .= " ORDER BY d.fk_statut";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$i = 0;
|
||||
$num = $db->num_rows($result);
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$somme[$objp->fk_statut] = $objp->somme;
|
||||
|
|
@ -90,25 +88,25 @@ print load_fiche_titre($langs->trans("DonationsArea"), '', 'object_donation');
|
|||
|
||||
print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
|
||||
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
|
||||
{
|
||||
if (!empty($conf->don->enabled) && $user->rights->don->lire)
|
||||
{
|
||||
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo
|
||||
if (!empty($conf->don->enabled) && $user->rights->don->lire) {
|
||||
$listofsearchfields['search_donation'] = array('text'=>'Donation');
|
||||
}
|
||||
|
||||
if (count($listofsearchfields))
|
||||
{
|
||||
if (count($listofsearchfields)) {
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<table class="noborder nohover centpercent">';
|
||||
$i = 0;
|
||||
foreach ($listofsearchfields as $key => $value)
|
||||
{
|
||||
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||
foreach ($listofsearchfields as $key => $value) {
|
||||
if ($i == 0) {
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||
}
|
||||
print '<tr '.$bc[false].'>';
|
||||
print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'"></td>';
|
||||
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||
if ($i == 0) {
|
||||
print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
|
|
@ -129,17 +127,23 @@ print '<th colspan="4">'.$langs->trans("Statistics").'</th>';
|
|||
print "</tr>\n";
|
||||
|
||||
$listofstatus = array(0, 1, -1, 2);
|
||||
foreach ($listofstatus as $status)
|
||||
{
|
||||
foreach ($listofstatus as $status) {
|
||||
$dataseries[] = array($donstatic->LibStatut($status, 1), (isset($nb[$status]) ? (int) $nb[$status] : 0));
|
||||
if ($status == Don::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
|
||||
if ($status == Don::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1;
|
||||
if ($status == Don::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9;
|
||||
if ($status == Don::STATUS_PAID) $colorseries[$status] = $badgeStatus6;
|
||||
if ($status == Don::STATUS_DRAFT) {
|
||||
$colorseries[$status] = '-'.$badgeStatus0;
|
||||
}
|
||||
if ($status == Don::STATUS_VALIDATED) {
|
||||
$colorseries[$status] = $badgeStatus1;
|
||||
}
|
||||
if ($status == Don::STATUS_CANCELED) {
|
||||
$colorseries[$status] = $badgeStatus9;
|
||||
}
|
||||
if ($status == Don::STATUS_PAID) {
|
||||
$colorseries[$status] = $badgeStatus6;
|
||||
}
|
||||
}
|
||||
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print '<tr><td class="center" colspan="4">';
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||
|
|
@ -165,8 +169,7 @@ print '</tr>';
|
|||
|
||||
$total = 0;
|
||||
$totalnb = 0;
|
||||
foreach ($listofstatus as $status)
|
||||
{
|
||||
foreach ($listofstatus as $status) {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td><a href="list.php?search_status='.$status.'">'.$donstatic->LibStatut($status, 4).'</a></td>';
|
||||
print '<td class="right">'.(!empty($nb[$status]) ? $nb[$status] : ' ').'</td>';
|
||||
|
|
@ -203,18 +206,15 @@ $sql .= " ORDER BY c.tms DESC";
|
|||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th colspan="5">'.$langs->trans("LastModifiedDonations", $max).'</th></tr>';
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
if ($num) {
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
|
@ -246,7 +246,9 @@ if ($resql)
|
|||
}
|
||||
}
|
||||
print "</table><br>";
|
||||
} else dol_print_error($db);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
print '</div></div></div>';
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ require '../main.inc.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
}
|
||||
|
|
@ -39,7 +38,9 @@ $action = GETPOST('action', 'aZ09');
|
|||
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'don', $id, '');
|
||||
|
||||
$object = new Don($db);
|
||||
|
|
@ -47,8 +48,7 @@ $object->fetch($id);
|
|||
/*
|
||||
* Actions
|
||||
*/
|
||||
if ($action == 'classin' && $user->rights->don->creer)
|
||||
{
|
||||
if ($action == 'classin' && $user->rights->don->creer) {
|
||||
$object->fetch($id);
|
||||
$object->setProject($projectid);
|
||||
}
|
||||
|
|
@ -61,7 +61,9 @@ $helpurl = "";
|
|||
llxHeader('', $title, $helpurl);
|
||||
|
||||
$form = new Form($db);
|
||||
if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$formproject = new FormProjets($db);
|
||||
}
|
||||
|
||||
$object->info($id);
|
||||
|
||||
|
|
@ -73,12 +75,10 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(!empty($socid) ? '?socid='
|
|||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$langs->load("projects");
|
||||
$morehtmlref .= $langs->trans('Project').' ';
|
||||
if ($user->rights->don->creer)
|
||||
{
|
||||
if ($user->rights->don->creer) {
|
||||
if ($action != 'classify') {
|
||||
// $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@
|
|||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("companies", "donations"));
|
||||
|
|
@ -38,12 +40,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
|||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) $sortorder = "DESC";
|
||||
if (!$sortfield) $sortfield = "d.datedon";
|
||||
if (!$sortorder) {
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "d.datedon";
|
||||
}
|
||||
|
||||
$search_status = (GETPOST("search_status", 'intcomma') != '') ? GETPOST("search_status", 'intcomma') : "-4";
|
||||
$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
|
||||
|
|
@ -53,10 +61,11 @@ $search_name = GETPOST('search_name', 'alpha');
|
|||
$search_amount = GETPOST('search_amount', 'alpha');
|
||||
$optioncss = GETPOST('optioncss', 'alpha');
|
||||
|
||||
if (!$user->rights->don->lire) accessforbidden();
|
||||
if (!$user->rights->don->lire) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
|
||||
$search_all = "";
|
||||
$search_ref = "";
|
||||
$search_company = "";
|
||||
|
|
@ -84,7 +93,9 @@ $fieldstosearchall = array(
|
|||
|
||||
$donationstatic = new Don($db);
|
||||
$form = new Form($db);
|
||||
if (!empty($conf->projet->enabled)) $projectstatic = new Project($db);
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$projectstatic = new Project($db);
|
||||
}
|
||||
|
||||
llxHeader('', $langs->trans("Donations"), 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones');
|
||||
|
||||
|
|
@ -94,37 +105,32 @@ $sql .= " d.amount, d.fk_statut as status,";
|
|||
$sql .= " p.rowid as pid, p.ref, p.title, p.public";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p";
|
||||
$sql .= " ON p.rowid = d.fk_projet WHERE d.entity IN (".getEntity('donation').")";
|
||||
if ($search_status != '' && $search_status != '-4')
|
||||
{
|
||||
if ($search_status != '' && $search_status != '-4') {
|
||||
$sql .= " AND d.fk_statut IN (".$db->sanitize($db->escape($search_status)).")";
|
||||
}
|
||||
if (trim($search_ref) != '')
|
||||
{
|
||||
if (trim($search_ref) != '') {
|
||||
$sql .= natural_search('d.ref', $search_ref);
|
||||
}
|
||||
if (trim($search_all) != '')
|
||||
{
|
||||
if (trim($search_all) != '') {
|
||||
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
|
||||
}
|
||||
if (trim($search_company) != '')
|
||||
{
|
||||
if (trim($search_company) != '') {
|
||||
$sql .= natural_search('d.societe', $search_company);
|
||||
}
|
||||
if (trim($search_name) != '')
|
||||
{
|
||||
if (trim($search_name) != '') {
|
||||
$sql .= natural_search(array('d.lastname', 'd.firstname'), $search_name);
|
||||
}
|
||||
if ($search_amount) $sql .= natural_search('d.amount', $search_amount, 1);
|
||||
if ($search_amount) {
|
||||
$sql .= natural_search('d.amount', $search_amount, 1);
|
||||
}
|
||||
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
|
|
@ -133,29 +139,45 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
|||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if ($search_status && $search_status != -1) $param .= '&search_status='.urlencode($search_status);
|
||||
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
|
||||
if ($search_company) $param .= '&search_company='.urlencode($search_company);
|
||||
if ($search_name) $param .= '&search_name='.urlencode($search_name);
|
||||
if ($search_amount) $param .= '&search_amount='.urlencode($search_amount);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
if ($search_status && $search_status != -1) {
|
||||
$param .= '&search_status='.urlencode($search_status);
|
||||
}
|
||||
if ($search_ref) {
|
||||
$param .= '&search_ref='.urlencode($search_ref);
|
||||
}
|
||||
if ($search_company) {
|
||||
$param .= '&search_company='.urlencode($search_company);
|
||||
}
|
||||
if ($search_name) {
|
||||
$param .= '&search_name='.urlencode($search_name);
|
||||
}
|
||||
if ($search_amount) {
|
||||
$param .= '&search_amount='.urlencode($search_amount);
|
||||
}
|
||||
|
||||
$newcardbutton = '';
|
||||
if ($user->rights->don->creer)
|
||||
{
|
||||
if ($user->rights->don->creer) {
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create');
|
||||
}
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
|
|
@ -165,9 +187,10 @@ if ($resql)
|
|||
|
||||
print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1);
|
||||
|
||||
if ($search_all)
|
||||
{
|
||||
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
|
||||
if ($search_all) {
|
||||
foreach ($fieldstosearchall as $key => $val) {
|
||||
$fieldstosearchall[$key] = $langs->trans($val);
|
||||
}
|
||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
|
||||
}
|
||||
|
||||
|
|
@ -194,8 +217,7 @@ if ($resql)
|
|||
print '<td class="liste_titre left">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
print '<td class="liste_titre right">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
|
|
@ -225,8 +247,7 @@ if ($resql)
|
|||
}
|
||||
print_liste_field_titre("Name", $_SERVER["PHP_SELF"], "d.lastname", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.datedon", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$langs->load("projects");
|
||||
print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "d.fk_projet", "", $param, "", $sortfield, $sortorder);
|
||||
}
|
||||
|
|
@ -235,8 +256,7 @@ if ($resql)
|
|||
print_liste_field_titre('');
|
||||
print "</tr>\n";
|
||||
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
while ($i < min($num, $limit)) {
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
|
@ -258,18 +278,18 @@ if ($resql)
|
|||
}
|
||||
print "<td>".$donationstatic->getFullName($langs)."</td>";
|
||||
print '<td class="center">'.dol_print_date($db->jdate($objp->datedon), 'day').'</td>';
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
print "<td>";
|
||||
if ($objp->pid)
|
||||
{
|
||||
if ($objp->pid) {
|
||||
$projectstatic->id = $objp->pid;
|
||||
$projectstatic->ref = $objp->ref;
|
||||
$projectstatic->id = $objp->pid;
|
||||
$projectstatic->public = $objp->public;
|
||||
$projectstatic->title = $objp->title;
|
||||
print $projectstatic->getNomUrl(1);
|
||||
} else print ' ';
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
print "</td>\n";
|
||||
}
|
||||
print '<td class="right">'.price($objp->amount).'</td>';
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ require '../main.inc.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
}
|
||||
|
|
@ -45,7 +44,9 @@ $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
|
|||
|
||||
// Security check
|
||||
$socid = 0;
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'don', $id, '');
|
||||
|
||||
$object = new Don($db);
|
||||
|
|
@ -59,8 +60,7 @@ $permissionnote = $user->rights->don->creer; // Used by the include of actions_s
|
|||
*/
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
||||
|
||||
if ($action == 'classin' && $user->rights->don->creer)
|
||||
{
|
||||
if ($action == 'classin' && $user->rights->don->creer) {
|
||||
$object->fetch($id);
|
||||
$object->setProject($projectid);
|
||||
}
|
||||
|
|
@ -74,10 +74,11 @@ $helpurl = "";
|
|||
llxHeader('', $title, $helpurl);
|
||||
|
||||
$form = new Form($db);
|
||||
if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$formproject = new FormProjets($db);
|
||||
}
|
||||
|
||||
if ($id > 0 || !empty($ref))
|
||||
{
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$object = new Don($db);
|
||||
$object->fetch($id, $ref);
|
||||
|
||||
|
|
@ -89,12 +90,10 @@ if ($id > 0 || !empty($ref))
|
|||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$langs->load("projects");
|
||||
$morehtmlref .= $langs->trans('Project').' ';
|
||||
if ($user->rights->don->creer)
|
||||
{
|
||||
if ($user->rights->don->creer) {
|
||||
if ($action != 'classify') {
|
||||
// $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
|
||||
if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("bills", "banks", "companies", "donations"));
|
||||
|
|
@ -36,15 +38,18 @@ $langs->loadLangs(array("bills", "banks", "companies", "donations"));
|
|||
$id = GETPOST('rowid') ? GETPOST('rowid', 'int') : GETPOST('id', 'int');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
// TODO Add rule to restrict access payment
|
||||
//$result = restrictedArea($user, 'facture', $id,'');
|
||||
|
||||
$object = new PaymentDonation($db);
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
$result = $object->fetch($id);
|
||||
if (!$result) dol_print_error($db, 'Failed to get payment id '.$id);
|
||||
if (!$result) {
|
||||
dol_print_error($db, 'Failed to get payment id '.$id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -53,13 +58,11 @@ if ($id > 0)
|
|||
*/
|
||||
|
||||
// Delete payment
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->don->supprimer)
|
||||
{
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->don->supprimer) {
|
||||
$db->begin();
|
||||
|
||||
$result = $object->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$db->commit();
|
||||
header("Location: ".DOL_URL_ROOT."/don/index.php");
|
||||
exit;
|
||||
|
|
@ -93,8 +96,7 @@ print dol_get_fiche_head($head, $hselected, $langs->trans("DonationPayment"), -1
|
|||
/*
|
||||
* Confirm deleting of the payment
|
||||
*/
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
|
||||
}
|
||||
|
||||
|
|
@ -122,10 +124,8 @@ print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount, 0, $
|
|||
print '<tr><td>'.$langs->trans('Note').'</td><td>'.nl2br($object->note_public).'</td></tr>';
|
||||
|
||||
// Bank account
|
||||
if (!empty($conf->banque->enabled))
|
||||
{
|
||||
if ($object->bank_account)
|
||||
{
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
if ($object->bank_account) {
|
||||
$bankline = new AccountLine($db);
|
||||
$bankline->fetch($object->bank_line);
|
||||
|
||||
|
|
@ -154,8 +154,7 @@ $sql .= ' AND pd.rowid = '.$id;
|
|||
|
||||
dol_syslog("don/payment/card.php", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
|
|
@ -168,10 +167,8 @@ if ($resql)
|
|||
print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
if ($num > 0) {
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
|
@ -213,12 +210,9 @@ print dol_get_fiche_end();
|
|||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if (empty($action))
|
||||
{
|
||||
if ($user->rights->don->supprimer)
|
||||
{
|
||||
if (!$disable_delete)
|
||||
{
|
||||
if (empty($action)) {
|
||||
if ($user->rights->don->supprimer) {
|
||||
if (!$disable_delete) {
|
||||
print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>';
|
||||
|
|
|
|||
|
|
@ -46,12 +46,10 @@ $object = new Don($db);
|
|||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'add_payment')
|
||||
{
|
||||
if ($action == 'add_payment') {
|
||||
$error = 0;
|
||||
|
||||
if ($_POST["cancel"])
|
||||
{
|
||||
if ($_POST["cancel"]) {
|
||||
$loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid;
|
||||
header("Location: ".$loc);
|
||||
exit;
|
||||
|
|
@ -59,45 +57,37 @@ if ($action == 'add_payment')
|
|||
|
||||
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
|
||||
if (!$_POST["paymenttype"] > 0)
|
||||
{
|
||||
if (!$_POST["paymenttype"] > 0) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if ($datepaid == '')
|
||||
{
|
||||
if ($datepaid == '') {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (!empty($conf->banque->enabled) && !$_POST["accountid"] > 0)
|
||||
{
|
||||
if (!empty($conf->banque->enabled) && !$_POST["accountid"] > 0) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$paymentid = 0;
|
||||
|
||||
// Read possible payments
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
if (substr($key, 0, 7) == 'amount_')
|
||||
{
|
||||
foreach ($_POST as $key => $value) {
|
||||
if (substr($key, 0, 7) == 'amount_') {
|
||||
$other_chid = substr($key, 7);
|
||||
$amounts[$other_chid] = price2num($_POST[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($amounts) <= 0)
|
||||
{
|
||||
if (count($amounts) <= 0) {
|
||||
$error++;
|
||||
$errmsg = 'ErrorNoPaymentDefined';
|
||||
setEventMessages($errmsg, null, 'errors');
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->begin();
|
||||
|
||||
// Create a line of payments
|
||||
|
|
@ -109,30 +99,25 @@ if ($action == 'add_payment')
|
|||
$payment->num_payment = GETPOST("num_payment", 'alphanohtml');
|
||||
$payment->note_public = GETPOST("note_public", 'restricthtml');
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$paymentid = $payment->create($user);
|
||||
if ($paymentid < 0)
|
||||
{
|
||||
if ($paymentid < 0) {
|
||||
$errmsg = $payment->error;
|
||||
setEventMessages($errmsg, null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$result = $payment->addPaymentToBank($user, 'payment_donation', '(DonationPayment)', $_POST['accountid'], '', '');
|
||||
if (!$result > 0)
|
||||
{
|
||||
if (!$result > 0) {
|
||||
$errmsg = $payment->error;
|
||||
setEventMessages($errmsg, null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
$loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid;
|
||||
header('Location: '.$loc);
|
||||
|
|
@ -160,8 +145,7 @@ $sql = "SELECT sum(p.amount) as total";
|
|||
$sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as p";
|
||||
$sql .= " WHERE p.fk_donation = ".$chid;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$sumpaid = $obj->total;
|
||||
$db->free();
|
||||
|
|
@ -169,16 +153,14 @@ if ($resql)
|
|||
|
||||
|
||||
// Form to create donation payment
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
$object->fetch($chid);
|
||||
|
||||
$total = $object->amount;
|
||||
|
||||
print load_fiche_titre($langs->trans("DoPayment"));
|
||||
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
{
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
print "\n".'<script type="text/javascript" language="javascript">';
|
||||
//Add js for AutoFill
|
||||
print ' $(document).ready(function () {';
|
||||
|
|
@ -234,7 +216,7 @@ if ($action == 'create')
|
|||
print dol_get_fiche_end();
|
||||
|
||||
/*
|
||||
* List of payments on donation
|
||||
* List of payments on donation
|
||||
*/
|
||||
|
||||
$num = 1;
|
||||
|
|
@ -252,8 +234,7 @@ if ($action == 'create')
|
|||
$total = 0;
|
||||
$totalrecu = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$objp = $object;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
|
@ -267,11 +248,11 @@ if ($action == 'create')
|
|||
print '<td class="right">'.price($objp->amount - $sumpaid)."</td>";
|
||||
|
||||
print '<td class="center">';
|
||||
if ($sumpaid < $objp->amount)
|
||||
{
|
||||
if ($sumpaid < $objp->amount) {
|
||||
$namef = "amount_".$objp->id;
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".price($objp->amount - $sumpaid)."'");
|
||||
}
|
||||
print '<input type="text" size="8" name="'.$namef.'">';
|
||||
} else {
|
||||
print '-';
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
|
|||
$userid = GETPOST('userid', 'int');
|
||||
$socid = GETPOST('socid', 'int');
|
||||
// Security check
|
||||
if ($user->socid > 0)
|
||||
{
|
||||
if ($user->socid > 0) {
|
||||
$action = '';
|
||||
$socid = $user->socid;
|
||||
}
|
||||
|
|
@ -72,8 +71,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
|
|||
// $data = array(array('Lib',val1,val2,val3),...)
|
||||
|
||||
|
||||
if (!$user->rights->societe->client->voir || $user->socid)
|
||||
{
|
||||
if (!$user->rights->societe->client->voir || $user->socid) {
|
||||
$filenamenb = $dir.'/shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
|
||||
} else {
|
||||
$filenamenb = $dir.'/shipmentsnbinyear-'.$year.'.png';
|
||||
|
|
@ -81,12 +79,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
|
|||
|
||||
$px1 = new DolGraph();
|
||||
$mesg = $px1->isGraphKo();
|
||||
if (!$mesg)
|
||||
{
|
||||
if (!$mesg) {
|
||||
$px1->SetData($data);
|
||||
$i = $startyear; $legend = array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
while ($i <= $endyear) {
|
||||
$legend[] = $i;
|
||||
$i++;
|
||||
}
|
||||
|
|
@ -112,36 +108,36 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
|
|||
|
||||
if (!$user->rights->societe->client->voir || $user->socid)
|
||||
{
|
||||
$filenameamount = $dir.'/shipmentsamountinyear-'.$user->id.'-'.$year.'.png';
|
||||
$filenameamount = $dir.'/shipmentsamountinyear-'.$user->id.'-'.$year.'.png';
|
||||
}
|
||||
else
|
||||
{
|
||||
$filenameamount = $dir.'/shipmentsamountinyear-'.$year.'.png';
|
||||
$filenameamount = $dir.'/shipmentsamountinyear-'.$year.'.png';
|
||||
}
|
||||
|
||||
$px2 = new DolGraph();
|
||||
$mesg = $px2->isGraphKo();
|
||||
if (! $mesg)
|
||||
{
|
||||
$px2->SetData($data);
|
||||
$i=$startyear;$legend=array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px2->SetLegend($legend);
|
||||
$px2->SetMaxValue($px2->GetCeilMaxValue());
|
||||
$px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
|
||||
$px2->SetWidth($WIDTH);
|
||||
$px2->SetHeight($HEIGHT);
|
||||
$px2->SetYLabel($langs->trans("AmountOfShipments"));
|
||||
$px2->SetShading(3);
|
||||
$px2->SetHorizTickIncrement(1);
|
||||
$px2->mode='depth';
|
||||
$px2->SetTitle($langs->trans("AmountOfShipmentsByMonthHT"));
|
||||
$px2->SetData($data);
|
||||
$i=$startyear;$legend=array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px2->SetLegend($legend);
|
||||
$px2->SetMaxValue($px2->GetCeilMaxValue());
|
||||
$px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
|
||||
$px2->SetWidth($WIDTH);
|
||||
$px2->SetHeight($HEIGHT);
|
||||
$px2->SetYLabel($langs->trans("AmountOfShipments"));
|
||||
$px2->SetShading(3);
|
||||
$px2->SetHorizTickIncrement(1);
|
||||
$px2->mode='depth';
|
||||
$px2->SetTitle($langs->trans("AmountOfShipmentsByMonthHT"));
|
||||
|
||||
$px2->draw($filenameamount,$fileurlamount);
|
||||
$px2->draw($filenameamount,$fileurlamount);
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
@ -150,36 +146,36 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
|
|||
|
||||
if (!$user->rights->societe->client->voir || $user->socid)
|
||||
{
|
||||
$filename_avg = $dir.'/shipmentsaverage-'.$user->id.'-'.$year.'.png';
|
||||
$filename_avg = $dir.'/shipmentsaverage-'.$user->id.'-'.$year.'.png';
|
||||
}
|
||||
else
|
||||
{
|
||||
$filename_avg = $dir.'/shipmentsaverage-'.$year.'.png';
|
||||
$filename_avg = $dir.'/shipmentsaverage-'.$year.'.png';
|
||||
}
|
||||
|
||||
$px3 = new DolGraph();
|
||||
$mesg = $px3->isGraphKo();
|
||||
if (! $mesg)
|
||||
{
|
||||
$px3->SetData($data);
|
||||
$i=$startyear;$legend=array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px3->SetLegend($legend);
|
||||
$px3->SetYLabel($langs->trans("AmountAverage"));
|
||||
$px3->SetMaxValue($px3->GetCeilMaxValue());
|
||||
$px3->SetMinValue($px3->GetFloorMinValue());
|
||||
$px3->SetWidth($WIDTH);
|
||||
$px3->SetHeight($HEIGHT);
|
||||
$px3->SetShading(3);
|
||||
$px3->SetHorizTickIncrement(1);
|
||||
$px3->mode='depth';
|
||||
$px3->SetTitle($langs->trans("AmountAverage"));
|
||||
$px3->SetData($data);
|
||||
$i=$startyear;$legend=array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px3->SetLegend($legend);
|
||||
$px3->SetYLabel($langs->trans("AmountAverage"));
|
||||
$px3->SetMaxValue($px3->GetCeilMaxValue());
|
||||
$px3->SetMinValue($px3->GetFloorMinValue());
|
||||
$px3->SetWidth($WIDTH);
|
||||
$px3->SetHeight($HEIGHT);
|
||||
$px3->SetShading(3);
|
||||
$px3->SetHorizTickIncrement(1);
|
||||
$px3->mode='depth';
|
||||
$px3->SetTitle($langs->trans("AmountAverage"));
|
||||
|
||||
$px3->draw($filename_avg,$fileurl_avg);
|
||||
$px3->draw($filename_avg,$fileurl_avg);
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
@ -192,7 +188,9 @@ foreach ($data as $val) {
|
|||
$arrayyears[$val['year']] = $val['year'];
|
||||
}
|
||||
}
|
||||
if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
|
||||
if (!count($arrayyears)) {
|
||||
$arrayyears[$nowyear] = $nowyear;
|
||||
}
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
|
@ -229,8 +227,12 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
|
|||
print '</td></tr>';
|
||||
// Year
|
||||
print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">';
|
||||
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
|
||||
if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
|
||||
if (!in_array($year, $arrayyears)) {
|
||||
$arrayyears[$year] = $year;
|
||||
}
|
||||
if (!in_array($nowyear, $arrayyears)) {
|
||||
$arrayyears[$nowyear] = $nowyear;
|
||||
}
|
||||
arsort($arrayyears);
|
||||
print $form->selectarray('year', $arrayyears, $year, 0);
|
||||
print '</td></tr>';
|
||||
|
|
@ -250,11 +252,9 @@ print '<td class="center">'.$langs->trans("AmountAverage").'</td>';*/
|
|||
print '</tr>';
|
||||
|
||||
$oldyear = 0;
|
||||
foreach ($data as $val)
|
||||
{
|
||||
foreach ($data as $val) {
|
||||
$year = $val['year'];
|
||||
while (!empty($year) && $oldyear > $year + 1)
|
||||
{ // If we have empty year
|
||||
while (!empty($year) && $oldyear > $year + 1) { // If we have empty year
|
||||
$oldyear--;
|
||||
print '<tr height="24">';
|
||||
print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'">'.$oldyear.'</a></td>';
|
||||
|
|
@ -283,12 +283,14 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
|||
|
||||
// Show graphs
|
||||
print '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
|
||||
if ($mesg) { print $mesg; } else {
|
||||
if ($mesg) {
|
||||
print $mesg;
|
||||
} else {
|
||||
print $px1->show();
|
||||
print "<br>\n";
|
||||
/*print $px2->show();
|
||||
print "<br>\n";
|
||||
print $px3->show();*/
|
||||
print "<br>\n";
|
||||
print $px3->show();*/
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
|
||||
|
|
@ -315,17 +317,17 @@ $sql.= " GROUP BY dm DESC";
|
|||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$nbproduct = $row[0];
|
||||
$year = $row[1];
|
||||
print "<tr>";
|
||||
print '<td class="center"><a href="month.php?year='.$year.'">'.$year.'</a></td><td class="center">'.$nbproduct.'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$nbproduct = $row[0];
|
||||
$year = $row[1];
|
||||
print "<tr>";
|
||||
print '<td class="center"><a href="month.php?year='.$year.'">'.$year.'</a></td><td class="center">'.$nbproduct.'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$db->free($resql);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
|
|||
$ilink++;
|
||||
|
||||
$trclass = 'oddeven';
|
||||
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total';
|
||||
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
|
||||
$trclass .= ' liste_sub_total';
|
||||
}
|
||||
print '<tr class="'.$trclass.'">';
|
||||
print '<td>'.$langs->trans("Donation").'</td>';
|
||||
print '<td>'.$objectlink->getNomUrl(1).'</td>';
|
||||
|
|
@ -49,19 +51,18 @@ print '</td>';
|
|||
print '<td class="right">'.$objectlink->getLibStatut(3).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
if (count($linkedObjectBlock) > 1)
|
||||
{
|
||||
if (count($linkedObjectBlock) > 1) {
|
||||
?>
|
||||
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>">
|
||||
<td><?php echo $langs->trans("Total"); ?></td>
|
||||
<td></td>
|
||||
<td class="center"></td>
|
||||
<td class="center"></td>
|
||||
<td class="right"><?php echo price($total); ?></td>
|
||||
<td class="right"></td>
|
||||
<td class="right"></td>
|
||||
</tr>
|
||||
<?php
|
||||
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>">
|
||||
<td><?php echo $langs->trans("Total"); ?></td>
|
||||
<td></td>
|
||||
<td class="center"></td>
|
||||
<td class="center"></td>
|
||||
<td class="right"><?php echo price($total); ?></td>
|
||||
<td class="right"></td>
|
||||
<td class="right"></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
print "<!-- END PHP TEMPLATE -->\n";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user