diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index a777ada50f9..eb61b7e7807 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'hrm')); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $error = 0; @@ -52,8 +53,12 @@ llxHeader('', $langs->trans("Establishments")); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortorder = GETPOST("sortorder", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); -if (!$sortorder) $sortorder = "DESC"; -if (!$sortfield) $sortfield = "e.rowid"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "e.rowid"; +} if (empty($page) || $page == -1) { $page = 0; @@ -79,8 +84,7 @@ $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); $i = 0; @@ -95,12 +99,10 @@ if ($result) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.status", "", "", '', $sortfield, $sortorder, 'right '); print "\n"; - if ($num > 0) - { + if ($num > 0) { $establishmentstatic = new Establishment($db); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($result); $establishmentstatic->id = $obj->rowid; diff --git a/htdocs/hrm/admin/admin_hrm.php b/htdocs/hrm/admin/admin_hrm.php index c4081e1d454..0131539071a 100644 --- a/htdocs/hrm/admin/admin_hrm.php +++ b/htdocs/hrm/admin/admin_hrm.php @@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'hrm')); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index dc97787ae6e..28a354c757f 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -180,7 +180,9 @@ class Establishment extends CommonObject $this->zip = trim($this->zip); $this->town = trim($this->town); - if (empty($this->ref)) $this->ref = '(PROV)'; + if (empty($this->ref)) { + $this->ref = '(PROV)'; + } $this->db->begin(); @@ -248,8 +250,7 @@ class Establishment extends CommonObject global $langs; // Check parameters - if (empty($this->label)) - { + if (empty($this->label)) { $this->error = 'ErrorBadParameter'; return -1; } @@ -296,8 +297,7 @@ class Establishment extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; @@ -334,8 +334,7 @@ class Establishment extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $this->db->commit(); return 1; } else { @@ -367,8 +366,7 @@ class Establishment 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("mymodule"); $this->labelStatus[self::STATUS_OPEN] = $langs->trans('Open'); @@ -378,8 +376,12 @@ class Establishment extends CommonObject } $statusType = 'status'.$status; - if ($status == self::STATUS_OPEN) $statusType = 'status4'; - if ($status == self::STATUS_CLOSED) $statusType = 'status6'; + if ($status == self::STATUS_OPEN) { + $statusType = 'status4'; + } + if ($status == self::STATUS_CLOSED) { + $statusType = 'status6'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -400,22 +402,18 @@ class Establishment extends CommonObject dol_syslog(get_class($this)."::fetch 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; $this->date_creation = $this->db->jdate($obj->datec); - 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_mod) - { + if ($obj->fk_user_mod) { $muser = new User($this->db); $muser->fetch($obj->fk_user_mod); $this->user_modification = $muser; @@ -449,9 +447,15 @@ class Establishment extends CommonObject $label = ''.$langs->trans("Establishment").''; $label .= '
'.$langs->trans("Label").': '.$this->label; - if ($withpicto) $result .= ($link.img_object($label, $picto).$linkend); - if ($withpicto && $withpicto != 2) $result .= ' '; - if ($withpicto != 2) $result .= $link.$this->label.$linkend; + if ($withpicto) { + $result .= ($link.img_object($label, $picto).$linkend); + } + if ($withpicto && $withpicto != 2) { + $result .= ' '; + } + if ($withpicto != 2) { + $result .= $link.$this->label.$linkend; + } return $result; } @@ -465,10 +469,14 @@ class Establishment extends CommonObject global $mysoc; // We return country code of bank account - if (!empty($this->country_code)) return $this->country_code; + if (!empty($this->country_code)) { + return $this->country_code; + } // We return country code of managed company - if (!empty($mysoc->country_code)) return $mysoc->country_code; + if (!empty($mysoc->country_code)) { + return $mysoc->country_code; + } return ''; } diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index 15fd44e2c3b..6c336d230f0 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $langs->loadLangs(array('admin', 'hrm')); // Security check -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $error = 0; @@ -44,7 +46,9 @@ static $tmpstatus2label = array( '1'=>'OpenEtablishment' ); $status2label = array(''); -foreach ($tmpstatus2label as $key => $val) $status2label[$key] = $langs->trans($val); +foreach ($tmpstatus2label as $key => $val) { + $status2label[$key] = $langs->trans($val); +} $object = new Establishment($db); @@ -56,31 +60,25 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ * Actions */ -if ($action == 'confirm_delete' && $confirm == "yes") -{ +if ($action == 'confirm_delete' && $confirm == "yes") { $result = $object->delete($id); - if ($result >= 0) - { + if ($result >= 0) { header("Location: ../admin/admin_establishment.php"); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } -} elseif ($action == 'add') -{ - if (!$cancel) - { +} elseif ($action == 'add') { + if (!$cancel) { $error = 0; $object->label = GETPOST('label', 'alpha'); - if (empty($object->label)) - { + if (empty($object->label)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); $error++; } - if (empty($error)) - { + if (empty($error)) { $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); @@ -92,8 +90,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") $id = $object->create($user); - if ($id > 0) - { + if ($id > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else { @@ -106,11 +103,8 @@ if ($action == 'confirm_delete' && $confirm == "yes") header("Location: ../admin/admin_establishment.php"); exit; } -} - -// Update record -elseif ($action == 'update') -{ +} elseif ($action == 'update') { + // Update record $error = 0; if (!$cancel) { @@ -120,8 +114,7 @@ elseif ($action == 'update') $error++; } - if (empty($error)) - { + if (empty($error)) { $object->label = GETPOST('label', 'alphanohtml'); $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); @@ -133,8 +126,7 @@ elseif ($action == 'update') $result = $object->update($user); - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST['id']); exit; } else { @@ -159,8 +151,7 @@ $formcompany = new FormCompany($db); /* * Action create */ -if ($action == 'create') -{ +if ($action == 'create') { print load_fiche_titre($langs->trans("NewEstablishment")); print '
'; @@ -228,7 +219,9 @@ if ($action == 'create') print ''.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).''; print ''; print $form->select_country(GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : ($object->country_id ? $object->country_id : $mysoc->country_id), 'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } print ''; print ''; @@ -253,15 +246,12 @@ if ($action == 'create') } // Part to edit record -if (($id || $ref) && $action == 'edit') -{ +if (($id || $ref) && $action == 'edit') { $result = $object->fetch($id); - if ($result > 0) - { + if ($result > 0) { $head = establishment_prepare_head($object); - if ($action == 'edit') - { + if ($action == 'edit') { print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), 0, 'building'); print ''."\n"; @@ -284,12 +274,12 @@ if (($id || $ref) && $action == 'edit') // Entity /* - if (! empty($conf->multicompany->enabled)) { - print ''.$form->editfieldkey('Parent', 'entity', '', $object, 0, 'string', '', 1).''; + if (! empty($conf->multicompany->enabled)) { + print ''.$form->editfieldkey('Parent', 'entity', '', $object, 0, 'string', '', 1).''; print ''; print $object->entity > 0 ? $object->entity : $conf->entity; - print ''; - }*/ + print ''; + }*/ // Address print ''.$form->editfieldkey('Address', 'address', '', $object, 0).''; @@ -313,7 +303,9 @@ if (($id || $ref) && $action == 'edit') print ''.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).''; print ''; print $form->select_country($object->country_id, 'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } print ''; print ''; @@ -334,19 +326,19 @@ if (($id || $ref) && $action == 'edit') print '
'; } - } else dol_print_error($db); + } else { + dol_print_error($db); + } } -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) -{ +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals(); $head = establishment_prepare_head($object); print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), -1, 'building'); // Confirmation to delete - if ($action == 'delete') - { + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteEstablishment"), $langs->trans("ConfirmDeleteEstablishment"), "confirm_delete"); } @@ -404,8 +396,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''.$langs->trans("Country").''; print ''; - if ($object->country_id > 0) - { + if ($object->country_id > 0) { $img = picto_from_langcode($object->country_code); print $img ? $img.' ' : ''; print getCountry($object->getCountryCode(), 0, $db); @@ -421,8 +412,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dol_get_fiche_end(); /* - * Barre d'actions - */ + * Barre d'actions + */ print '
'; print ''.$langs->trans('Modify').''; diff --git a/htdocs/hrm/establishment/info.php b/htdocs/hrm/establishment/info.php index 3185f897958..f72b381a2d8 100644 --- a/htdocs/hrm/establishment/info.php +++ b/htdocs/hrm/establishment/info.php @@ -37,7 +37,9 @@ $backtopage = GETPOST('backtopage', 'alpha'); if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + if (!count($actioncode)) { + $actioncode = '0'; + } } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } @@ -47,12 +49,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 (!$sortfield) $sortfield = 'a.datep,a.id'; -if (!$sortorder) $sortorder = 'DESC,DESC'; +if (!$sortfield) { + $sortfield = 'a.datep,a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC,DESC'; +} // Initialize technical objects $object = new Establishment($db); @@ -64,7 +72,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) $upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id; +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id; +} // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); @@ -80,20 +90,19 @@ $permissiontoadd = $user->rights->hrm->write; // Used by the include of actions_ $parameters = array('id'=>$id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; } // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $actioncode = ''; $search_agenda_label = ''; } @@ -107,14 +116,15 @@ if (empty($reshook)) $form = new Form($db); -if ($object->id > 0) -{ +if ($object->id > 0) { $title = $langs->trans("Agenda"); //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; $help_url = ''; llxHeader('', $title, $help_url); - if (!empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } $head = establishment_prepare_head($object); diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index f0bbb442acc..94dd7f98cd1 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -33,8 +33,12 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; -if ($conf->deplacement->enabled) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; -if ($conf->expensereport->enabled) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +if ($conf->deplacement->enabled) { + require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +} +if ($conf->expensereport->enabled) { + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +} require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; @@ -47,9 +51,13 @@ $langs->loadLangs(array('users', 'holidays', 'trips', 'boxes')); $socid = GETPOST("socid", "int"); // Protection if external user -if ($user->socid > 0) accessforbidden(); +if ($user->socid > 0) { + accessforbidden(); +} -if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete = 1; +if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) { + $setupcompanynotcomplete = 1; +} $holiday = new Holiday($db); $holidaystatic = new Holiday($db); @@ -63,8 +71,7 @@ $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; */ // Update sold -if (!empty($conf->holiday->enabled) && !empty($setupcompanynotcomplete)) -{ +if (!empty($conf->holiday->enabled) && !empty($setupcompanynotcomplete)) { $result = $holiday->updateBalance(); } @@ -81,8 +88,7 @@ llxHeader('', $langs->trans('HRMArea')); print load_fiche_titre($langs->trans("HRMArea"), '', 'hrm'); -if (!empty($setupcompanynotcomplete)) -{ +if (!empty($setupcompanynotcomplete)) { $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete")); print '
'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'
'; @@ -94,36 +100,34 @@ if (!empty($setupcompanynotcomplete)) print '
'; -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo -{ - if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) - { +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo + if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { $langs->load("holiday"); $listofsearchfields['search_holiday'] = array('text'=>'TitreRequestCP'); } - if (!empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) - { + if (!empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) { $langs->load("trips"); $listofsearchfields['search_deplacement'] = array('text'=>'ExpenseReport'); } - if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) - { + if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) { $langs->load("trips"); $listofsearchfields['search_expensereport'] = array('text'=>'ExpenseReport'); } - if (count($listofsearchfields)) - { + if (count($listofsearchfields)) { print '
'; print ''; print '
'; print ''; $i = 0; - foreach ($listofsearchfields as $key => $value) - { - if ($i == 0) print ''; + foreach ($listofsearchfields as $key => $value) { + if ($i == 0) { + print ''; + } print ''; print ''; - if ($i == 0) print ''; + if ($i == 0) { + print ''; + } print ''; $i++; } @@ -135,10 +139,8 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles } -if (!empty($conf->holiday->enabled)) -{ - if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) - { +if (!empty($conf->holiday->enabled)) { + if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) { $user_id = $user->id; print '
'; @@ -149,8 +151,7 @@ if (!empty($conf->holiday->enabled)) $out = ''; $typeleaves = $holiday->getTypes(1, 1); - foreach ($typeleaves as $key => $val) - { + foreach ($typeleaves as $key => $val) { $nb_type = $holiday->getCPforUser($user->id, $val['rowid']); $nb_holiday += $nb_type; $out .= ' - '.($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']).': '.($nb_type ? price2num($nb_type) : 0).'
'; @@ -161,8 +162,7 @@ if (!empty($conf->holiday->enabled)) print ''; print ''; print '
'.$langs->trans("Search").'
'.$langs->trans("Search").'

'; - } elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) - { + } elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) { print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'
'; } } @@ -173,22 +173,22 @@ print '
'; // Latest leave requests -if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) -{ +if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut as user_status,"; $sql .= " x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.rowid = x.fk_user"; $sql .= " AND x.entity = ".$conf->entity; - if (empty($user->rights->holiday->readall)) $sql .= ' AND x.fk_user IN ('.join(',', $childids).')'; + if (empty($user->rights->holiday->readall)) { + $sql .= ' AND x.fk_user IN ('.join(',', $childids).')'; + } //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid; $sql .= $db->order("x.tms", "DESC"); $sql .= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) - { + if ($result) { $var = false; $num = $db->num_rows($result); @@ -208,10 +208,8 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) print ''.$langs->trans("to").''; print ''.$langs->trans("FullList").''; print ''; - if ($num) - { - while ($i < $num && $i < $max) - { + if ($num) { + while ($i < $num && $i < $max) { $obj = $db->fetch_object($result); $holidaystatic->id = $obj->rowid; @@ -248,28 +246,30 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) print ''; print '
'; print '
'; - } else dol_print_error($db); + } else { + dol_print_error($db); + } } // Latest expense report -if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) -{ +if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) { $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut as user_status, u.photo,"; $sql .= " x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u"; //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE u.rowid = x.fk_user_author"; $sql .= " AND x.entity = ".$conf->entity; - if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql .= ' AND x.fk_user_author IN ('.join(',', $childids).')'; + if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) { + $sql .= ' AND x.fk_user_author IN ('.join(',', $childids).')'; + } //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid; $sql .= $db->order("x.tms", "DESC"); $sql .= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); $i = 0; @@ -281,14 +281,12 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) print ''.$langs->trans("TotalTTC").''; print '
'.$langs->trans("FullList").''; print ''; - if ($num) - { + if ($num) { $total_ttc = $totalam = $total = 0; $expensereportstatic = new ExpenseReport($db); $userstatic = new User($db); - while ($i < $num && $i < $max) - { + while ($i < $num && $i < $max) { $obj = $db->fetch_object($result); $expensereportstatic->id = $obj->rowid; @@ -320,26 +318,32 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) print ''; print '
'; print '
'; - } else dol_print_error($db); + } else { + dol_print_error($db); + } } // Last modified job position -if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) -{ +if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) { $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status"; $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.fk_soc = $socid"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND s.fk_soc = $socid"; + } $sql .= " ORDER BY rc.tms DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -351,10 +355,8 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme print ''; print '
'.$langs->trans("FullList").''; print ''; - if ($num) - { - while ($i < $num) - { + if ($num) { + while ($i < $num) { $objp = $db->fetch_object($resql); $staticrecruitmentcandidature->id = $objp->rowid; $staticrecruitmentcandidature->ref = $objp->ref; diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 19b71cb8cd3..c9bb41389c9 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -87,15 +87,17 @@ class Import $modulesdir = dolGetModulesDirs(); // Load list of modules - foreach ($modulesdir as $dir) - { + foreach ($modulesdir as $dir) { $handle = @opendir(dol_osencode($dir)); - if (!is_resource($handle)) continue; + if (!is_resource($handle)) { + continue; + } // Search module files - while (($file = readdir($handle)) !== false) - { - if (!preg_match("/^(mod.*)\.class\.php/i", $file, $reg)) continue; + while (($file = readdir($handle)) !== false) { + if (!preg_match("/^(mod.*)\.class\.php/i", $file, $reg)) { + continue; + } $modulename = $reg[1]; @@ -103,10 +105,16 @@ class Import $enabled = true; $part = strtolower(preg_replace('/^mod/i', '', $modulename)); // Adds condition for propal module - if ($part === 'propale') $part = 'propal'; - if (empty($conf->$part->enabled)) $enabled = false; + if ($part === 'propale') { + $part = 'propal'; + } + if (empty($conf->$part->enabled)) { + $enabled = false; + } - if (empty($enabled)) continue; + if (empty($enabled)) { + continue; + } // Init load class $file = $dir."/".$modulename.".class.php"; @@ -114,11 +122,11 @@ class Import require_once $file; $module = new $classname($this->db); - if (isset($module->import_code) && is_array($module->import_code)) - { - foreach ($module->import_code as $r => $value) - { - if ($filter && ($filter != $module->import_code[$r])) continue; + if (isset($module->import_code) && is_array($module->import_code)) { + foreach ($module->import_code as $r => $value) { + if ($filter && ($filter != $module->import_code[$r])) { + continue; + } // Test if permissions are ok /*$perm=$module->import_permission[$r][0]; @@ -137,10 +145,8 @@ class Import // Load lang file $langtoload = $module->getLangFilesArray(); - if (is_array($langtoload)) - { - foreach ($langtoload as $key) - { + if (is_array($langtoload)) { + foreach ($langtoload as $key) { $langs->load($key); } } @@ -246,9 +252,15 @@ class Import dol_syslog("Import.class.php::create"); // Check parameters - if (empty($this->model_name)) { $this->error = 'ErrorWrongParameters'; return -1; } - if (empty($this->datatoimport)) { $this->error = 'ErrorWrongParameters'; return -1; } - if (empty($this->hexa)) { $this->error = 'ErrorWrongParameters'; return -1; } + if (empty($this->model_name)) { + $this->error = 'ErrorWrongParameters'; return -1; + } + if (empty($this->datatoimport)) { + $this->error = 'ErrorWrongParameters'; return -1; + } + if (empty($this->hexa)) { + $this->error = 'ErrorWrongParameters'; return -1; + } $this->db->begin(); @@ -259,8 +271,7 @@ class Import dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->db->commit(); return 1; } else { @@ -285,11 +296,9 @@ class Import dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $obj = $this->db->fetch_object($result); - if ($obj) - { + if ($obj) { $this->id = $obj->rowid; $this->hexa = $obj->field; $this->model_name = $obj->label; @@ -325,26 +334,24 @@ class Import 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 (!$notrigger) - { + if (!$error) { + if (!$notrigger) { /* Not used. This is not a business object. To convert it we must herit from CommonObject - // Call trigger - $result=$this->call_trigger('IMPORT_DELETE',$user); - if ($result < 0) $error++; - // End call triggers - */ + // Call trigger + $result=$this->call_trigger('IMPORT_DELETE',$user); + 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); } diff --git a/htdocs/imports/emptyexample.php b/htdocs/imports/emptyexample.php index 7e7cec1707e..a50a2fc9996 100644 --- a/htdocs/imports/emptyexample.php +++ b/htdocs/imports/emptyexample.php @@ -21,7 +21,9 @@ * \brief Show example of import file */ -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +} /** @@ -58,8 +60,7 @@ $format = GETPOST('format'); $langs->load("exports"); // Check exportkey -if (empty($datatoimport)) -{ +if (empty($datatoimport)) { $user->getrights(); llxHeader(); @@ -81,23 +82,30 @@ $fieldstarget = $objimport->array_import_fields[0]; $valuestarget = $objimport->array_import_examplevalues[0]; $attachment = true; -if (isset($_GET["attachment"])) $attachment = $_GET["attachment"]; +if (isset($_GET["attachment"])) { + $attachment = $_GET["attachment"]; +} //$attachment = false; $contenttype = dol_mimetype($format); -if (isset($_GET["contenttype"])) $contenttype = $_GET["contenttype"]; +if (isset($_GET["contenttype"])) { + $contenttype = $_GET["contenttype"]; +} //$contenttype='text/plain'; $outputencoding = 'UTF-8'; -if ($contenttype) header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : '')); -if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); +if ($contenttype) { + header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : '')); +} +if ($attachment) { + header('Content-Disposition: attachment; filename="'.$filename.'"'); +} // List of targets fields $headerlinefields = array(); $contentlinevalues = array(); $i = 0; -foreach ($fieldstarget as $code=>$label) -{ +foreach ($fieldstarget as $code => $label) { $withoutstar = preg_replace('/\*/', '', $fieldstarget[$code]); $headerlinefields[] = $langs->transnoentities($withoutstar).($withoutstar != $fieldstarget[$code] ? '*' : '').' ('.$code.')'; $contentlinevalues[] = $valuestarget[$code]; diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 1f8e6bb0bea..dff1940c042 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -41,61 +41,61 @@ $result = restrictedArea($user, 'import'); // Map icons, array duplicated in export.php, was not synchronized, TODO put it somewhere only once $entitytoicon = array( 'invoice' => 'bill', - 'invoice_line' => 'bill', + 'invoice_line' => 'bill', 'order' => 'order', - 'order_line' => 'order', + 'order_line' => 'order', 'propal' => 'propal', - 'propal_line' => 'propal', + 'propal_line' => 'propal', 'intervention' => 'intervention', - 'inter_line' => 'intervention', + 'inter_line' => 'intervention', 'member' => 'user', - 'member_type' => 'group', - 'subscription' => 'payment', - 'payment' => 'payment', + 'member_type' => 'group', + 'subscription' => 'payment', + 'payment' => 'payment', 'tax' => 'bill', - 'tax_type' => 'generic', - 'other' => 'generic', + 'tax_type' => 'generic', + 'other' => 'generic', 'account' => 'account', 'product' => 'product', - 'virtualproduct'=>'product', + 'virtualproduct'=>'product', 'subproduct' => 'product', 'product_supplier_ref' => 'product', - 'stock' => 'stock', + 'stock' => 'stock', 'warehouse' => 'stock', 'batch' => 'stock', 'stockbatch' => 'stock', 'category' => 'category', 'shipment' => 'sending', - 'shipment_line'=> 'sending', - 'reception'=> 'sending', - 'reception_line'=> 'sending', + 'shipment_line'=> 'sending', + 'reception'=> 'sending', + 'reception_line'=> 'sending', 'expensereport'=> 'trip', - 'expensereport_line'=> 'trip', + 'expensereport_line'=> 'trip', 'holiday' => 'holiday', - 'contract_line' => 'contract', - 'translation' => 'generic', - 'bomm' => 'bom', - 'bomline' => 'bom' + 'contract_line' => 'contract', + 'translation' => 'generic', + 'bomm' => 'bom', + 'bomline' => 'bom' ); // Translation code, array duplicated in export.php, was not synchronized, TODO put it somewhere only once $entitytolang = array( 'user' => 'User', 'company' => 'Company', - 'contact' => 'Contact', + 'contact' => 'Contact', 'invoice' => 'Bill', - 'invoice_line' => 'InvoiceLine', + 'invoice_line' => 'InvoiceLine', 'order' => 'Order', - 'order_line' => 'OrderLine', - 'propal' => 'Proposal', - 'propal_line' => 'ProposalLine', + 'order_line' => 'OrderLine', + 'propal' => 'Proposal', + 'propal_line' => 'ProposalLine', 'intervention' => 'Intervention', - 'inter_line' => 'InterLine', + 'inter_line' => 'InterLine', 'member' => 'Member', - 'member_type' => 'MemberType', - 'subscription' => 'Subscription', + 'member_type' => 'MemberType', + 'subscription' => 'Subscription', 'tax' => 'SocialContribution', - 'tax_type' => 'DictionarySocialContributions', + 'tax_type' => 'DictionarySocialContributions', 'account' => 'BankTransactions', 'payment' => 'Payment', 'product' => 'Product', @@ -103,28 +103,28 @@ $entitytolang = array( 'subproduct' => 'SubProduct', 'product_supplier_ref' => 'SupplierPrices', 'service' => 'Service', - 'stock' => 'Stock', + 'stock' => 'Stock', 'movement' => 'StockMovement', 'batch' => 'Batch', 'stockbatch' => 'StockDetailPerBatch', 'warehouse' => 'Warehouse', 'category' => 'Category', 'other' => 'Other', - 'trip' => 'TripsAndExpenses', - 'shipment' => 'Shipments', - 'shipment_line'=> 'ShipmentLine', - 'project' => 'Projects', - 'projecttask' => 'Tasks', - 'task_time' => 'TaskTimeSpent', + 'trip' => 'TripsAndExpenses', + 'shipment' => 'Shipments', + 'shipment_line'=> 'ShipmentLine', + 'project' => 'Projects', + 'projecttask' => 'Tasks', + 'task_time' => 'TaskTimeSpent', 'action' => 'Event', 'expensereport'=> 'ExpenseReport', 'expensereport_line'=> 'ExpenseReportLine', 'holiday' => 'TitreRequestCP', 'contract' => 'Contract', - 'contract_line'=> 'ContractLine', - 'translation' => 'Translation', - 'bom' => 'BOM', - 'bomline' => 'BOMLine' + 'contract_line'=> 'ContractLine', + 'translation' => 'Translation', + 'bom' => 'BOM', + 'bomline' => 'BOMLine' ); $datatoimport = GETPOST('datatoimport'); @@ -155,13 +155,11 @@ $formfile = new FormFile($db); $serialized_array_match_file_to_database = isset($_SESSION["dol_array_match_file_to_database"]) ? $_SESSION["dol_array_match_file_to_database"] : ''; $array_match_file_to_database = array(); $fieldsarray = explode(',', $serialized_array_match_file_to_database); -foreach ($fieldsarray as $elem) -{ +foreach ($fieldsarray as $elem) { $tabelem = explode('=', $elem, 2); $key = $tabelem[0]; $val = (isset($tabelem[1]) ? $tabelem[1] : ''); - if ($key && $val) - { + if ($key && $val) { $array_match_file_to_database[$key] = $val; } } @@ -196,37 +194,32 @@ if ($action=='downfield' || $action=='upfield') } } */ -if ($action == 'builddoc') -{ +if ($action == 'builddoc') { // Build import file $result = $objimport->build_file($user, GETPOST('model', 'alpha'), $datatoimport, $array_match_file_to_database); - if ($result < 0) - { + if ($result < 0) { setEventMessages($objimport->error, $objimport->errors, 'errors'); } else { setEventMessages($langs->trans("FileSuccessfullyBuilt"), null, 'mesgs'); } } -if ($action == 'deleteprof') -{ - if (GETPOST("id", 'int')) - { +if ($action == 'deleteprof') { + if (GETPOST("id", 'int')) { $objimport->fetch(GETPOST("id", 'int')); $result = $objimport->delete($user); } } // Save import config to database -if ($action == 'add_import_model') -{ - if ($import_name) - { +if ($action == 'add_import_model') { + if ($import_name) { // Set save string $hexa = ''; - foreach ($array_match_file_to_database as $key=>$val) - { - if ($hexa) $hexa .= ','; + foreach ($array_match_file_to_database as $key => $val) { + if ($hexa) { + $hexa .= ','; + } $hexa .= $key.'='.$val; } @@ -235,13 +228,11 @@ if ($action == 'add_import_model') $objimport->hexa = $hexa; $result = $objimport->create($user); - if ($result >= 0) - { + if ($result >= 0) { setEventMessages($langs->trans("ImportModelSaved", $objimport->model_name), null, 'mesgs'); } else { $langs->load("errors"); - if ($objimport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($objimport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->trans("ErrorImportDuplicateProfil"), null, 'errors'); } else { setEventMessages($objimport->error, null, 'errors'); @@ -252,16 +243,13 @@ if ($action == 'add_import_model') } } -if ($step == 3 && $datatoimport) -{ - if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) - { +if ($step == 3 && $datatoimport) { + if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) { dol_mkdir($conf->import->dir_temp); $nowyearmonth = dol_print_date(dol_now(), '%Y%m%d%H%M%S'); $fullpath = $conf->import->dir_temp."/".$nowyearmonth.'-'.$_FILES['userfile']['name']; - if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $fullpath, 1) > 0) - { + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $fullpath, 1) > 0) { dol_syslog("File ".$fullpath." was added for import"); } else { $langs->load("errors"); @@ -270,25 +258,30 @@ if ($step == 3 && $datatoimport) } // Delete file - if ($action == 'confirm_deletefile' && $confirm == 'yes') - { + if ($action == 'confirm_deletefile' && $confirm == 'yes') { $langs->load("other"); $param = '&datatoimport='.urlencode($datatoimport).'&format='.urlencode($format); - if ($excludefirstline) $param .= '&excludefirstline='.urlencode($excludefirstline); - if ($endatlinenb) $param .= '&endatlinenb='.urlencode($endatlinenb); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } $file = $conf->import->dir_temp.'/'.GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $ret = dol_delete_file($file); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } Header('Location: '.$_SERVER["PHP_SELF"].'?step='.$step.$param); exit; } } -if ($step == 4 && $action == 'select_model') -{ +if ($step == 4 && $action == 'select_model') { // Reinit match arrays $_SESSION["dol_array_match_file_to_database"] = ''; $serialized_array_match_file_to_database = ''; @@ -297,17 +290,14 @@ if ($step == 4 && $action == 'select_model') // Load model from $importmodelid and set $array_match_file_to_database // and $_SESSION["dol_array_match_file_to_database"] $result = $objimport->fetch($importmodelid); - if ($result > 0) - { + if ($result > 0) { $serialized_array_match_file_to_database = $objimport->hexa; $fieldsarray = explode(',', $serialized_array_match_file_to_database); - foreach ($fieldsarray as $elem) - { + foreach ($fieldsarray as $elem) { $tabelem = explode('=', $elem); $key = $tabelem[0]; $val = $tabelem[1]; - if ($key && $val) - { + if ($key && $val) { $array_match_file_to_database[$key] = $val; } } @@ -315,8 +305,7 @@ if ($step == 4 && $action == 'select_model') } } -if ($action == 'saveorder') -{ +if ($action == 'saveorder') { // Enregistrement de la position des champs dol_syslog("boxorder=".$_GET['boxorder']." datatoimport=".$_GET["datatoimport"], LOG_DEBUG); $part = explode(':', $_GET['boxorder']); @@ -332,15 +321,12 @@ if ($action == 'saveorder') $array_match_file_to_database = array(); $fieldsarray = explode(',', $list); $pos = 0; - foreach ($fieldsarray as $fieldnb) // For each elem in list. fieldnb start from 1 to ... - { + foreach ($fieldsarray as $fieldnb) { // For each elem in list. fieldnb start from 1 to ... // Get name of database fields at position $pos and put it into $namefield $posbis = 0; $namefield = ''; - foreach ($fieldstarget as $key => $val) // key: val: - { + foreach ($fieldstarget as $key => $val) { // key: val: //dol_syslog('AjaxImport key='.$key.' val='.$val); - if ($posbis < $pos) - { + if ($posbis < $pos) { $posbis++; continue; } @@ -351,10 +337,11 @@ if ($action == 'saveorder') break; } - if ($fieldnb && $namefield) - { + if ($fieldnb && $namefield) { $array_match_file_to_database[$fieldnb] = $namefield; - if ($serialized_array_match_file_to_database) $serialized_array_match_file_to_database .= ','; + if ($serialized_array_match_file_to_database) { + $serialized_array_match_file_to_database .= ','; + } $serialized_array_match_file_to_database .= ($fieldnb.'='.$namefield); } @@ -375,18 +362,25 @@ if ($action == 'saveorder') // STEP 1: Page to select dataset to import -if ($step == 1 || !$datatoimport) -{ +if ($step == 1 || !$datatoimport) { // Clean saved file-database matching $serialized_array_match_file_to_database = ''; $array_match_file_to_database = array(); $_SESSION["dol_array_match_file_to_database"] = ''; $param = ''; - if ($excludefirstline) $param .= '&excludefirstline='.urlencode($excludefirstline); - if ($endatlinenb) $param .= '&endatlinenb='.urlencode($endatlinenb); - if ($separator) $param .= '&separator='.urlencode($separator); - if ($enclosure) $param .= '&enclosure='.urlencode($enclosure); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } + if ($separator) { + $param .= '&separator='.urlencode($separator); + } + if ($enclosure) { + $param .= '&enclosure='.urlencode($enclosure); + } llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones'); @@ -405,16 +399,16 @@ if ($step == 1 || !$datatoimport) print ' '; print ''; - if (count($objimport->array_import_module)) - { + if (count($objimport->array_import_module)) { $sortedarrayofmodules = dol_sort_array($objimport->array_import_module, 'position_of_profile', 'asc', 0, 0, 1); - foreach ($sortedarrayofmodules as $key => $value) - { + foreach ($sortedarrayofmodules as $key => $value) { //var_dump($key.' '.$value['position_of_profile'].' '.$value['import_code'].' '.$objimport->array_import_module[$key]['module']->getName().' '.$objimport->array_import_code[$key]); print ''; $titleofmodule = $objimport->array_import_module[$key]['module']->getName(); // Special cas for import common to module/services - if (in_array($objimport->array_import_code[$key], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); + if (in_array($objimport->array_import_code[$key], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) { + $titleofmodule = $langs->trans("ProductOrService"); + } print $titleofmodule; print ''; $entity = preg_replace('/:.*$/', '', $objimport->array_import_icon[$key]); @@ -422,8 +416,7 @@ if ($step == 1 || !$datatoimport) print img_object($objimport->array_import_module[$key]['module']->getName(), $entityicon).' '; print $objimport->array_import_label[$key]; print ''; - if ($objimport->array_import_perms[$key]) - { + if ($objimport->array_import_perms[$key]) { print ''.img_picto($langs->trans("NewImport"), 'next', 'class="fa-15x"').''; } else { print $langs->trans("NotEnoughPermissions"); @@ -441,13 +434,20 @@ if ($step == 1 || !$datatoimport) // STEP 2: Page to select input format file -if ($step == 2 && $datatoimport) -{ +if ($step == 2 && $datatoimport) { $param = '&datatoimport='.urlencode($datatoimport); - if ($excludefirstline) $param .= '&excludefirstline='.urlencode($excludefirstline); - if ($endatlinenb) $param .= '&endatlinenb='.urlencode($endatlinenb); - if ($separator) $param .= '&separator='.urlencode($separator); - if ($enclosure) $param .= '&enclosure='.urlencode($enclosure); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } + if ($separator) { + $param .= '&separator='.urlencode($separator); + } + if ($enclosure) { + $param .= '&enclosure='.urlencode($enclosure); + } llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones'); @@ -465,7 +465,9 @@ if ($step == 2 && $datatoimport) print ''; $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services - if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); + if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) { + $titleofmodule = $langs->trans("ProductOrService"); + } print $titleofmodule; print ''; @@ -503,8 +505,7 @@ if ($step == 2 && $datatoimport) print $langs->trans("FileMustHaveOneOfFollowingFormat"); print ''; $list = $objmodelimport->liste_modeles($db); - foreach ($list as $key) - { + foreach ($list as $key) { print ''; print ''.img_picto_common($key, $objmodelimport->getPictoForKey($key)).''; $text = $objmodelimport->getDriverDescForKey($key); @@ -525,13 +526,20 @@ if ($step == 2 && $datatoimport) // STEP 3: Page to select file -if ($step == 3 && $datatoimport) -{ +if ($step == 3 && $datatoimport) { $param = '&datatoimport='.urlencode($datatoimport).'&format='.urlencode($format); - if ($excludefirstline) $param .= '&excludefirstline='.urlencode($excludefirstline); - if ($endatlinenb) $param .= '&endatlinenb='.urlencode($endatlinenb); - if ($separator) $param .= '&separator='.urlencode($separator); - if ($enclosure) $param .= '&enclosure='.urlencode($enclosure); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } + if ($separator) { + $param .= '&separator='.urlencode($separator); + } + if ($enclosure) { + $param .= '&enclosure='.urlencode($enclosure); + } $list = $objmodelimport->liste_modeles($db); @@ -544,8 +552,7 @@ if ($step == 3 && $datatoimport) /* * Confirm delete file */ - if ($action == 'delete') - { + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?urlfile='.urlencode(GETPOST('urlfile')).'&step=3'.$param, $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); } @@ -559,7 +566,9 @@ if ($step == 3 && $datatoimport) print ''; $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services - if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); + if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) { + $titleofmodule = $langs->trans("ProductOrService"); + } print $titleofmodule; print ''; @@ -635,33 +644,45 @@ if ($step == 3 && $datatoimport) $out = (empty($conf->global->MAIN_UPLOAD_DOC) ? ' disabled' : ''); print ''; $out = ''; - if (!empty($conf->global->MAIN_UPLOAD_DOC)) - { + if (!empty($conf->global->MAIN_UPLOAD_DOC)) { $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb $maxphp = @ini_get('upload_max_filesize'); // In unknown - if (preg_match('/k$/i', $maxphp)) $maxphp = $maxphp * 1; - if (preg_match('/m$/i', $maxphp)) $maxphp = $maxphp * 1024; - if (preg_match('/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024; - if (preg_match('/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024; + if (preg_match('/k$/i', $maxphp)) { + $maxphp = $maxphp * 1; + } + if (preg_match('/m$/i', $maxphp)) { + $maxphp = $maxphp * 1024; + } + if (preg_match('/g$/i', $maxphp)) { + $maxphp = $maxphp * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp)) { + $maxphp = $maxphp * 1024 * 1024 * 1024; + } $maxphp2 = @ini_get('post_max_size'); // In unknown - if (preg_match('/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1; - if (preg_match('/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024; - if (preg_match('/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024; - if (preg_match('/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; + if (preg_match('/k$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1; + } + if (preg_match('/m$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024; + } + if (preg_match('/g$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; + } // Now $max and $maxphp and $maxphp2 are in Kb $maxmin = $max; $maxphptoshow = $maxphptoshowparam = ''; - if ($maxphp > 0) - { + if ($maxphp > 0) { $maxmin = min($max, $maxphp); $maxphptoshow = $maxphp; $maxphptoshowparam = 'upload_max_filesize'; } - if ($maxphp2 > 0) - { + if ($maxphp2 > 0) { $maxmin = min($max, $maxphp2); - if ($maxphp2 < $maxphp) - { + if ($maxphp2 < $maxphp) { $maxphptoshow = $maxphp2; $maxphptoshowparam = 'post_max_size'; } @@ -679,20 +700,22 @@ if ($step == 3 && $datatoimport) // Search available imports $filearray = dol_dir_list($conf->import->dir_temp, 'files', 0, '', '', 'name', SORT_DESC); - if (count($filearray) > 0) - { + if (count($filearray) > 0) { $dir = $conf->import->dir_temp; // Search available files to import $i = 0; - foreach ($filearray as $key => $val) - { + foreach ($filearray as $key => $val) { $file = $val['name']; // readdir return value in ISO and we want UTF8 in memory - if (!utf8_check($file)) $file = utf8_encode($file); + if (!utf8_check($file)) { + $file = utf8_encode($file); + } - if (preg_match('/^\./', $file)) continue; + if (preg_match('/^\./', $file)) { + continue; + } $modulepart = 'import'; $urlsource = $_SERVER["PHP_SELF"].'?step='.$step.$param.'&filetoimport='.urlencode($filetoimport); @@ -728,8 +751,7 @@ if ($step == 3 && $datatoimport) // STEP 4: Page to make matching between source file and database fields -if ($step == 4 && $datatoimport) -{ +if ($step == 4 && $datatoimport) { $model = $format; $list = $objmodelimport->liste_modeles($db); @@ -739,14 +761,12 @@ if ($step == 4 && $datatoimport) $classname = "Import".ucfirst($model); require_once $dir.$file; $obj = new $classname($db, $datatoimport); - if ($model == 'csv') - { + if ($model == 'csv') { $obj->separator = $separator; $obj->enclosure = $enclosure; } if ($model == 'xlsx') { - if (!preg_match('/\.xlsx$/i', $filetoimport)) - { + if (!preg_match('/\.xlsx$/i', $filetoimport)) { $langs->load("errors"); $param = '&datatoimport='.$datatoimport.'&format='.$format; setEventMessages($langs->trans("ErrorFileMustHaveFormat", $model), null, 'errors'); @@ -762,14 +782,12 @@ if ($step == 4 && $datatoimport) // Load source fields in input file $fieldssource = array(); $result = $obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport, $langs); - if ($result >= 0) - { + if ($result >= 0) { // Read first line $arrayrecord = $obj->import_read_record(); // Put into array fieldssource starting with 1. $i = 1; - foreach ($arrayrecord as $key => $val) - { + foreach ($arrayrecord as $key => $val) { $fieldssource[$i]['example1'] = dol_trunc($val['val'], 24); $i++; } @@ -784,29 +802,26 @@ if ($step == 4 && $datatoimport) //var_dump($array_match_file_to_database); // Is it a first time in page (if yes, we must initialize array_match_file_to_database) - if (count($array_match_file_to_database) == 0) - { + if (count($array_match_file_to_database) == 0) { // This is first input in screen, we need to define // $array_match_file_to_database // $serialized_array_match_file_to_database // $_SESSION["dol_array_match_file_to_database"] $pos = 1; $num = count($fieldssource); - while ($pos <= $num) - { - if ($num >= 1 && $pos <= $num) - { + while ($pos <= $num) { + if ($num >= 1 && $pos <= $num) { $posbis = 1; - foreach ($fieldstarget as $key => $val) - { - if ($posbis < $pos) - { + foreach ($fieldstarget as $key => $val) { + if ($posbis < $pos) { $posbis++; continue; } // We found the key of targets that is at position pos $array_match_file_to_database[$pos] = $key; - if ($serialized_array_match_file_to_database) $serialized_array_match_file_to_database .= ','; + if ($serialized_array_match_file_to_database) { + $serialized_array_match_file_to_database .= ','; + } $serialized_array_match_file_to_database .= ($pos.'='.$key); break; } @@ -825,10 +840,18 @@ if ($step == 4 && $datatoimport) // Now $array_match_file_to_database contains fieldnb(1,2,3...)=>fielddatabase(key in $array_match_file_to_database) $param = '&format='.$format.'&datatoimport='.urlencode($datatoimport).'&filetoimport='.urlencode($filetoimport); - if ($excludefirstline) $param .= '&excludefirstline='.urlencode($excludefirstline); - if ($endatlinenb) $param .= '&endatlinenb='.urlencode($endatlinenb); - if ($separator) $param .= '&separator='.urlencode($separator); - if ($enclosure) $param .= '&enclosure='.urlencode($enclosure); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } + if ($separator) { + $param .= '&separator='.urlencode($separator); + } + if ($enclosure) { + $param .= '&enclosure='.urlencode($enclosure); + } llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones'); @@ -846,7 +869,9 @@ if ($step == 4 && $datatoimport) print ''; $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services - if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); + if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) { + $titleofmodule = $langs->trans("ProductOrService"); + } print $titleofmodule; print ''; @@ -954,8 +979,7 @@ if ($step == 4 && $datatoimport) $fieldsplaced = array(); $valforsourcefieldnb = array(); $listofkeys = array(); - foreach ($array_match_file_to_database as $key => $val) - { + foreach ($array_match_file_to_database as $key => $val) { $listofkeys[$key] = 1; } @@ -965,8 +989,7 @@ if ($step == 4 && $datatoimport) // List of source fields $var = true; $lefti = 1; - foreach ($array_match_file_to_database as $key => $val) - { + foreach ($array_match_file_to_database as $key => $val) { $var = !$var; show_elem($fieldssource, $key, $val, $var); // key is field number in source file //print '> '.$lefti.'-'.$key.'-'.$val; @@ -975,15 +998,16 @@ if ($step == 4 && $datatoimport) $valforsourcefieldnb[$lefti] = $key; $lefti++; - if ($lefti > count($fieldstarget)) break; // Other fields are in the not imported area + if ($lefti > count($fieldstarget)) { + break; // Other fields are in the not imported area + } } //var_dump($valforsourcefieldnb); // Complete source fields from count($fieldssource)+1 to count($fieldstarget) $more = 1; $num = count($fieldssource); - while ($lefti <= $num) - { + while ($lefti <= $num) { $var = !$var; $newkey = getnewkey($fieldssource, $listofkeys); show_elem($fieldssource, $newkey, '', $var); // key start after field number in source file @@ -1005,8 +1029,7 @@ if ($step == 4 && $datatoimport) $mandatoryfieldshavesource = true; print ''; - foreach ($fieldstarget as $code=>$label) - { + foreach ($fieldstarget as $code => $label) { print ''; $i++; @@ -1023,11 +1046,12 @@ if ($step == 4 && $datatoimport) $newlabel = preg_replace('/\*$/', '', $label); $text = $langs->trans($newlabel); $more = ''; - if (preg_match('/\*$/', $label)) - { + if (preg_match('/\*$/', $label)) { $text = ''.$text.''; $more = ((!empty($valforsourcefieldnb[$i]) && $valforsourcefieldnb[$i] <= count($fieldssource)) ? '' : img_warning($langs->trans("FieldNeedSource"))); - if ($mandatoryfieldshavesource) $mandatoryfieldshavesource = (!empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= count($fieldssource))); + if ($mandatoryfieldshavesource) { + $mandatoryfieldshavesource = (!empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= count($fieldssource))); + } //print 'xx'.($i).'-'.$valforsourcefieldnb[$i].'-'.$mandatoryfieldshavesource; } print $text; @@ -1037,43 +1061,54 @@ if ($step == 4 && $datatoimport) $filecolumn = $array_match_database_to_file[$code]; // Source field info $htmltext = ''.$langs->trans("FieldSource").'
'; - if ($filecolumn > count($fieldssource)) $htmltext .= $langs->trans("DataComeFromNoWhere").'
'; - else { - if (empty($objimport->array_import_convertvalue[0][$code])) // If source file does not need convertion - { + if ($filecolumn > count($fieldssource)) { + $htmltext .= $langs->trans("DataComeFromNoWhere").'
'; + } else { + if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion $filecolumntoshow = $filecolumn; $htmltext .= $langs->trans("DataComeFromFileFieldNb", $filecolumntoshow).'
'; } else { - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') $htmltext .= $langs->trans("DataComeFromIdFoundFromRef", $filecolumn, $langs->transnoentitiesnoconv($entitylang)).'
'; - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') $htmltext .= $langs->trans("DataComeFromIdFoundFromCodeId", $filecolumn, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).'
'; + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') { + $htmltext .= $langs->trans("DataComeFromIdFoundFromRef", $filecolumn, $langs->transnoentitiesnoconv($entitylang)).'
'; + } + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') { + $htmltext .= $langs->trans("DataComeFromIdFoundFromCodeId", $filecolumn, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).'
'; + } } } // Source required $htmltext .= $langs->trans("SourceRequired").': '.yn(preg_match('/\*$/', $label)).'
'; $example = $objimport->array_import_examplevalues[0][$code]; // Example - if (empty($objimport->array_import_convertvalue[0][$code])) // If source file does not need convertion - { - if ($example) $htmltext .= $langs->trans("SourceExample").': '.$example.'
'; + if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion + if ($example) { + $htmltext .= $langs->trans("SourceExample").': '.$example.'
'; + } } else { - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') $htmltext .= $langs->trans("SourceExample").': '.$langs->transnoentitiesnoconv("ExampleAnyRefFoundIntoElement", $entitylang).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'
'; - elseif ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') $htmltext .= $langs->trans("SourceExample").': '.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'
'; - elseif ($example) $htmltext .= $langs->trans("SourceExample").': '.$example.'
'; + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') { + $htmltext .= $langs->trans("SourceExample").': '.$langs->transnoentitiesnoconv("ExampleAnyRefFoundIntoElement", $entitylang).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'
'; + } elseif ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') { + $htmltext .= $langs->trans("SourceExample").': '.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'
'; + } elseif ($example) { + $htmltext .= $langs->trans("SourceExample").': '.$example.'
'; + } } // Format control rule - if (!empty($objimport->array_import_regex[0][$code])) - { + if (!empty($objimport->array_import_regex[0][$code])) { $htmltext .= $langs->trans("FormatControlRule").': '.$objimport->array_import_regex[0][$code].'
'; } $htmltext .= '
'; // Target field info $htmltext .= ''.$langs->trans("FieldTarget").'
'; - if (empty($objimport->array_import_convertvalue[0][$code])) // If source file does not need convertion - { + if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion $htmltext .= $langs->trans("DataIsInsertedInto").'
'; } else { - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') $htmltext .= $langs->trans("DataIDSourceIsInsertedInto").'
'; - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') $htmltext .= $langs->trans("DataCodeIDSourceIsInsertedInto").'
'; + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') { + $htmltext .= $langs->trans("DataIDSourceIsInsertedInto").'
'; + } + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') { + $htmltext .= $langs->trans("DataCodeIDSourceIsInsertedInto").'
'; + } } $htmltext .= $langs->trans("FieldTitle").": ".$langs->trans($newlabel)."
"; $htmltext .= $langs->trans("Table")." -> ".$langs->trans("Field").': '.$tablename." -> ".preg_replace('/^.*\./', '', $code)."
"; @@ -1096,10 +1131,8 @@ if ($step == 4 && $datatoimport) print '
'; $i = 0; - while ($i < $nbofnotimportedfields) - { + while ($i < $nbofnotimportedfields) { // Print empty cells show_elem('', '', 'none', $var, 'nostyle'); $i++; @@ -1134,8 +1166,7 @@ if ($step == 4 && $datatoimport) print ''; - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print ' '.$langs->trans('CantUseScheduleWithLoanStartedToPaid').''."\n"; +} print ''; print ''; print ''; -if (count($echeances->lines) > 0) -{ +if (count($echeances->lines) > 0) { print ''; } else { print ''; @@ -229,7 +236,9 @@ print '
'; print ''; print ''; $colspan = 6; -if (count($echeances->lines) > 0) $colspan++; +if (count($echeances->lines) > 0) { + $colspan++; +} print ''; @@ -245,18 +254,18 @@ print ''; -if (count($echeances->lines) > 0) print ''; +if (count($echeances->lines) > 0) { + print ''; +} print ''."\n"; -if ($object->nbterm > 0 && count($echeances->lines) == 0) -{ +if ($object->nbterm > 0 && count($echeances->lines) == 0) { $i = 1; $capital = $object->capital; $insurance = $object->insurance_amount / $object->nbterm; $insurance = price2num($insurance, 'MT'); $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); - while ($i < $object->nbterm + 1) - { + while ($i < $object->nbterm + 1) { $mens = price2num($echeances->calcMonthlyPayments($capital, $object->rate / 100, $object->nbterm - $i + 1), 'MT'); $int = ($capital * ($object->rate / 12)) / 100; $int = price2num($int, 'MT'); @@ -273,8 +282,7 @@ if ($object->nbterm > 0 && count($echeances->lines) == 0) $i++; $capital = $cap_rest; } -} elseif (count($echeances->lines) > 0) -{ +} elseif (count($echeances->lines) > 0) { $i = 1; $capital = $object->capital; $insurance = $object->insurance_amount / $object->nbterm; @@ -300,14 +308,12 @@ if ($object->nbterm > 0 && count($echeances->lines) == 0) print ''; print '
'; print $langs->trans("FinancialCommitment"); print ''.$langs->trans("CapitalRemain"); print '
('.price($object->capital, 0, '', 1, -1, -1, $conf->currency).')'; print ''; print '
'.$langs->trans('DoPayment').''.$langs->trans('DoPayment').'
'.price($cap_rest, 0, '', 1, -1, -1, $conf->currency).''; - if (!empty($line->fk_bank)) - { + if (!empty($line->fk_bank)) { print $langs->trans('Paid'); - if (!empty($line->fk_payment_loan)) + if (!empty($line->fk_payment_loan)) { print ' ('.img_object($langs->trans("Payment"), "payment").' '.$line->fk_payment_loan.')'; - } - elseif (!$printed) - { + } + } elseif (!$printed) { print ''.$langs->trans('DoPayment').''; $printed = true; } @@ -323,8 +329,11 @@ print ''; print '
'; -if (count($echeances->lines) == 0) $label = $langs->trans("Create"); -else $label = $langs->trans("Save"); +if (count($echeances->lines) == 0) { + $label = $langs->trans("Create"); +} else { + $label = $langs->trans("Save"); +} print '
'; print '';