diff --git a/htdocs/don/admin/donation.php b/htdocs/don/admin/donation.php index 7b0896134e0..2cbd00c8522 100644 --- a/htdocs/don/admin/donation.php +++ b/htdocs/don/admin/donation.php @@ -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 = ''.$langs->trans("BackToModuleList").''; @@ -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 ''; echo $module->name; print ''; @@ -252,10 +241,8 @@ if (is_resource($handle)) print ''; // 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 "\n"; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; @@ -271,8 +258,7 @@ if (is_resource($handle)) } // Default - if ($conf->global->DON_ADDON_MODEL == "$name") - { + if ($conf->global->DON_ADDON_MODEL == "$name") { print ""; print img_picto($langs->trans("Default"), 'on'); print ''; @@ -285,8 +271,7 @@ if (is_resource($handle)) // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; @@ -345,8 +330,7 @@ print ''; $label = $langs->trans("AccountAccounting"); print ''; print ''; -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 ''; @@ -373,8 +357,7 @@ print ''; /* * 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 '
'; print load_fiche_titre($langs->trans("FrenchOptions"), '', ''); diff --git a/htdocs/don/admin/donation_extrafields.php b/htdocs/don/admin/donation_extrafields.php index 6062d4fca26..699bcdf7379 100644 --- a/htdocs/don/admin/donation_extrafields.php +++ b/htdocs/don/admin/donation_extrafields.php @@ -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 '
'; print '
'.$langs->trans("NewAttribute").'
'; print "
"; @@ -88,8 +91,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print "
"; 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 "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 1f0835ee80b..093e478e2c4 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -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 '
'; @@ -350,12 +349,10 @@ if ($action == 'create') print ''.$langs->trans('Ref').''.$langs->trans('Draft').''; // 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 ''.$langs->trans('Customer').''; - if ($soc->id > 0 && !GETPOST('fac_rec', 'alpha')) - { + if ($soc->id > 0 && !GETPOST('fac_rec', 'alpha')) { print ''; print $soc->getNomUrl(1); print ''; @@ -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 ''; 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 '