diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index a32110f782f..7f3072d8051 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -50,10 +50,10 @@ $objectline = new BOMLine($this->db); print "\n"; -$nolinesbefore=(count($this->lines) == 0 || $forcetoshowtitlelines); +$nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines); if ($nolinesbefore) { print ''; - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print ''; } print ''; @@ -74,11 +74,11 @@ if ($nolinesbefore) { print ' '; print ''; } -print ''; -$coldisplay=0; +print ''; +$coldisplay = 0; // Adds a line numbering column -if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { +if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $coldisplay++; echo ''; } @@ -87,15 +87,15 @@ $coldisplay++; print ''; // Predefined product/service -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) +if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { if ($forceall >= 0 && $freelines) echo '
'; echo ''; - $filtertype=''; - if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1'; + $filtertype = ''; + if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype = '1'; $statustoshow = -1; - if (! empty($conf->global->ENTREPOT_EXTRA_STATUS)) + if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) { // hide products in closed warehouse, but show products for internal transfer $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); @@ -109,10 +109,10 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) } $coldisplay++; -print ''; +print ''; print ''; -if($conf->global->PRODUCT_USE_UNITS) +if ($conf->global->PRODUCT_USE_UNITS) { $coldisplay++; print ''; @@ -121,11 +121,11 @@ if($conf->global->PRODUCT_USE_UNITS) } $coldisplay++; -print ''; +print ''; print ''; $coldisplay++; -print ''; +print ''; print ''; //$coldisplay++; diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 46ce0c78345..0d3c5de514d 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -63,7 +63,7 @@ class AgendaEvents extends DolibarrApi */ public function get($id) { - if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { + if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) { throw new RestException(401, "Insufficient rights to read an event"); } if ($id == 0) { @@ -75,15 +75,15 @@ class AgendaEvents extends DolibarrApi $this->actioncomm->fetchObjectLinked(); } } - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Agenda Events not found'); } - if (! DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->userownerid != DolibarrApiAccess::$user->id) { + if (!DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->userownerid != DolibarrApiAccess::$user->id) { throw new RestException(401, "Insufficient rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - if ( ! DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { + if (!DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } return $this->_cleanObjectDatas($this->actioncomm); @@ -108,30 +108,30 @@ class AgendaEvents extends DolibarrApi $obj_ret = array(); - if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { + if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) { throw new RestException(401, "Insufficient rights to read events"); } // case of external user $socid = 0; - if (! empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid; + if (!empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid; // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; - if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists $sql = "SELECT t.id as rowid"; - if (! empty($conf->societe->enabled)) + if (!empty($conf->societe->enabled)) if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $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."actioncomm as t"; - if (! empty($conf->societe->enabled)) - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ' WHERE t.entity IN ('.getEntity('agenda').')'; - if (! empty($conf->societe->enabled)) - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; - if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; + if (!empty($conf->societe->enabled)) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql .= ' WHERE t.entity IN ('.getEntity('agenda').')'; + if (!empty($conf->societe->enabled)) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($user_ids) $sql .= " AND t.fk_user_action IN (".$user_ids.")"; + if ($socid > 0) $sql .= " AND t.fk_soc = ".$socid; // Insert sale filter if ($search_sale > 0) { @@ -140,30 +140,30 @@ class AgendaEvents extends DolibarrApi // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); if ($result) { - $i=0; + $i = 0; $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); while ($i < $min) @@ -179,7 +179,7 @@ class AgendaEvents extends DolibarrApi else { throw new RestException(503, 'Error when retrieve Agenda Event list : '.$db->lasterror()); } - if ( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No Agenda Event found'); } return $obj_ret; @@ -193,17 +193,17 @@ class AgendaEvents extends DolibarrApi */ public function post($request_data = null) { - if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { + if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insufficient rights to create your Agenda Event"); } - if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + if (!DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->actioncomm->$field = $value; } /*if (isset($request_data["lines"])) { @@ -273,7 +273,7 @@ class AgendaEvents extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->agenda->myactions->delete) { + if (!DolibarrApiAccess::$user->rights->agenda->myactions->delete) { throw new RestException(401, "Insufficient rights to delete your Agenda Event"); } @@ -284,19 +284,19 @@ class AgendaEvents extends DolibarrApi $this->actioncomm->oldcopy = clone $this->actioncomm; } - if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { + if (!DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { throw new RestException(401, "Insufficient rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Agenda Event not found'); } - if( ! DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id)) { + if (!DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! $this->actioncomm->delete(DolibarrApiAccess::$user)) { + if (!$this->actioncomm->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete Agenda Event : '.$this->actioncomm->error); } @@ -338,7 +338,7 @@ class AgendaEvents extends DolibarrApi // phpcs:enable $object = parent::_cleanObjectDatas($object); - unset($object->note); // alreaydy into note_private + unset($object->note); // alreaydy into note_private unset($object->usermod); unset($object->libelle); unset($object->context); diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 476f94c8937..2a56122d6f3 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -39,7 +39,7 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'banque', '', '', ''); // Get parameters @@ -74,50 +74,50 @@ include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $form = new Form($db); -$title = $langs->trans("VariousPayment") . ' - ' . $langs->trans("Documents"); +$title = $langs->trans("VariousPayment").' - '.$langs->trans("Documents"); $help_url = ''; llxHeader("", $title, $help_url); if ($object->id) { - $head=various_payment_prepare_head($object); + $head = various_payment_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("VariousPayment"), -1, $object->picto); - $morehtmlref='
'; + $morehtmlref = '
'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' : '; + $morehtmlref .= $langs->trans('Project').' : '; if ($user->rights->banque->modifier && 0) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=$proj->getNomUrl(1); + $morehtmlref .= $proj->getNomUrl(1); } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
'; - $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref .= '
'; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index c3714b28360..9975357fc23 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -52,44 +52,44 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'invoicetemplatelist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search // Security check -$id=(GETPOST('facid', 'int')?GETPOST('facid', 'int'):GETPOST('id', 'int')); -$lineid=GETPOST('lineid', 'int'); -$ref=GETPOST('ref', 'alpha'); -if ($user->socid) $socid=$user->socid; +$id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int')); +$lineid = GETPOST('lineid', 'int'); +$ref = GETPOST('ref', 'alpha'); +if ($user->socid) $socid = $user->socid; $objecttype = 'facture_rec'; if ($action == "create" || $action == "add") $objecttype = ''; $result = restrictedArea($user, 'facture', $id, $objecttype); $projectid = GETPOST('projectid', 'int'); -$search_ref=GETPOST('search_ref'); -$search_societe=GETPOST('search_societe'); -$search_montant_ht=GETPOST('search_montant_ht'); -$search_montant_vat=GETPOST('search_montant_vat'); -$search_montant_ttc=GETPOST('search_montant_ttc'); -$search_payment_mode=GETPOST('search_payment_mode'); -$search_payment_term=GETPOST('search_payment_term'); -$search_day=GETPOST('search_day', 'int'); -$search_year=GETPOST('search_year', 'int'); -$search_month=GETPOST('search_month', 'int'); -$search_day_date_when=GETPOST('search_day_date_when', 'int'); -$search_year_date_when=GETPOST('search_year_date_when', 'int'); -$search_month_date_when=GETPOST('search_month_date_when', 'int'); -$search_recurring=GETPOST('search_recurring', 'int'); -$search_frequency=GETPOST('search_frequency', 'alpha'); -$search_unit_frequency=GETPOST('search_unit_frequency', 'alpha'); -$search_status=GETPOST('search_status', 'int'); +$search_ref = GETPOST('search_ref'); +$search_societe = GETPOST('search_societe'); +$search_montant_ht = GETPOST('search_montant_ht'); +$search_montant_vat = GETPOST('search_montant_vat'); +$search_montant_ttc = GETPOST('search_montant_ttc'); +$search_payment_mode = GETPOST('search_payment_mode'); +$search_payment_term = GETPOST('search_payment_term'); +$search_day = GETPOST('search_day', 'int'); +$search_year = GETPOST('search_year', 'int'); +$search_month = GETPOST('search_month', 'int'); +$search_day_date_when = GETPOST('search_day_date_when', 'int'); +$search_year_date_when = GETPOST('search_year_date_when', 'int'); +$search_month_date_when = GETPOST('search_month_date_when', 'int'); +$search_recurring = GETPOST('search_recurring', 'int'); +$search_frequency = GETPOST('search_frequency', 'alpha'); +$search_unit_frequency = GETPOST('search_unit_frequency', 'alpha'); +$search_status = GETPOST('search_status', 'int'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (! $sortorder) $sortorder='DESC'; -if (! $sortfield) $sortfield='f.titre'; +if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) $sortfield = 'f.titre'; $pageprev = $page - 1; $pagenext = $page + 1; @@ -206,40 +206,40 @@ llxHeader('', $langs->trans("RepeatableInvoices"), 'ch-facture.html#s-fac-factur $form = new Form($db); $formother = new FormOther($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $companystatic = new Societe($db); $invoicerectmp = new FactureRec($db); $now = dol_now(); -$tmparray=dol_getdate($now); -$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day +$tmparray = dol_getdate($now); +$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day /* * List mode */ $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,"; -$sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,"; -$sql.= " f.datec, f.tms,"; -$sql.= " f.fk_cond_reglement, f.fk_mode_reglement"; +$sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,"; +$sql .= " f.datec, f.tms,"; +$sql .= " f.fk_cond_reglement, f.fk_mode_reglement"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=preg_replace('/^,/', '', $hookmanager->resPrint); -$sql =preg_replace('/,\s*$/', '', $sql); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as f"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_rec_extrafields as ef ON ef.fk_object = f.rowid"; -if (! $user->rights->societe->client->voir && ! $socid) { +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as f"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_rec_extrafields as ef ON ef.fk_object = f.rowid"; +if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } -$sql.= " WHERE f.fk_soc = s.rowid"; -$sql.= ' AND f.entity IN ('.getEntity('invoice').')'; -if (! $user->rights->societe->client->voir && ! $socid) { +$sql .= " WHERE f.fk_soc = s.rowid"; +$sql .= ' AND f.entity IN ('.getEntity('invoice').')'; +if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($search_ref) $sql .= natural_search('f.titre', $search_ref); @@ -333,126 +333,126 @@ if ($resql) $i = 0; print '
'; - print ''."\n"; + print '
'."\n"; // Filters lines print ''; // Ref - if (! empty($arrayfields['f.titre']['checked'])) + if (!empty($arrayfields['f.titre']['checked'])) { print ''; } // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } - if (! empty($arrayfields['f.total']['checked'])) + if (!empty($arrayfields['f.total']['checked'])) { // Amount net print ''; } - if (! empty($arrayfields['f.tva']['checked'])) + if (!empty($arrayfields['f.tva']['checked'])) { // Amount Vat print ''; } - if (! empty($arrayfields['f.total_ttc']['checked'])) + if (!empty($arrayfields['f.total_ttc']['checked'])) { // Amount print ''; } - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { // Payment term print '"; } - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { // Payment mode print ''; } - if (! empty($arrayfields['recurring']['checked'])) + if (!empty($arrayfields['recurring']['checked'])) { // Recurring or not print ''; } - if (! empty($arrayfields['f.frequency']['checked'])) + if (!empty($arrayfields['f.frequency']['checked'])) { // Recurring or not print ''; } - if (! empty($arrayfields['f.unit_frequency']['checked'])) + if (!empty($arrayfields['f.unit_frequency']['checked'])) { // Frequency unit print ''; } - if (! empty($arrayfields['f.nb_gen_done']['checked'])) + if (!empty($arrayfields['f.nb_gen_done']['checked'])) { // Nb generation print ''; } // Date invoice - if (! empty($arrayfields['f.date_last_gen']['checked'])) + if (!empty($arrayfields['f.date_last_gen']['checked'])) { print ''; } // Date next generation - if (! empty($arrayfields['f.date_when']['checked'])) + if (!empty($arrayfields['f.date_when']['checked'])) { print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['f.datec']['checked'])) + if (!empty($arrayfields['f.datec']['checked'])) { print ''; } // Date modification - if (! empty($arrayfields['f.tms']['checked'])) + if (!empty($arrayfields['f.tms']['checked'])) { print ''; } // Status - if (! empty($arrayfields['status']['checked'])) + if (!empty($arrayfields['status']['checked'])) { print ''; print "\n"; print ''; - if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'], $_SERVER['PHP_SELF'], "f.total", "", $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'], $_SERVER['PHP_SELF'], "f.tva", "", $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'], $_SERVER['PHP_SELF'], "f.total", "", $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'], $_SERVER['PHP_SELF'], "f.tva", "", $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'nomaxwidthsearch '); print "\n"; if ($num > 0) { - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); if (empty($objp)) break; - $companystatic->id=$objp->socid; - $companystatic->name=$objp->name; + $companystatic->id = $objp->socid; + $companystatic->name = $objp->name; - $invoicerectmp->id=$objp->id?$objp->id:$objp->facid; - $invoicerectmp->frequency=$objp->frequency; - $invoicerectmp->suspended=$objp->suspended; - $invoicerectmp->unit_frequency=$objp->unit_frequency; - $invoicerectmp->nb_gen_max=$objp->nb_gen_max; - $invoicerectmp->nb_gen_done=$objp->nb_gen_done; - $invoicerectmp->ref=$objp->title; + $invoicerectmp->id = $objp->id ? $objp->id : $objp->facid; + $invoicerectmp->frequency = $objp->frequency; + $invoicerectmp->suspended = $objp->suspended; + $invoicerectmp->unit_frequency = $objp->unit_frequency; + $invoicerectmp->nb_gen_max = $objp->nb_gen_max; + $invoicerectmp->nb_gen_done = $objp->nb_gen_done; + $invoicerectmp->ref = $objp->title; print ''; - if (! empty($arrayfields['f.titre']['checked'])) + if (!empty($arrayfields['f.titre']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['f.total']['checked'])) + if (!empty($arrayfields['f.total']['checked'])) { print ''."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total'; $totalarray['val']['f.total'] += $objp->total; } - if (! empty($arrayfields['f.tva']['checked'])) + if (!empty($arrayfields['f.tva']['checked'])) { print ''."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.tva'; $totalarray['val']['f.tva'] += $objp->total_vat; } - if (! empty($arrayfields['f.total_ttc']['checked'])) + if (!empty($arrayfields['f.total_ttc']['checked'])) { print ''."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; $totalarray['val']['f.total_ttc'] += $objp->total_ttc; } // Payment term - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { print ''."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Payment mode - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { print ''."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['recurring']['checked'])) + if (!empty($arrayfields['recurring']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['f.frequency']['checked'])) + if (!empty($arrayfields['f.frequency']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['f.unit_frequency']['checked'])) + if (!empty($arrayfields['f.unit_frequency']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['f.nb_gen_done']['checked'])) + if (!empty($arrayfields['f.nb_gen_done']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date last generation - if (! empty($arrayfields['f.date_last_gen']['checked'])) + if (!empty($arrayfields['f.date_last_gen']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date next generation - if (! empty($arrayfields['f.date_when']['checked'])) + if (!empty($arrayfields['f.date_when']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['f.datec']['checked'])) + if (!empty($arrayfields['f.datec']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['f.tms']['checked'])) + if (!empty($arrayfields['f.tms']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } $obj = $objp; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Status - if (! empty($arrayfields['status']['checked'])) { + if (!empty($arrayfields['status']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print '\n"; + $out .= "\n"; } // Message - if (! empty($this->withbody)) + if (!empty($this->withbody)) { - $defaultmessage=GETPOST('message', 'none'); - if (! GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') + $defaultmessage = GETPOST('message', 'none'); + if (!GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') { if ($arraydefaultmessage && $arraydefaultmessage->content) { $defaultmessage = $arraydefaultmessage->content; - } elseif (! is_numeric($this->withbody)) { + } elseif (!is_numeric($this->withbody)) { $defaultmessage = $this->withbody; } } // Complete substitution array with the url to make online payment - $paymenturl=''; $validpaymentmethod=array(); + $paymenturl = ''; $validpaymentmethod = array(); if (empty($this->substit['__REF__'])) { - $paymenturl=''; + $paymenturl = ''; } else { // Set the online payment url link into __ONLINE_PAYMENT_URL__ key require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - $langs->loadLangs(array('paypal','other')); - $typeforonlinepayment='free'; - if ($this->param["models"]=='order' || $this->param["models"]=='order_send') $typeforonlinepayment='order'; // TODO use detection on something else than template - if ($this->param["models"]=='invoice' || $this->param["models"]=='facture_send') $typeforonlinepayment='invoice'; // TODO use detection on something else than template - if ($this->param["models"]=='member') $typeforonlinepayment='member'; // TODO use detection on something else than template - $url=getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']); - $paymenturl=$url; + $langs->loadLangs(array('paypal', 'other')); + $typeforonlinepayment = 'free'; + if ($this->param["models"] == 'order' || $this->param["models"] == 'order_send') $typeforonlinepayment = 'order'; // TODO use detection on something else than template + if ($this->param["models"] == 'invoice' || $this->param["models"] == 'facture_send') $typeforonlinepayment = 'invoice'; // TODO use detection on something else than template + if ($this->param["models"] == 'member') $typeforonlinepayment = 'member'; // TODO use detection on something else than template + $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']); + $paymenturl = $url; $validpaymentmethod = getValidOnlinePaymentMethods(''); } @@ -934,13 +934,13 @@ class FormMail extends Form if (count($validpaymentmethod) > 0 && $paymenturl) { $langs->load('other'); - $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']=str_replace('\n', "\n", $langs->transnoentities("PredefinedMailContentLink", $paymenturl)); - $this->substit['__ONLINE_PAYMENT_URL__']=$paymenturl; + $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = str_replace('\n', "\n", $langs->transnoentities("PredefinedMailContentLink", $paymenturl)); + $this->substit['__ONLINE_PAYMENT_URL__'] = $paymenturl; } else { - $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']=''; - $this->substit['__ONLINE_PAYMENT_URL__']=''; + $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = ''; + $this->substit['__ONLINE_PAYMENT_URL__'] = ''; } //Add lines substitution key from each line @@ -953,92 +953,92 @@ class FormMail extends Form $lines .= make_substitutions($defaultlines, $substit_line)."\n"; } } - $this->substit['__LINES__']=$lines; + $this->substit['__LINES__'] = $lines; - $defaultmessage=str_replace('\n', "\n", $defaultmessage); + $defaultmessage = str_replace('\n', "\n", $defaultmessage); // Deal with format differences between message and signature (text / HTML) if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__USER_SIGNATURE__'])) { $this->substit['__USER_SIGNATURE__'] = dol_nl2br($this->substit['__USER_SIGNATURE__']); - } elseif(!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) { + } elseif (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) { $defaultmessage = dol_nl2br($defaultmessage); } - if (isset($_POST["message"]) && ! $_POST['modelselected']) $defaultmessage=$_POST["message"]; + if (isset($_POST["message"]) && !$_POST['modelselected']) $defaultmessage = $_POST["message"]; else { - $defaultmessage=make_substitutions($defaultmessage, $this->substit); + $defaultmessage = make_substitutions($defaultmessage, $this->substit); // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty) - $defaultmessage=preg_replace("/^(
)+/", "", $defaultmessage); - $defaultmessage=preg_replace("/^\n+/", "", $defaultmessage); + $defaultmessage = preg_replace("/^(
)+/", "", $defaultmessage); + $defaultmessage = preg_replace("/^\n+/", "", $defaultmessage); } - $out.= ''; - $out.= ''; - $out.= ''; + $out .= ''; + $out .= '\n"; + $out .= "\n"; } - $out.= '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100'); print "'; $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100'); print ''; print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1); print ''; print ''; print ''; print ''; print ''; print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_year?$search_year:-1, 'search_year', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + $formother->select_year($search_year ? $search_year : -1, 'search_year', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_year_date_when?$search_year_date_when:-1, 'search_year_date_when', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + $formother->select_year($search_year_date_when ? $search_year_date_when : -1, 'search_year_date_when', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print ''; print ''; print ''; - $liststatus=array( + $liststatus = array( 0=>$langs->trans("Draft"), 1=>$langs->trans("Active"), -1=>$langs->trans("Disabled"), @@ -462,145 +462,145 @@ if ($resql) } // Action column print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1); + $searchpicto = $form->showFilterAndCheckAddButtons(0, 'checkforselect', 1); print $searchpicto; print '
'; print $invoicerectmp->getNomUrl(1); print ""; print "'.$companystatic->getNomUrl(1, 'customer').''.price($objp->total).''.price($objp->total_vat).''.price($objp->total_ttc).''; $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); print ''; $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); print ''.yn($objp->frequency?1:0).''.yn($objp->frequency ? 1 : 0).''.($objp->frequency > 0 ? $objp->frequency : '').''.($objp->frequency > 0 ? $objp->unit_frequency : '').''; - print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : ''.$langs->trans('NA').''); + print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '') : ''.$langs->trans('NA').''); print ''; print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : ''.$langs->trans('NA').''); print ''; print '
'; - print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'':'').dol_print_date($db->jdate($objp->date_when), 'day').($invoicerectmp->isMaxNbGenReached()?'':'') : ''.$langs->trans('NA').''); - if (! $invoicerectmp->isMaxNbGenReached()) + print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached() ? '' : '').dol_print_date($db->jdate($objp->date_when), 'day').($invoicerectmp->isMaxNbGenReached() ? '' : '') : ''.$langs->trans('NA').''); + if (!$invoicerectmp->isMaxNbGenReached()) { - if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); + if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); } else { @@ -608,36 +608,36 @@ if ($resql) } print '
'; print '
'; print dol_print_date($db->jdate($objp->datec), 'dayhour'); print ''; print dol_print_date($db->jdate($objp->tms), 'dayhour'); print ''; print $invoicerectmp->getLibStatut(3, 0); print ''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index ba04782eafe..a945e8cb5a5 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -64,23 +64,23 @@ class Contact extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), - 'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), - 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), + 'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), ); - public $civility_id; // In fact we store civility_code + public $civility_id; // In fact we store civility_code public $civility_code; public $civility; @@ -92,14 +92,14 @@ class Contact extends CommonObject public $zip; public $town; - public $state_id; // Id of department - public $state_code; // Code of department - public $state; // Label of department + public $state_id; // Id of department + public $state_code; // Code of department + public $state; // Label of department - public $poste; // Position + public $poste; // Position - public $socid; // fk_soc - public $statut; // 0=inactif, 1=actif + public $socid; // fk_soc + public $statut; // 0=inactif, 1=actif public $code; @@ -181,9 +181,9 @@ class Contact extends CommonObject * Old copy * @var Contact */ - public $oldcopy; // To contains a clone of this when we need to save old properties of object + public $oldcopy; // To contains a clone of this when we need to save old properties of object - public $roles=array(); + public $roles = array(); /** @@ -208,28 +208,28 @@ class Contact extends CommonObject // phpcs:enable global $user; - $this->nb=array(); + $this->nb = array(); $clause = "WHERE"; $sql = "SELECT count(sp.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $clause = "AND"; } - $sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')'; - $sql.= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; - if ($user->socid > 0) $sql.=" AND sp.fk_soc = ".$user->socid; + $sql .= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')'; + $sql .= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; + if ($user->socid > 0) $sql .= " AND sp.fk_soc = ".$user->socid; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["contacts"]=$obj->nb; + $this->nb["contacts"] = $obj->nb; } $this->db->free($resql); return 1; @@ -386,7 +386,7 @@ class Contact extends CommonObject $this->town = (empty($this->town) ? '' : $this->town); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); if (empty($this->statut)) $this->statut = 0; - if (empty($this->civility_code) && ! is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility + if (empty($this->civility_code) && !is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET "; @@ -406,16 +406,16 @@ class Contact extends CommonObject $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; $sql .= ", photo='".$this->db->escape($this->photo)."'"; $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); - $sql .= ", note_private = ".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); - $sql .= ", note_public = ".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); - $sql .= ", phone = ".(isset($this->phone_pro)?"'".$this->db->escape($this->phone_pro)."'":"null"); - $sql .= ", phone_perso = ".(isset($this->phone_perso)?"'".$this->db->escape($this->phone_perso)."'":"null"); - $sql .= ", phone_mobile = ".(isset($this->phone_mobile)?"'".$this->db->escape($this->phone_mobile)."'":"null"); + $sql .= ", note_private = ".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); + $sql .= ", note_public = ".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null"); + $sql .= ", phone = ".(isset($this->phone_pro) ? "'".$this->db->escape($this->phone_pro)."'" : "null"); + $sql .= ", phone_perso = ".(isset($this->phone_perso) ? "'".$this->db->escape($this->phone_perso)."'" : "null"); + $sql .= ", phone_mobile = ".(isset($this->phone_mobile) ? "'".$this->db->escape($this->phone_mobile)."'" : "null"); $sql .= ", priv = '".$this->db->escape($this->priv)."'"; $sql .= ", statut = ".$this->db->escape($this->statut); - $sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"NULL"); - $sql .= ", default_lang=".($this->default_lang?"'".$this->db->escape($this->default_lang)."'":"NULL"); - $sql .= ", entity = " . $this->db->escape($this->entity); + $sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'" : "NULL"); + $sql .= ", default_lang=".($this->default_lang ? "'".$this->db->escape($this->default_lang)."'" : "NULL"); + $sql .= ", entity = ".$this->db->escape($this->entity); $sql .= " WHERE rowid=".$this->db->escape($id); dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -525,15 +525,15 @@ class Contact extends CommonObject } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('CONTACT_MODIFY', $user); + $result = $this->call_trigger('CONTACT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -757,37 +757,37 @@ class Contact extends CommonObject $langs->load("dict"); - dol_syslog(get_class($this) . "::fetch id=" . $id . " ref_ext=" . $ref_ext . " email=" . $email, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch id=".$id." ref_ext=".$ref_ext." email=".$email, LOG_DEBUG); if (empty($id) && empty($ref_ext) && empty($email)) { - $this->error='BadParameter'; + $this->error = 'BadParameter'; return -1; } $langs->load("companies"); $sql = "SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_code, c.lastname, c.firstname,"; - $sql.= " c.address, c.statut, c.zip, c.town,"; - $sql.= " c.fk_pays as country_id,"; - $sql.= " c.fk_departement as state_id,"; - $sql.= " c.birthday,"; - $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,"; - $sql.= " c.socialnetworks,"; - $sql.= " c.photo,"; - $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; - $sql.= " c.import_key,"; - $sql.= " c.datec as date_creation, c.tms as date_modification,"; - $sql.= " co.label as country, co.code as country_code,"; - $sql.= " d.nom as state, d.code_departement as state_code,"; - $sql.= " u.rowid as user_id, u.login as user_login,"; - $sql.= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON c.fk_pays = co.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; - if ($id) $sql.= " WHERE c.rowid = ". $id; + $sql .= " c.address, c.statut, c.zip, c.town,"; + $sql .= " c.fk_pays as country_id,"; + $sql .= " c.fk_departement as state_id,"; + $sql .= " c.birthday,"; + $sql .= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,"; + $sql .= " c.socialnetworks,"; + $sql .= " c.photo,"; + $sql .= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; + $sql .= " c.import_key,"; + $sql .= " c.datec as date_creation, c.tms as date_modification,"; + $sql .= " co.label as country, co.code as country_code,"; + $sql .= " d.nom as state, d.code_departement as state_code,"; + $sql .= " u.rowid as user_id, u.login as user_login,"; + $sql .= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON c.fk_pays = co.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; + if ($id) $sql .= " WHERE c.rowid = ".$id; else { $sql .= " WHERE c.entity IN (".getEntity($this->element).")"; @@ -799,47 +799,47 @@ class Contact extends CommonObject } } - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->entity = $obj->entity; - $this->ref = $obj->rowid; - $this->ref_ext = $obj->ref_ext; + $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->ref = $obj->rowid; + $this->ref_ext = $obj->ref_ext; $this->civility_code = $obj->civility_code; - $this->civility = $obj->civility_code?($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code):''; + $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : ''; - $this->lastname = $obj->lastname; - $this->firstname = $obj->firstname; - $this->address = $obj->address; - $this->zip = $obj->zip; - $this->town = $obj->town; + $this->lastname = $obj->lastname; + $this->firstname = $obj->firstname; + $this->address = $obj->address; + $this->zip = $obj->zip; + $this->town = $obj->town; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_modification = $this->db->jdate($obj->date_modification); - $this->state_id = $obj->state_id; - $this->state_code = $obj->state_code; - $this->state = $obj->state; + $this->state_id = $obj->state_id; + $this->state_code = $obj->state_code; + $this->state = $obj->state; - $this->country_id = $obj->country_id; - $this->country_code = $obj->country_id?$obj->country_code:''; - $this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; + $this->country_id = $obj->country_id; + $this->country_code = $obj->country_id ? $obj->country_code : ''; + $this->country = $obj->country_id ? ($langs->trans('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : ''; $this->socid = $obj->fk_soc; $this->socname = $obj->socname; $this->poste = $obj->poste; - $this->statut = $obj->statut; + $this->statut = $obj->statut; - $this->phone_pro = trim($obj->phone); - $this->fax = trim($obj->fax); - $this->phone_perso = trim($obj->phone_perso); - $this->phone_mobile = trim($obj->phone_mobile); + $this->phone_pro = trim($obj->phone); + $this->fax = trim($obj->fax); + $this->phone_perso = trim($obj->phone_perso); + $this->phone_mobile = trim($obj->phone_mobile); $this->email = $obj->email; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); @@ -847,14 +847,14 @@ class Contact extends CommonObject $this->priv = $obj->priv; $this->mail = $obj->email; - $this->birthday = $this->db->jdate($obj->birthday); - $this->note = $obj->note_private; // deprecated + $this->birthday = $this->db->jdate($obj->birthday); + $this->note = $obj->note_private; // deprecated $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; + $this->note_public = $obj->note_public; $this->default_lang = $obj->default_lang; - $this->user_id = $obj->user_id; + $this->user_id = $obj->user_id; $this->user_login = $obj->user_login; - $this->canvas = $obj->canvas; + $this->canvas = $obj->canvas; $this->import_key = $obj->import_key; @@ -1617,7 +1617,7 @@ class Contact extends CommonObject $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_soc=".$this->socid." AND fk_socpeople=".$this->id;; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_soc=".$this->socid." AND fk_socpeople=".$this->id; ; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 48baff0f8fd..6c0a20bc6db 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_permonth extends ModeleBoxes { - public $boxcode="invoicespermonth"; - public $boximg="object_bill"; - public $boxlabel="BoxCustomersInvoicesPerMonth"; + public $boxcode = "invoicespermonth"; + public $boximg = "object_bill"; + public $boxlabel = "BoxCustomersInvoicesPerMonth"; public $depends = array("facture"); /** @@ -52,9 +52,9 @@ class box_graph_invoices_permonth extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden = ! ($user->rights->facture->lire); + $this->hidden = !($user->rights->facture->lire); } /** @@ -67,14 +67,14 @@ class box_graph_invoices_permonth extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; - $refreshaction='refresh_'.$this->boxcode; + $refreshaction = 'refresh_'.$this->boxcode; //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; //$facturestatic=new Facture($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $text = $langs->trans("BoxCustomersInvoicesPerMonth", $max); @@ -89,50 +89,50 @@ class box_graph_invoices_permonth extends ModeleBoxes 'target'=>'none' // Set '' to get target="_blank" ); - $dir=''; // We don't need a path because image file will not be saved into disk - $prefix=''; - $socid=0; - if ($user->socid) $socid=$user->socid; - if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user + $dir = ''; // We don't need a path because image file will not be saved into disk + $prefix = ''; + $socid = 0; + if ($user->socid) $socid = $user->socid; + if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->facture->lire) { $mesg = ''; - $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; - $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; - $autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); + $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { - $endyear=GETPOST($param_year, 'int'); - $shownb=GETPOST($param_shownb, 'alpha'); - $showtot=GETPOST($param_showtot, 'alpha'); + $endyear = GETPOST($param_year, 'int'); + $shownb = GETPOST($param_shownb, 'alpha'); + $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); - $endyear=$tmparray['year']; - $shownb=$tmparray['shownb']; - $showtot=$tmparray['showtot']; + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); + $endyear = $tmparray['year']; + $shownb = $tmparray['shownb']; + $showtot = $tmparray['showtot']; } - if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; } - $nowarray=dol_getdate(dol_now(), true); - if (empty($endyear)) $endyear=$nowarray['year']; - $startyear=$endyear-1; - $mode='customer'; - $WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320'; - $HEIGHT='192'; + if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } + $nowarray = dol_getdate(dol_now(), true); + if (empty($endyear)) $endyear = $nowarray['year']; + $startyear = $endyear - 1; + $mode = 'customer'; + $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; + $HEIGHT = '192'; $stats = new FactureStats($this->db, $socid, $mode, 0); // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png"; // default value for customer mode @@ -141,22 +141,22 @@ class box_graph_invoices_permonth extends ModeleBoxes $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); - if (! $mesg) + if (!$mesg) { $langs->load("bills"); $px1->SetData($data1); unset($data1); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { - $legend[]=sprintf("%d/%d", $i-2001, $i-2000); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -168,7 +168,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $px1->SetShading(3); $px1->SetHorizTickIncrement(1); $px1->SetCssPrefix("cssboxes"); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberOfBillsByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -178,7 +178,7 @@ class box_graph_invoices_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png"; // default value for customer mode @@ -187,22 +187,22 @@ class box_graph_invoices_permonth extends ModeleBoxes $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); - if (! $mesg) + if (!$mesg) { $langs->load("bills"); $px2->SetData($data2); unset($data2); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { - $legend[]=sprintf("%d/%d", $i-2001, $i-2000); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -214,7 +214,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $px2->SetShading(3); $px2->SetHorizTickIncrement(1); $px2->SetCssPrefix("cssboxes"); - $px2->mode='depth'; + $px2->mode = 'depth'; $px2->SetTitle($langs->trans("AmountOfBillsByMonthHT")); $px2->draw($filenamenb, $fileurlnb); @@ -224,51 +224,51 @@ class box_graph_invoices_permonth extends ModeleBoxes if (empty($conf->use_javascript_ajax)) { $langs->load("errors"); - $mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); + $mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); } - if (! $mesg) + if (!$mesg) { - $stringtoshow=''; - $stringtoshow.=''; - $stringtoshow.='
'; // hideobject is to start hidden - $stringtoshow.='
'; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=' '.$langs->trans("NumberOfBillsByMonth"); - $stringtoshow.='   '; - $stringtoshow.=' '.$langs->trans("AmountOfBillsByMonthHT"); - $stringtoshow.='
'; - $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; // hideobject is to start hidden + $stringtoshow .= '
'; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ' '.$langs->trans("NumberOfBillsByMonth"); + $stringtoshow .= '   '; + $stringtoshow .= ' '.$langs->trans("AmountOfBillsByMonthHT"); + $stringtoshow .= '
'; + $stringtoshow .= $langs->trans("Year").' '; + $stringtoshow .= ''; + $stringtoshow .= '
'; + $stringtoshow .= '
'; if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($shownb) $stringtoshow.=$px1->show(); + if ($shownb) $stringtoshow .= $px1->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($showtot) $stringtoshow.=$px2->show(); + if ($showtot) $stringtoshow .= $px2->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"','textnoformat'=>$stringtoshow); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); } else { diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index f9e2d3ccc25..52dcdc995cd 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_supplier_permonth extends ModeleBoxes { - public $boxcode="invoicessupplierpermonth"; - public $boximg="object_bill"; - public $boxlabel="BoxSuppliersInvoicesPerMonth"; + public $boxcode = "invoicessupplierpermonth"; + public $boximg = "object_bill"; + public $boxlabel = "BoxSuppliersInvoicesPerMonth"; public $depends = array("fournisseur"); /** @@ -52,9 +52,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden = ! ($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** @@ -67,13 +67,13 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; - $refreshaction='refresh_'.$this->boxcode; + $refreshaction = 'refresh_'.$this->boxcode; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $text = $langs->trans("BoxSuppliersInvoicesPerMonth", $max); @@ -88,48 +88,48 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes 'target'=>'none' // Set '' to get target="_blank" ); - $dir=''; // We don't need a path because image file will not be saved into disk - $prefix=''; - $socid=0; - if ($user->socid) $socid=$user->socid; - if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user + $dir = ''; // We don't need a path because image file will not be saved into disk + $prefix = ''; + $socid = 0; + if ($user->socid) $socid = $user->socid; + if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->fournisseur->facture->lire) { - $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; - $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; - $autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); + $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { - $endyear=GETPOST($param_year, 'int'); - $shownb=GETPOST($param_shownb, 'alpha'); - $showtot=GETPOST($param_showtot, 'alpha'); + $endyear = GETPOST($param_year, 'int'); + $shownb = GETPOST($param_shownb, 'alpha'); + $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); - $endyear=$tmparray['year']; - $shownb=$tmparray['shownb']; - $showtot=$tmparray['showtot']; + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); + $endyear = $tmparray['year']; + $shownb = $tmparray['shownb']; + $showtot = $tmparray['showtot']; } - if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; } - $nowarray=dol_getdate(dol_now(), true); - if (empty($endyear)) $endyear=$nowarray['year']; - $startyear=$endyear-1; - $mode='supplier'; - $WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320'; - $HEIGHT='192'; + if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } + $nowarray = dol_getdate(dol_now(), true); + if (empty($endyear)) $endyear = $nowarray['year']; + $startyear = $endyear - 1; + $mode = 'supplier'; + $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; + $HEIGHT = '192'; $stats = new FactureStats($this->db, $socid, $mode, 0); // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png"; // default value for customer mode @@ -138,23 +138,23 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); - if (! $mesg) + if (!$mesg) { $langs->load("bills"); $px1->SetData($data1); unset($data1); - $i=$startyear; - $legend=array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { - $legend[]=sprintf("%d/%d", $i-2001, $i-2000); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -166,7 +166,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $px1->SetShading(3); $px1->SetHorizTickIncrement(1); $px1->SetCssPrefix("cssboxes"); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberOfBillsByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -176,7 +176,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$year.".png"; // default value for customer mode @@ -185,22 +185,22 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); - if (! $mesg) + if (!$mesg) { $langs->load("bills"); $px2->SetData($data2); unset($data2); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { - $legend[]=sprintf("%d/%d", $i-2001, $i-2000); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -212,7 +212,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $px2->SetShading(3); $px2->SetHorizTickIncrement(1); $px2->SetCssPrefix("cssboxes"); - $px2->mode='depth'; + $px2->mode = 'depth'; $px2->SetTitle($langs->trans("AmountOfBillsByMonthHT")); $px2->draw($filenamenb, $fileurlnb); @@ -222,51 +222,51 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes if (empty($conf->use_javascript_ajax)) { $langs->load("errors"); - $mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); + $mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); } - if (! $mesg) + if (!$mesg) { - $stringtoshow=''; - $stringtoshow.=''; - $stringtoshow.='
'; // hideobject is to start hidden - $stringtoshow.='
'; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=' '.$langs->trans("NumberOfBillsByMonth"); - $stringtoshow.='   '; - $stringtoshow.=' '.$langs->trans("AmountOfBillsByMonthHT"); - $stringtoshow.='
'; - $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; // hideobject is to start hidden + $stringtoshow .= '
'; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ' '.$langs->trans("NumberOfBillsByMonth"); + $stringtoshow .= '   '; + $stringtoshow .= ' '.$langs->trans("AmountOfBillsByMonthHT"); + $stringtoshow .= '
'; + $stringtoshow .= $langs->trans("Year").' '; + $stringtoshow .= ''; + $stringtoshow .= '
'; + $stringtoshow .= '
'; if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($shownb) $stringtoshow.=$px1->show(); + if ($shownb) $stringtoshow .= $px1->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($showtot) $stringtoshow.=$px2->show(); + if ($showtot) $stringtoshow .= $px2->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"','td' => 'class="nohover center"','textnoformat'=>$stringtoshow); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); } else { diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 244bd7d7083..45459805f00 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_orders_permonth extends ModeleBoxes { - public $boxcode="orderspermonth"; - public $boximg="object_order"; - public $boxlabel="BoxCustomersOrdersPerMonth"; + public $boxcode = "orderspermonth"; + public $boximg = "object_order"; + public $boxlabel = "BoxCustomersOrdersPerMonth"; public $depends = array("commande"); /** @@ -52,9 +52,9 @@ class box_graph_orders_permonth extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden = ! ($user->rights->commande->lire); + $this->hidden = !($user->rights->commande->lire); } /** @@ -67,14 +67,14 @@ class box_graph_orders_permonth extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; - $refreshaction='refresh_'.$this->boxcode; + $refreshaction = 'refresh_'.$this->boxcode; //include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; //$commandestatic=new Commande($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $text = $langs->trans("BoxCustomersOrdersPerMonth", $max); @@ -89,50 +89,50 @@ class box_graph_orders_permonth extends ModeleBoxes 'target'=>'none' // Set '' to get target="_blank" ); - $dir=''; // We don't need a path because image file will not be saved into disk - $prefix=''; - $socid=0; - if ($user->socid) $socid=$user->socid; - if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user + $dir = ''; // We don't need a path because image file will not be saved into disk + $prefix = ''; + $socid = 0; + if ($user->socid) $socid = $user->socid; + if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->commande->lire) { $langs->load("orders"); - $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; - $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; - $autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); + $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { - $endyear=GETPOST($param_year, 'int'); - $shownb=GETPOST($param_shownb, 'alpha'); - $showtot=GETPOST($param_showtot, 'alpha'); + $endyear = GETPOST($param_year, 'int'); + $shownb = GETPOST($param_shownb, 'alpha'); + $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); - $endyear=$tmparray['year']; - $shownb=$tmparray['shownb']; - $showtot=$tmparray['showtot']; + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); + $endyear = $tmparray['year']; + $shownb = $tmparray['shownb']; + $showtot = $tmparray['showtot']; } - if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; } - $nowarray=dol_getdate(dol_now(), true); - if (empty($endyear)) $endyear=$nowarray['year']; - $startyear=$endyear-1; - $mode='customer'; - $WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320'; - $HEIGHT='192'; + if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } + $nowarray = dol_getdate(dol_now(), true); + if (empty($endyear)) $endyear = $nowarray['year']; + $startyear = $endyear - 1; + $mode = 'customer'; + $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; + $HEIGHT = '192'; $stats = new CommandeStats($this->db, $socid, $mode, 0); // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png"; // default value for customer mode @@ -141,21 +141,21 @@ class box_graph_orders_permonth extends ModeleBoxes $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); - if (! $mesg) + if (!$mesg) { $px1->SetData($data1); unset($data1); - $i=$startyear; - $legend=array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { - $legend[]=sprintf("%d/%d", $i-2001, $i-2000); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -167,7 +167,7 @@ class box_graph_orders_permonth extends ModeleBoxes $px1->SetShading(3); $px1->SetHorizTickIncrement(1); $px1->SetCssPrefix("cssboxes"); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberOfOrdersByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -177,7 +177,7 @@ class box_graph_orders_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png"; // default value for customer mode @@ -186,20 +186,20 @@ class box_graph_orders_permonth extends ModeleBoxes $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); - if (! $mesg) + if (!$mesg) { $px2->SetData($data2); unset($data2); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { - $legend[]=sprintf("%d/%d", $i-2001, $i-2000); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -211,7 +211,7 @@ class box_graph_orders_permonth extends ModeleBoxes $px2->SetShading(3); $px2->SetHorizTickIncrement(1); $px2->SetCssPrefix("cssboxes"); - $px2->mode='depth'; + $px2->mode = 'depth'; $px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT")); $px2->draw($filenamenb, $fileurlnb); @@ -221,49 +221,49 @@ class box_graph_orders_permonth extends ModeleBoxes if (empty($conf->use_javascript_ajax)) { $langs->load("errors"); - $mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); + $mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); } - if (! $mesg) + if (!$mesg) { - $stringtoshow=''; - $stringtoshow.=''; - $stringtoshow.='
'; // hideobject is to start hidden - $stringtoshow.='
'; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=' '.$langs->trans("NumberOfOrdersByMonth"); - $stringtoshow.='   '; - $stringtoshow.=' '.$langs->trans("AmountOfOrdersByMonthHT"); - $stringtoshow.='
'; - $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; // hideobject is to start hidden + $stringtoshow .= '
'; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ' '.$langs->trans("NumberOfOrdersByMonth"); + $stringtoshow .= '   '; + $stringtoshow .= ' '.$langs->trans("AmountOfOrdersByMonthHT"); + $stringtoshow .= '
'; + $stringtoshow .= $langs->trans("Year").' '; + $stringtoshow .= ''; + $stringtoshow .= '
'; + $stringtoshow .= '
'; if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($shownb) $stringtoshow.=$px1->show(); + if ($shownb) $stringtoshow .= $px1->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($showtot) $stringtoshow.=$px2->show(); + if ($showtot) $stringtoshow .= $px2->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( 'tr'=>'class="oddeven nohover"', diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 3ceb04b7d4c..99426be8cb1 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_orders_supplier_permonth extends ModeleBoxes { - public $boxcode="orderssupplierpermonth"; - public $boximg="object_order"; - public $boxlabel="BoxSuppliersOrdersPerMonth"; + public $boxcode = "orderssupplierpermonth"; + public $boximg = "object_order"; + public $boxlabel = "BoxSuppliersOrdersPerMonth"; public $depends = array("fournisseur"); /** @@ -52,9 +52,9 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden = ! ($user->rights->fournisseur->commande->lire); + $this->hidden = !($user->rights->fournisseur->commande->lire); } /** @@ -67,13 +67,13 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; - $refreshaction='refresh_'.$this->boxcode; + $refreshaction = 'refresh_'.$this->boxcode; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $text = $langs->trans("BoxSuppliersOrdersPerMonth", $max); @@ -88,50 +88,50 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes 'target'=>'none' // Set '' to get target="_blank" ); - $dir=''; // We don't need a path because image file will not be saved into disk - $prefix=''; - $socid=0; - if ($user->socid) $socid=$user->socid; - if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user + $dir = ''; // We don't need a path because image file will not be saved into disk + $prefix = ''; + $socid = 0; + if ($user->socid) $socid = $user->socid; + if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->fournisseur->commande->lire) { $langs->load("orders"); - $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; - $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; - $autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); + $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { - $endyear=GETPOST($param_year, 'int'); - $shownb=GETPOST($param_shownb, 'alpha'); - $showtot=GETPOST($param_showtot, 'alpha'); + $endyear = GETPOST($param_year, 'int'); + $shownb = GETPOST($param_shownb, 'alpha'); + $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); - $endyear=$tmparray['year']; - $shownb=$tmparray['shownb']; - $showtot=$tmparray['showtot']; + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); + $endyear = $tmparray['year']; + $shownb = $tmparray['shownb']; + $showtot = $tmparray['showtot']; } - if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; } - $nowarray=dol_getdate(dol_now(), true); - if (empty($endyear)) $endyear=$nowarray['year']; - $startyear=$endyear-1; - $mode='supplier'; - $WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320'; - $HEIGHT='192'; + if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } + $nowarray = dol_getdate(dol_now(), true); + if (empty($endyear)) $endyear = $nowarray['year']; + $startyear = $endyear - 1; + $mode = 'supplier'; + $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; + $HEIGHT = '192'; $stats = new CommandeStats($this->db, $socid, $mode, 0); // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."orderssuppliernbinyear-".$endyear.".png"; // default value for customer mode @@ -140,21 +140,21 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); - if (! $mesg) + if (!$mesg) { $px1->SetData($data1); unset($data1); - $i=$startyear; - $legend=array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { - $legend[]=sprintf("%d/%d", $i-2001, $i-2000); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -166,7 +166,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $px1->SetShading(3); $px1->SetHorizTickIncrement(1); $px1->SetCssPrefix("cssboxes"); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberOfOrdersByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -176,7 +176,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."orderssupplieramountinyear-".$endyear.".png"; // default value for customer mode @@ -185,20 +185,20 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); - if (! $mesg) + if (!$mesg) { $px2->SetData($data2); unset($data2); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { - $legend[]=sprintf("%d/%d", $i-2001, $i-2000); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -210,7 +210,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $px2->SetShading(3); $px2->SetHorizTickIncrement(1); $px2->SetCssPrefix("cssboxes"); - $px2->mode='depth'; + $px2->mode = 'depth'; $px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT")); $px2->draw($filenamenb, $fileurlnb); @@ -220,49 +220,49 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes if (empty($conf->use_javascript_ajax)) { $langs->load("errors"); - $mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); + $mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); } - if (! $mesg) + if (!$mesg) { - $stringtoshow=''; - $stringtoshow.=''; - $stringtoshow.='
'; // hideobject is to start hidden - $stringtoshow.='
'; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=' '.$langs->trans("NumberOfOrdersByMonth"); - $stringtoshow.='   '; - $stringtoshow.=' '.$langs->trans("AmountOfOrdersByMonthHT"); - $stringtoshow.='
'; - $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; // hideobject is to start hidden + $stringtoshow .= '
'; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ' '.$langs->trans("NumberOfOrdersByMonth"); + $stringtoshow .= '   '; + $stringtoshow .= ' '.$langs->trans("AmountOfOrdersByMonthHT"); + $stringtoshow .= '
'; + $stringtoshow .= $langs->trans("Year").' '; + $stringtoshow .= ''; + $stringtoshow .= '
'; + $stringtoshow .= '
'; if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($shownb) $stringtoshow.=$px1->show(); + if ($shownb) $stringtoshow .= $px1->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($showtot) $stringtoshow.=$px2->show(); + if ($showtot) $stringtoshow .= $px2->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( 'tr'=>'class="oddeven nohover"', diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 48493eeac92..c61bc2569be 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -29,10 +29,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; */ class box_graph_product_distribution extends ModeleBoxes { - public $boxcode="productdistribution"; - public $boximg="object_product"; - public $boxlabel="BoxProductDistribution"; - public $depends = array("product|service","facture|propal|commande"); + public $boxcode = "productdistribution"; + public $boximg = "object_product"; + public $boxlabel = "BoxProductDistribution"; + public $depends = array("product|service", "facture|propal|commande"); /** * @var DoliDB Database handler. @@ -55,12 +55,12 @@ class box_graph_product_distribution extends ModeleBoxes { global $user, $conf; - $this->db=$db; + $this->db = $db; - $this->hidden = ! ( - (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire)) - || (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire)) - || (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire)) + $this->hidden = !( + (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) + || (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) + || (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) ); } @@ -74,43 +74,43 @@ class box_graph_product_distribution extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; - $refreshaction='refresh_'.$this->boxcode; + $refreshaction = 'refresh_'.$this->boxcode; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_showinvoicenb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb'; - $param_showpropalnb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb'; - $param_showordernb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb'; - $autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_showinvoicenb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb'; + $param_showpropalnb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb'; + $param_showordernb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb'; + $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { - $year=GETPOST($param_year, 'int'); - $showinvoicenb=GETPOST($param_showinvoicenb, 'alpha'); - $showpropalnb=GETPOST($param_showpropalnb, 'alpha'); - $showordernb=GETPOST($param_showordernb, 'alpha'); + $year = GETPOST($param_year, 'int'); + $showinvoicenb = GETPOST($param_showinvoicenb, 'alpha'); + $showpropalnb = GETPOST($param_showpropalnb, 'alpha'); + $showordernb = GETPOST($param_showordernb, 'alpha'); } else { - $tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); - $year=$tmparray['year']; - $showinvoicenb=$tmparray['showinvoicenb']; - $showpropalnb=$tmparray['showpropalnb']; - $showordernb=$tmparray['showordernb']; + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); + $year = $tmparray['year']; + $showinvoicenb = $tmparray['showinvoicenb']; + $showpropalnb = $tmparray['showpropalnb']; + $showordernb = $tmparray['showordernb']; } - if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; } - if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0; - if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb=0; - if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0; + if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb = 1; $showinvoicenb = 1; $showordernb = 1; } + if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb = 0; + if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb = 0; + if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb = 0; - $nowarray=dol_getdate(dol_now(), true); - if (empty($year)) $year=$nowarray['year']; + $nowarray = dol_getdate(dol_now(), true); + if (empty($year)) $year = $nowarray['year']; - $nbofgraph=0; + $nbofgraph = 0; if ($showinvoicenb) $nbofgraph++; if ($showpropalnb) $nbofgraph++; if ($showordernb) $nbofgraph++; @@ -128,13 +128,13 @@ class box_graph_product_distribution extends ModeleBoxes ); - $socid=empty($user->socid)?0:$user->socid; - $userid=0; // No filter on user creation + $socid = empty($user->socid) ? 0 : $user->socid; + $userid = 0; // No filter on user creation - $WIDTH=($nbofgraph >= 2 || ! empty($conf->dol_optimize_smallscreen))?'160':'320'; - $HEIGHT='192'; + $WIDTH = ($nbofgraph >= 2 || !empty($conf->dol_optimize_smallscreen)) ? '160' : '320'; + $HEIGHT = '192'; - if (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire)) + if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showinvoicenb) @@ -143,34 +143,34 @@ class box_graph_product_distribution extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; $showpointvalue = 1; $nocolor = 0; - $mode='customer'; - $stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid>0?$userid:0)); - $data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24))); + $mode = 'customer'; + $stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0)); + $data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24))); if (empty($data1)) { - $showpointvalue=0; - $nocolor=1; - $data1=array(array(0=>$langs->trans("None"),1=>1)); + $showpointvalue = 0; + $nocolor = 1; + $data1 = array(array(0=>$langs->trans("None"), 1=>1)); } $filenamenb = $dir."/prodserforinvoice-".$year.".png"; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file=prodserforinvoice-'.$year.'.png'; $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); - if (! $mesg) + if (!$mesg) { - $i=0;$tot=count($data1);$legend=array(); + $i = 0; $tot = count($data1); $legend = array(); while ($i <= $tot) { - $data1[$i][0]=dol_trunc($data1[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" - $legend[]=$data1[$i][0]; + $data1[$i][0] = dol_trunc($data1[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" + $legend[] = $data1[$i][0]; $i++; } $px1->SetData($data1); unset($data1); - if ($nocolor) $px1->SetDataColor(array(array(220,220,220))); + if ($nocolor) $px1->SetDataColor(array(array(220, 220, 220))); $px1->SetLegend($legend); $px1->setShowLegend(0); $px1->setShowPointValue($showpointvalue); @@ -192,7 +192,7 @@ class box_graph_product_distribution extends ModeleBoxes } } - if (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire)) + if (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showpropalnb) @@ -201,13 +201,13 @@ class box_graph_product_distribution extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; $showpointvalue = 1; $nocolor = 0; - $stats_proposal = new PropaleStats($this->db, $socid, ($userid>0?$userid:0)); - $data2 = $stats_proposal->getAllByProductEntry($year, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24))); + $stats_proposal = new PropaleStats($this->db, $socid, ($userid > 0 ? $userid : 0)); + $data2 = $stats_proposal->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24))); if (empty($data2)) { $showpointvalue = 0; $nocolor = 1; - $data2=array(array(0=>$langs->trans("None"),1=>1)); + $data2 = array(array(0=>$langs->trans("None"), 1=>1)); } $filenamenb = $dir."/prodserforpropal-".$year.".png"; @@ -215,20 +215,20 @@ class box_graph_product_distribution extends ModeleBoxes $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); - if (! $mesg) + if (!$mesg) { - $i=0;$tot=count($data2);$legend=array(); + $i = 0; $tot = count($data2); $legend = array(); while ($i <= $tot) { - $data2[$i][0]=dol_trunc($data2[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" - $legend[]=$data2[$i][0]; + $data2[$i][0] = dol_trunc($data2[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" + $legend[] = $data2[$i][0]; $i++; } $px2->SetData($data2); unset($data2); - if ($nocolor) $px2->SetDataColor(array(array(220,220,220))); + if ($nocolor) $px2->SetDataColor(array(array(220, 220, 220))); $px2->SetLegend($legend); $px2->setShowLegend(0); $px2->setShowPointValue($showpointvalue); @@ -250,7 +250,7 @@ class box_graph_product_distribution extends ModeleBoxes } } - if (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire)) + if (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showordernb) @@ -259,14 +259,14 @@ class box_graph_product_distribution extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; $showpointvalue = 1; $nocolor = 0; - $mode='customer'; - $stats_order = new CommandeStats($this->db, $socid, $mode, ($userid>0?$userid:0)); - $data3 = $stats_order->getAllByProductEntry($year, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24))); + $mode = 'customer'; + $stats_order = new CommandeStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0)); + $data3 = $stats_order->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24))); if (empty($data3)) { $showpointvalue = 0; $nocolor = 1; - $data3=array(array(0=>$langs->trans("None"),1=>1)); + $data3 = array(array(0=>$langs->trans("None"), 1=>1)); } $filenamenb = $dir."/prodserfororder-".$year.".png"; @@ -274,20 +274,20 @@ class box_graph_product_distribution extends ModeleBoxes $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); - if (! $mesg) + if (!$mesg) { - $i=0;$tot=count($data3);$legend=array(); + $i = 0; $tot = count($data3); $legend = array(); while ($i <= $tot) { - $data3[$i][0]=dol_trunc($data3[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" - $legend[]=$data3[$i][0]; + $data3[$i][0] = dol_trunc($data3[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" + $legend[] = $data3[$i][0]; $i++; } $px3->SetData($data3); unset($data3); - if ($nocolor) $px3->SetDataColor(array(array(220,220,220))); + if ($nocolor) $px3->SetDataColor(array(array(220, 220, 220))); $px3->SetLegend($legend); $px3->setShowLegend(0); $px3->setShowPointValue($showpointvalue); @@ -312,76 +312,76 @@ class box_graph_product_distribution extends ModeleBoxes if (empty($nbofgraph)) { $langs->load("errors"); - $mesg=$langs->trans("ReadPermissionNotAllowed"); + $mesg = $langs->trans("ReadPermissionNotAllowed"); } if (empty($conf->use_javascript_ajax)) { $langs->load("errors"); - $mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); + $mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); } - if (! $mesg) + if (!$mesg) { - $stringtoshow=''; - $stringtoshow.=''; - $stringtoshow.='
'; // hideobject is to start hidden - $stringtoshow.='
'; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - if (! empty($conf->facture->enabled) || ! empty($user->rights->facture->lire)) + $stringtoshow .= '
'; // hideobject is to start hidden + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire)) { - $stringtoshow.=' '.$langs->trans("ForCustomersInvoices"); - $stringtoshow.='   '; + $stringtoshow .= ' '.$langs->trans("ForCustomersInvoices"); + $stringtoshow .= '   '; } - if (! empty($conf->propal->enabled) || ! empty($user->rights->propale->lire)) + if (!empty($conf->propal->enabled) || !empty($user->rights->propale->lire)) { - $stringtoshow.=' '.$langs->trans("ForProposals"); - $stringtoshow.=' '; + $stringtoshow .= ' '.$langs->trans("ForProposals"); + $stringtoshow .= ' '; } - if (! empty($conf->commande->enabled) || ! empty($user->rights->commande->lire)) + if (!empty($conf->commande->enabled) || !empty($user->rights->commande->lire)) { - $stringtoshow.=' '.$langs->trans("ForCustomersOrders"); + $stringtoshow .= ' '.$langs->trans("ForCustomersOrders"); } - $stringtoshow.='
'; - $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= $langs->trans("Year").' '; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= '
'; if ($nbofgraph == 1) { - if ($showinvoicenb) $stringtoshow.=$px1->show(); - elseif ($showpropalnb) $stringtoshow.=$px2->show(); - else $stringtoshow.=$px3->show(); + if ($showinvoicenb) $stringtoshow .= $px1->show(); + elseif ($showpropalnb) $stringtoshow .= $px2->show(); + else $stringtoshow .= $px3->show(); } if ($nbofgraph == 2) { - $stringtoshow.='
'; - if ($showinvoicenb) $stringtoshow.=$px1->show(); - elseif ($showpropalnb) $stringtoshow.=$px2->show(); - $stringtoshow.='
'; - if ($showordernb) $stringtoshow.=$px3->show(); - elseif ($showpropalnb) $stringtoshow.=$px2->show(); - $stringtoshow.='
'; + $stringtoshow .= '
'; + if ($showinvoicenb) $stringtoshow .= $px1->show(); + elseif ($showpropalnb) $stringtoshow .= $px2->show(); + $stringtoshow .= '
'; + if ($showordernb) $stringtoshow .= $px3->show(); + elseif ($showpropalnb) $stringtoshow .= $px2->show(); + $stringtoshow .= '
'; } if ($nbofgraph == 3) { - $stringtoshow.='
'; - $stringtoshow.=$px1->show(); - $stringtoshow.='
'; - $stringtoshow.=$px2->show(); - $stringtoshow.='
'; - $stringtoshow.='
'; - $stringtoshow.=$px3->show(); - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= $px1->show(); + $stringtoshow .= '
'; + $stringtoshow .= $px2->show(); + $stringtoshow .= '
'; + $stringtoshow .= '
'; + $stringtoshow .= $px3->show(); + $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( 'tr'=>'class="oddeven nohover"', diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index f02ad99657c..42b95e516b5 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_propales_permonth extends ModeleBoxes { - public $boxcode="propalpermonth"; - public $boximg="object_propal"; - public $boxlabel="BoxProposalsPerMonth"; + public $boxcode = "propalpermonth"; + public $boximg = "object_propal"; + public $boxlabel = "BoxProposalsPerMonth"; public $depends = array("propal"); /** @@ -54,7 +54,7 @@ class box_graph_propales_permonth extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->propale->lire); + $this->hidden = !($user->rights->propale->lire); } /** @@ -67,14 +67,14 @@ class box_graph_propales_permonth extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; - $refreshaction='refresh_'.$this->boxcode; + $refreshaction = 'refresh_'.$this->boxcode; //include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; //$propalstatic=new Propal($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $langs->load("propal"); @@ -83,7 +83,7 @@ class box_graph_propales_permonth extends ModeleBoxes $this->info_box_head = array( 'text' => $text, 'limit'=> dol_strlen($text), - 'graph'=> 1, // Set to 1 if it's a box graph + 'graph'=> 1, // Set to 1 if it's a box graph 'sublink'=>'', 'subtext'=>$langs->trans("Filter"), 'subpicto'=>'filter.png', @@ -91,69 +91,69 @@ class box_graph_propales_permonth extends ModeleBoxes 'target'=>'none' // Set '' to get target="_blank" ); - $dir=''; // We don't need a path because image file will not be saved into disk - $prefix=''; - $socid=0; - if ($user->socid) $socid=$user->socid; - if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user + $dir = ''; // We don't need a path because image file will not be saved into disk + $prefix = ''; + $socid = 0; + if ($user->socid) $socid = $user->socid; + if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->propale->lire) { - $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; - $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; - $autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); + $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { - $endyear=GETPOST($param_year, 'int'); - $shownb=GETPOST($param_shownb, 'alpha'); - $showtot=GETPOST($param_showtot, 'alpha'); + $endyear = GETPOST($param_year, 'int'); + $shownb = GETPOST($param_shownb, 'alpha'); + $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); - $endyear=$tmparray['year']; - $shownb=$tmparray['shownb']; - $showtot=$tmparray['showtot']; + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); + $endyear = $tmparray['year']; + $shownb = $tmparray['shownb']; + $showtot = $tmparray['showtot']; } - if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; } - $nowarray=dol_getdate(dol_now(), true); - if (empty($endyear)) $endyear=$nowarray['year']; - $startyear=$endyear-1; - $WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320'; - $HEIGHT='192'; + if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } + $nowarray = dol_getdate(dol_now(), true); + if (empty($endyear)) $endyear = $nowarray['year']; + $startyear = $endyear - 1; + $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; + $HEIGHT = '192'; $stats = new PropaleStats($this->db, $socid, 0); // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); - $datatype1 = array_pad(array(), ($endyear-$startyear+1), 'bars'); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); + $datatype1 = array_pad(array(), ($endyear - $startyear + 1), 'bars'); $filenamenb = $dir."/".$prefix."propalsnbinyear-".$endyear.".png"; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=propalsnbinyear-'.$endyear.'.png'; $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); - if (! $mesg) + if (!$mesg) { $px1->SetType($datatype1); $px1->SetData($data1); unset($data1); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { - $legend[]=sprintf("%d/%d", $i-2001, $i-2000); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -165,7 +165,7 @@ class box_graph_propales_permonth extends ModeleBoxes $px1->SetShading(3); $px1->SetHorizTickIncrement(1); $px1->SetCssPrefix("cssboxes"); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberOfProposalsByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -175,8 +175,8 @@ class box_graph_propales_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); - $datatype2 = array_pad(array(), ($endyear-$startyear+1), 'bars'); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); + $datatype2 = array_pad(array(), ($endyear - $startyear + 1), 'bars'); //$datatype2 = array('lines','bars'); $filenamenb = $dir."/".$prefix."propalsamountinyear-".$endyear.".png"; @@ -185,21 +185,21 @@ class box_graph_propales_permonth extends ModeleBoxes $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); - if (! $mesg) + if (!$mesg) { $px2->SetType($datatype2); $px2->SetData($data2); unset($data2); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { - $legend[]=sprintf("%d/%d", $i-2001, $i-2000); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -211,7 +211,7 @@ class box_graph_propales_permonth extends ModeleBoxes $px2->SetShading(3); $px2->SetHorizTickIncrement(1); $px2->SetCssPrefix("cssboxes"); - $px2->mode='depth'; + $px2->mode = 'depth'; $px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT")); $px2->draw($filenamenb, $fileurlnb); @@ -221,49 +221,49 @@ class box_graph_propales_permonth extends ModeleBoxes if (empty($conf->use_javascript_ajax)) { $langs->load("errors"); - $mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); + $mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); } - if (! $mesg) + if (!$mesg) { - $stringtoshow=''; - $stringtoshow.=''; - $stringtoshow.='
'; // hideobject is to start hidden - $stringtoshow.='
'; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=' '.$langs->trans("NumberOfProposalsByMonth"); - $stringtoshow.='   '; - $stringtoshow.=' '.$langs->trans("AmountOfProposalsByMonthHT"); - $stringtoshow.='
'; - $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; // hideobject is to start hidden + $stringtoshow .= '
'; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ' '.$langs->trans("NumberOfProposalsByMonth"); + $stringtoshow .= '   '; + $stringtoshow .= ' '.$langs->trans("AmountOfProposalsByMonthHT"); + $stringtoshow .= '
'; + $stringtoshow .= $langs->trans("Year").' '; + $stringtoshow .= ''; + $stringtoshow .= '
'; + $stringtoshow .= '
'; if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($shownb) $stringtoshow.=$px1->show(); + if ($shownb) $stringtoshow .= $px1->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($showtot) $stringtoshow.=$px2->show(); + if ($showtot) $stringtoshow .= $px2->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( 'tr'=>'class="oddeven nohover"', diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 80264796186..2ae0ede3c21 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -118,16 +118,16 @@ class box_task extends ModeleBoxes // list the summary of the orders if ($user->rights->projet->lire) { - $boxcontent.= '
'."\n"; - $boxcontent.= '
'."\n"; - $boxcontent.= '
boxcode.'">'."\n"; - $boxcontent.= ''."\n"; + $boxcontent .= '
'."\n"; + $boxcontent .= '
'."\n"; + $boxcontent .= 'boxcode.'">'."\n"; + $boxcontent .= ''."\n"; $selectArray = array('all' => $langs->trans("NoFilter"), 'im_task_contact' => $langs->trans("WhichIamLinkedTo"), 'im_project_contact' => $langs->trans("WhichIamLinkedToProject")); - $boxcontent.= $form->selectArray($cookie_name, $selectArray, $filterValue); - $boxcontent.= ''; - $boxcontent.= ''."\n"; - $boxcontent.= '
'."\n"; - $boxcontent.= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; if (count($listofpaths)) { - foreach($listofpaths as $key => $val) + foreach ($listofpaths as $key => $val) { - $out.= '
'; - $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; - if (! $this->withfilereadonly) + $out .= '
'; + $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; + if (!$this->withfilereadonly) { - $out.= ' '; + $out .= ' '; //$out.= ' '.img_delete($langs->trans("Delete").''; } - $out.= '
'; + $out .= '
'; } } elseif (empty($this->withmaindocfile)) // Do not show message if we asked to show the checkbox { - $out.= $langs->trans("NoAttachedFiles").'
'; + $out .= $langs->trans("NoAttachedFiles").'
'; } if ($this->withfile == 2) // Can add other files { - if (!empty($conf->global->FROM_MAIL_USE_INPUT_FILE_MULTIPLE)) $out.= ''; - else $out.= ''; - $out.= ' '; - $out.= ''; + if (!empty($conf->global->FROM_MAIL_USE_INPUT_FILE_MULTIPLE)) $out .= ''; + else $out .= ''; + $out .= ' '; + $out .= ''; } } else { - $out.=$this->withfile; + $out .= $this->withfile; } - $out.= "
'; - $out.=$form->textwithpicto($langs->trans('MailText'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody'); - $out.=''; + $out .= '
'; + $out .= $form->textwithpicto($langs->trans('MailText'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody'); + $out .= ''; if ($this->withbodyreadonly) { - $out.= nl2br($defaultmessage); - $out.= ''; + $out .= nl2br($defaultmessage); + $out .= ''; } else { - if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; + if (!isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; if ($this->withfckeditor == -1) { - if (! empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $this->withfckeditor=1; - else $this->withfckeditor=0; + if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $this->withfckeditor = 1; + else $this->withfckeditor = 0; } - $doleditor=new DolEditor('message', $defaultmessage, '', 280, $this->ckeditortoolbar, 'In', true, true, $this->withfckeditor, 8, '95%'); - $out.= $doleditor->Create(1); + $doleditor = new DolEditor('message', $defaultmessage, '', 280, $this->ckeditortoolbar, 'In', true, true, $this->withfckeditor, 8, '95%'); + $out .= $doleditor->Create(1); } - $out.= "
'."\n"; + $out .= ''."\n"; if ($this->withform == 1 || $this->withform == -1) { - $out.= '
'; - $out.= 'trans("SendMail").'"'; // Add a javascript test to avoid to forget to submit file before sending email if ($this->withfile == 2 && $conf->use_javascript_ajax) { - $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; + $out .= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; } - $out.= ' />'; + $out .= ' />'; if ($this->withcancel) { - $out.= '     '; - $out.= ''; + $out .= '     '; + $out .= ''; } - $out.= '
'."\n"; + $out .= '
'."\n"; } - if ($this->withform == 1) $out.= ''."\n"; + if ($this->withform == 1) $out .= ''."\n"; // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set - if (! empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) + if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) { - $out.= ''; + $out .= ' })'; + $out .= ''; } - $out.= "\n"; + $out .= "\n"; return $out; } @@ -1053,34 +1053,34 @@ class FormMail extends Form { global $conf, $langs, $form; $out = ''; - $out.= $form->textwithpicto($langs->trans("MailCCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if (! empty($this->withtocccreadonly)) { - $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; + $out .= $form->textwithpicto($langs->trans("MailCCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out .= ''; + if (!empty($this->withtocccreadonly)) { + $out .= (!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : ""; } else { - $out.= 'withtoccc) && ! is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />'; - if (! empty($this->withtoccc) && is_array($this->withtoccc)) { - $out.= " ".$langs->trans("and")."/".$langs->trans("or")." "; + $out .= 'withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />'; + if (!empty($this->withtoccc) && is_array($this->withtoccc)) { + $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withtoccc; foreach ($tmparray as $key => $val) { - $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); + $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - $withtocccselected=GETPOST("receiverccc"); // Array of selected value - $out.= $form->multiselectarray("receiverccc", $tmparray, $withtocccselected, null, null, null, null, "90%"); + $withtocccselected = GETPOST("receiverccc"); // Array of selected value + $out .= $form->multiselectarray("receiverccc", $tmparray, $withtocccselected, null, null, null, null, "90%"); } } - $showinfobcc=''; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'order_supplier_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) && ! empty($this->param['models']) && $this->param['models'] == 'invoice_supplier_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) && ! empty($this->param['models']) && $this->param['models'] == 'project') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO; - if ($showinfobcc) $out.=' + '.$showinfobcc; - $out.= "\n"; + $showinfobcc = ''; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_supplier_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'invoice_supplier_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) && !empty($this->param['models']) && $this->param['models'] == 'project') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO; + if ($showinfobcc) $out .= ' + '.$showinfobcc; + $out .= "\n"; return $out; } @@ -1093,16 +1093,16 @@ class FormMail extends Form { global $conf, $langs; //if (! $this->errorstomail) $this->errorstomail=$this->frommail; - $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); + $errorstomail = (!empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); if ($this->witherrorstoreadonly) { - $out= ''.$langs->trans("MailErrorsTo").''; - $out.= ''; - $out.= $errorstomail; - $out.= "\n"; + $out = ''.$langs->trans("MailErrorsTo").''; + $out .= ''; + $out .= $errorstomail; + $out .= "\n"; } else { - $out= ''.$langs->trans("MailErrorsTo").''; - $out.= ''; - $out.= "\n"; + $out = ''.$langs->trans("MailErrorsTo").''; + $out .= ''; + $out .= "\n"; } return $out; } @@ -1117,17 +1117,17 @@ class FormMail extends Form global $conf, $langs, $form; $out = ''.$langs->trans("DeliveryReceipt").''; - if (! empty($this->withdeliveryreceiptreadonly)) { - $out.= yn($this->withdeliveryreceipt); + if (!empty($this->withdeliveryreceiptreadonly)) { + $out .= yn($this->withdeliveryreceipt); } else { - $defaultvaluefordeliveryreceipt=0; - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_PROPAL) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $defaultvaluefordeliveryreceipt=1; - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_SUPPLIER_PROPOSAL) && ! empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $defaultvaluefordeliveryreceipt=1; - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $defaultvaluefordeliveryreceipt=1; - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $defaultvaluefordeliveryreceipt=1; - $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:$defaultvaluefordeliveryreceipt), 1); + $defaultvaluefordeliveryreceipt = 0; + if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_PROPAL) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') $defaultvaluefordeliveryreceipt = 1; + if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_SUPPLIER_PROPOSAL) && !empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $defaultvaluefordeliveryreceipt = 1; + if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && !empty($this->param['models']) && $this->param['models'] == 'order_send') $defaultvaluefordeliveryreceipt = 1; + if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') $defaultvaluefordeliveryreceipt = 1; + $out .= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"]) ? $_POST["deliveryreceipt"] : $defaultvaluefordeliveryreceipt), 1); } - $out.= "\n"; + $out .= "\n"; return $out; } @@ -1143,28 +1143,28 @@ class FormMail extends Form global $conf, $langs, $form; $defaulttopic = GETPOST('subject', 'none'); - if (! GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') { + if (!GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') { if ($arraydefaultmessage && $arraydefaultmessage->topic) { $defaulttopic = $arraydefaultmessage->topic; - } elseif (! is_numeric($this->withtopic)) { + } elseif (!is_numeric($this->withtopic)) { $defaulttopic = $this->withtopic; } } - $defaulttopic=make_substitutions($defaulttopic, $this->substit); + $defaulttopic = make_substitutions($defaulttopic, $this->substit); $out = ''; - $out.= ''; - $out.= $form->textwithpicto($langs->trans('MailTopic'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfromtopic'); - $out.= ''; - $out.= ''; + $out .= ''; + $out .= $form->textwithpicto($langs->trans('MailTopic'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfromtopic'); + $out .= ''; + $out .= ''; if ($this->withtopicreadonly) { - $out.= $defaulttopic; - $out.= ''; + $out .= $defaulttopic; + $out .= ''; } else { - $out.= ''; + $out .= ''; } - $out.= "\n"; + $out .= "\n"; return $out; } @@ -1197,18 +1197,18 @@ class FormMail extends Form if ($languagetosearchmain == $languagetosearch) $languagetosearchmain = ''; $sql = "SELECT rowid, label, topic, joinfiles, content, content_lines, lang"; - $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; - $sql.= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')"; - $sql.= " AND entity IN (".getEntity('c_email_templates').")"; - $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned - if ($active >= 0) $sql.=" AND active = ".$active; - if ($label) $sql.=" AND label ='".$db->escape($label)."'"; - if (! ($id > 0) && $languagetosearch) $sql.= " AND (lang = '".$db->escape($languagetosearch)."'".($languagetosearchmain ? " OR lang = '".$db->escape($languagetosearchmain)."'" : "")." OR lang IS NULL OR lang = '')"; - if ($id > 0) $sql.= " AND rowid=".$id; - if ($id == -1) $sql.= " AND position=0"; - if ($languagetosearch) $sql.= $db->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' - else $sql.= $db->order("position,lang,label", "ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined - $sql.= $db->plimit(1); + $sql .= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; + $sql .= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')"; + $sql .= " AND entity IN (".getEntity('c_email_templates').")"; + $sql .= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned + if ($active >= 0) $sql .= " AND active = ".$active; + if ($label) $sql .= " AND label ='".$db->escape($label)."'"; + if (!($id > 0) && $languagetosearch) $sql .= " AND (lang = '".$db->escape($languagetosearch)."'".($languagetosearchmain ? " OR lang = '".$db->escape($languagetosearchmain)."'" : "")." OR lang IS NULL OR lang = '')"; + if ($id > 0) $sql .= " AND rowid=".$id; + if ($id == -1) $sql .= " AND position=0"; + if ($languagetosearch) $sql .= $db->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' + else $sql .= $db->order("position,lang,label", "ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined + $sql .= $db->plimit(1); //print $sql; $resql = $db->query($sql); @@ -1226,32 +1226,32 @@ class FormMail extends Form $ret->content_lines = $obj->content_lines; $ret->joinfiles = $obj->joinfiles; } - elseif($id == -2) { + elseif ($id == -2) { // Not found with the provided label return -1; } else { // If there is no template at all - $defaultmessage=''; - if ($type_template=='body') { $defaultmessage=$this->withbody; } // Special case to use this->withbody as content - elseif ($type_template=='facture_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoice"); } - elseif ($type_template=='facture_relance') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } - elseif ($type_template=='propal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendProposal"); } - elseif ($type_template=='supplier_proposal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierProposal"); } - elseif ($type_template=='order_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendOrder"); } - elseif ($type_template=='order_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); } - elseif ($type_template=='invoice_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } - elseif ($type_template=='shipping_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendShipping"); } - elseif ($type_template=='fichinter_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } - elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); } - elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); } - elseif (!empty($type_template)) { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContent".ucfirst($type_template)); } + $defaultmessage = ''; + if ($type_template == 'body') { $defaultmessage = $this->withbody; } // Special case to use this->withbody as content + elseif ($type_template == 'facture_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoice"); } + elseif ($type_template == 'facture_relance') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } + elseif ($type_template == 'propal_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendProposal"); } + elseif ($type_template == 'supplier_proposal_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierProposal"); } + elseif ($type_template == 'order_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendOrder"); } + elseif ($type_template == 'order_supplier_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); } + elseif ($type_template == 'invoice_supplier_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } + elseif ($type_template == 'shipping_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendShipping"); } + elseif ($type_template == 'fichinter_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } + elseif ($type_template == 'thirdparty') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentThirdparty"); } + elseif ($type_template == 'user') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentUser"); } + elseif (!empty($type_template)) { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContent".ucfirst($type_template)); } $ret->label = 'default'; $ret->lang = $outputlangs->defaultlang; $ret->topic = ''; $ret->joinfiles = 1; $ret->content = $defaultmessage; - $ret->content_lines =''; + $ret->content_lines = ''; } $db->free($resql); @@ -1275,27 +1275,27 @@ class FormMail extends Form */ public function isEMailTemplate($type_template, $user, $outputlangs) { - $ret=array(); + $ret = array(); $sql = "SELECT label, topic, content, lang"; - $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; - $sql.= " WHERE type_template='".$this->db->escape($type_template)."'"; - $sql.= " AND entity IN (".getEntity('c_email_templates').")"; - $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; - if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; - $sql.= $this->db->order("lang,label", "ASC"); + $sql .= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; + $sql .= " WHERE type_template='".$this->db->escape($type_template)."'"; + $sql .= " AND entity IN (".getEntity('c_email_templates').")"; + $sql .= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; + if (is_object($outputlangs)) $sql .= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; + $sql .= $this->db->order("lang,label", "ASC"); //print $sql; $resql = $this->db->query($sql); if ($resql) { - $num= $this->db->num_rows($resql); + $num = $this->db->num_rows($resql); $this->db->free($resql); return $num; } else { - $this->error=get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror(); + $this->error = get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror(); return -1; } } @@ -1312,44 +1312,44 @@ class FormMail extends Form */ public function fetchAllEMailTemplate($type_template, $user, $outputlangs, $active = 1) { - $ret=array(); + $ret = array(); $sql = "SELECT rowid, label, topic, content, content_lines, lang, fk_user, private, position"; - $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; - $sql.= " WHERE type_template IN ('".$this->db->escape($type_template)."', 'all')"; - $sql.= " AND entity IN (".getEntity('c_email_templates').")"; - $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // See all public templates or templates I own. - if ($active >= 0) $sql.=" AND active = ".$active; + $sql .= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; + $sql .= " WHERE type_template IN ('".$this->db->escape($type_template)."', 'all')"; + $sql .= " AND entity IN (".getEntity('c_email_templates').")"; + $sql .= " AND (private = 0 OR fk_user = ".$user->id.")"; // See all public templates or templates I own. + if ($active >= 0) $sql .= " AND active = ".$active; //if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; // Return all languages - $sql.= $this->db->order("position,lang,label", "ASC"); + $sql .= $this->db->order("position,lang,label", "ASC"); //print $sql; $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $this->lines_model=array(); + $num = $this->db->num_rows($resql); + $this->lines_model = array(); while ($obj = $this->db->fetch_object($resql)) { $line = new ModelMail(); - $line->id=$obj->rowid; - $line->label=$obj->label; - $line->lang=$obj->lang; - $line->fk_user=$obj->fk_user; - $line->private=$obj->private; - $line->position=$obj->position; - $line->topic=$obj->topic; - $line->content=$obj->content; - $line->content_lines=$obj->content_lines; + $line->id = $obj->rowid; + $line->label = $obj->label; + $line->lang = $obj->lang; + $line->fk_user = $obj->fk_user; + $line->private = $obj->private; + $line->position = $obj->position; + $line->topic = $obj->topic; + $line->content = $obj->content; + $line->content_lines = $obj->content_lines; - $this->lines_model[]=$line; + $this->lines_model[] = $line; } $this->db->free($resql); return $num; } else { - $this->error=get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror(); + $this->error = get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror(); return -1; } } @@ -1368,11 +1368,11 @@ class FormMail extends Form { global $conf, $user; - $parameters=array(); - $tmparray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + $parameters = array(); + $tmparray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($tmparray, $outputlangs, null, $parameters); - $this->substit=$tmparray; + $this->substit = $tmparray; // Fill substit_lines with each object lines content if (is_array($object->lines)) @@ -1396,7 +1396,7 @@ class FormMail extends Form // Create dynamic tags for __PRODUCT_EXTRAFIELD_FIELD__ if (!empty($line->fk_product)) { - if (! is_object($extrafields)) $extrafields = new ExtraFields($this->db); + if (!is_object($extrafields)) $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label('product', true); $product = new Product($this->db); $product->fetch($line->fk_product, '', '', 1); @@ -1404,7 +1404,7 @@ class FormMail extends Form if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) { - $substit_line['__PRODUCT_EXTRAFIELD_' . strtoupper($key) . '__'] = $product->array_options['options_' . $key]; + $substit_line['__PRODUCT_EXTRAFIELD_'.strtoupper($key).'__'] = $product->array_options['options_'.$key]; } } } @@ -1425,27 +1425,27 @@ class FormMail extends Form { global $conf, $langs; - $tmparray=array(); + $tmparray = array(); if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines') { - $parameters=array('mode'=>$mode); - $tmparray=getCommonSubstitutionArray($langs, 2, null, $object); // Note: On email templated edition, this is null because it is related to all type of objects + $parameters = array('mode'=>$mode); + $tmparray = getCommonSubstitutionArray($langs, 2, null, $object); // Note: On email templated edition, this is null because it is related to all type of objects complete_substitutions_array($tmparray, $langs, null, $parameters); if ($mode == 'formwithlines') { - $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function + $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function } if ($mode == 'formforlines') { - $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function + $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function } } if ($mode == 'emailing') { - $parameters=array('mode'=>$mode); - $tmparray=getCommonSubstitutionArray($langs, 2, array('object','objectamount'), $object); // Note: On email templated edition, this is null because it is related to all type of objects + $parameters = array('mode'=>$mode); + $tmparray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount'), $object); // Note: On email templated edition, this is null because it is related to all type of objects complete_substitutions_array($tmparray, $langs, null, $parameters); // For mass emailing, we have different keys @@ -1465,18 +1465,18 @@ class FormMail extends Form //,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing $onlinepaymentenabled = 0; - if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++; - if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++; - if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++; - if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + if (!empty($conf->paypal->enabled)) $onlinepaymentenabled++; + if (!empty($conf->paybox->enabled)) $onlinepaymentenabled++; + if (!empty($conf->stripe->enabled)) $onlinepaymentenabled++; + if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - $tmparray['__SECUREKEYPAYMENT__']=$conf->global->PAYMENT_SECURITY_TOKEN; - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) + $tmparray['__SECUREKEYPAYMENT__'] = $conf->global->PAYMENT_SECURITY_TOKEN; + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - if ($conf->adherent->enabled) $tmparray['__SECUREKEYPAYMENT_MEMBER__']='SecureKeyPAYMENTUniquePerMember'; - if ($conf->facture->enabled) $tmparray['__SECUREKEYPAYMENT_INVOICE__']='SecureKeyPAYMENTUniquePerInvoice'; - if ($conf->commande->enabled) $tmparray['__SECUREKEYPAYMENT_ORDER__']='SecureKeyPAYMENTUniquePerOrder'; - if ($conf->contrat->enabled) $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__']='SecureKeyPAYMENTUniquePerContractLine'; + if ($conf->adherent->enabled) $tmparray['__SECUREKEYPAYMENT_MEMBER__'] = 'SecureKeyPAYMENTUniquePerMember'; + if ($conf->facture->enabled) $tmparray['__SECUREKEYPAYMENT_INVOICE__'] = 'SecureKeyPAYMENTUniquePerInvoice'; + if ($conf->commande->enabled) $tmparray['__SECUREKEYPAYMENT_ORDER__'] = 'SecureKeyPAYMENTUniquePerOrder'; + if ($conf->contrat->enabled) $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'SecureKeyPAYMENTUniquePerContractLine'; } } else @@ -1491,9 +1491,9 @@ class FormMail extends Form } } - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { - if (empty($val)) $tmparray[$key]=$key; + if (empty($val)) $tmparray[$key] = $key; } return $tmparray; diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 535d5bef3cd..12be3854ed6 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -23,7 +23,7 @@ * \ingroup notification * \brief File of class to manage notifications */ -require_once DOL_DOCUMENT_ROOT .'/core/class/CMailFile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; /** @@ -44,7 +44,7 @@ class Notify /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -110,27 +110,27 @@ class Notify global $langs; $langs->load("mails"); - $listofnotiftodo=$this->getNotificationsArray($action, $socid, $object, 0); + $listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0); - $nb=-1; - if (is_array($listofnotiftodo)) $nb=count($listofnotiftodo); - if ($nb < 0) $texte=img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend"); - if ($nb == 0) $texte=img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent"); - if ($nb == 1) $texte=img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent"); - if ($nb >= 2) $texte=img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb); + $nb = -1; + if (is_array($listofnotiftodo)) $nb = count($listofnotiftodo); + if ($nb < 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend"); + if ($nb == 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent"); + if ($nb == 1) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent"); + if ($nb >= 2) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb); if (is_array($listofnotiftodo)) { - $i=0; + $i = 0; foreach ($listofnotiftodo as $key => $val) { - if ($i) $texte.=', '; - else $texte.=' ('; - if ($val['isemailvalid']) $texte.=$val['email']; - else $texte.=$val['emaildesc']; + if ($i) $texte .= ', '; + else $texte .= ' ('; + if ($val['isemailvalid']) $texte .= $val['email']; + else $texte .= $val['emaildesc']; $i++; } - if ($i) $texte.=')'; + if ($i) $texte .= ')'; } return $texte; @@ -150,31 +150,31 @@ class Notify { global $conf, $user; - $error=0; - $resarray=array(); + $error = 0; + $resarray = array(); $valueforthreshold = 0; if (is_object($object)) $valueforthreshold = $object->total_ht; - if (! $error) + if (!$error) { if ($socid >= 0 && in_array('thirdparty', $scope)) { $sql = "SELECT a.code, c.email, c.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; - $sql.= " ".MAIN_DB_PREFIX."socpeople as c,"; - $sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE n.fk_contact = c.rowid"; - $sql.= " AND a.rowid = n.fk_action"; - $sql.= " AND n.fk_soc = s.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; + $sql .= " ".MAIN_DB_PREFIX."socpeople as c,"; + $sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE n.fk_contact = c.rowid"; + $sql .= " AND a.rowid = n.fk_action"; + $sql .= " AND n.fk_soc = s.rowid"; if ($notifcode) { - if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage - else $sql.= " AND a.code = '".$notifcode."'"; // New usage + if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage + else $sql .= " AND a.code = '".$notifcode."'"; // New usage } - $sql.= " AND s.entity IN (".getEntity('societe').")"; - if ($socid > 0) $sql.= " AND s.rowid = ".$socid; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + if ($socid > 0) $sql .= " AND s.rowid = ".$socid; dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); @@ -182,14 +182,14 @@ class Notify if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($obj) { - $newval2=trim($obj->email); - $isvalid=isValidEmail($newval2); + $newval2 = trim($obj->email); + $isvalid = isValidEmail($newval2); if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid); } $i++; @@ -198,28 +198,28 @@ class Notify else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } } } - if (! $error) + if (!$error) { if ($userid >= 0 && in_array('user', $scope)) { $sql = "SELECT a.code, c.email, c.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; - $sql.= " ".MAIN_DB_PREFIX."user as c,"; - $sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a"; - $sql.= " WHERE n.fk_user = c.rowid"; - $sql.= " AND a.rowid = n.fk_action"; + $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; + $sql .= " ".MAIN_DB_PREFIX."user as c,"; + $sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a"; + $sql .= " WHERE n.fk_user = c.rowid"; + $sql .= " AND a.rowid = n.fk_action"; if ($notifcode) { - if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage - else $sql.= " AND a.code = '".$notifcode."'"; // New usage + if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage + else $sql .= " AND a.code = '".$notifcode."'"; // New usage } - $sql.= " AND c.entity IN (".getEntity('user').")"; - if ($userid > 0) $sql.= " AND c.rowid = ".$userid; + $sql .= " AND c.entity IN (".getEntity('user').")"; + if ($userid > 0) $sql .= " AND c.rowid = ".$userid; dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); @@ -227,14 +227,14 @@ class Notify if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($obj) { - $newval2=trim($obj->email); - $isvalid=isValidEmail($newval2); + $newval2 = trim($obj->email); + $isvalid = isValidEmail($newval2); if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid); } $i++; @@ -243,49 +243,49 @@ class Notify else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } } } - if (! $error) + if (!$error) { if (in_array('global', $scope)) { // List of notifications enabled for fixed email - foreach($conf->global as $key => $val) + foreach ($conf->global as $key => $val) { if ($notifcode) { - if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; } else { - if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; } $threshold = (float) $reg[1]; if ($valueforthreshold < $threshold) continue; - $tmpemail=explode(',', $val); - foreach($tmpemail as $key2 => $val2) + $tmpemail = explode(',', $val); + foreach ($tmpemail as $key2 => $val2) { - $newval2=trim($val2); + $newval2 = trim($val2); if ($newval2 == '__SUPERVISOREMAIL__') { if ($user->fk_user > 0) { - $tmpuser=new User($this->db); + $tmpuser = new User($this->db); $tmpuser->fetch($user->fk_user); - if ($tmpuser->email) $newval2=trim($tmpuser->email); - else $newval2=''; + if ($tmpuser->email) $newval2 = trim($tmpuser->email); + else $newval2 = ''; } - else $newval2=''; + else $newval2 = ''; } if ($newval2) { - $isvalid=isValidEmail($newval2, 0); - if (empty($resarray[$newval2])) $resarray[$newval2]=array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid); + $isvalid = isValidEmail($newval2, 0); + if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid); } } } @@ -311,17 +311,17 @@ class Notify */ public function send($notifcode, $object, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array()) { - global $user,$conf,$langs,$mysoc; + global $user, $conf, $langs, $mysoc; global $hookmanager; global $dolibarr_main_url_root; - if (! in_array($notifcode, $this->arrayofnotifsupported)) return 0; + if (!in_array($notifcode, $this->arrayofnotifsupported)) return 0; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('notification')); @@ -409,77 +409,77 @@ class Notify { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($obj->default_lang); - $outputlangs->loadLangs(array("main","other")); + $outputlangs->loadLangs(array("main", "other")); } - $subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification").($projtitle?' '.$projtitle:''); + $subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : ''); switch ($notifcode) { case 'BILL_VALIDATE': - $link='/compta/facture/card.php?facid='.$object->id; + $link = '/compta/facture/card.php?facid='.$object->id; $dir_output = $conf->facture->dir_output; $object_type = 'facture'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoiceValidated", $newref); break; case 'BILL_PAYED': - $link='/compta/facture/card.php?facid='.$object->id; + $link = '/compta/facture/card.php?facid='.$object->id; $dir_output = $conf->facture->dir_output; $object_type = 'facture'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoicePayed", $newref); break; case 'ORDER_VALIDATE': - $link='/commande/card.php?id='.$object->id; + $link = '/commande/card.php?id='.$object->id; $dir_output = $conf->commande->dir_output; $object_type = 'order'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextOrderValidated", $newref); break; case 'PROPAL_VALIDATE': - $link='/comm/propal/card.php?id='.$object->id; + $link = '/comm/propal/card.php?id='.$object->id; $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalValidated", $newref); break; case 'PROPAL_CLOSE_SIGNED': - $link='/comm/propal/card.php?id='.$object->id; + $link = '/comm/propal/card.php?id='.$object->id; $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $newref); break; case 'FICHINTER_ADD_CONTACT': - $link='/fichinter/card.php?id='.$object->id; + $link = '/fichinter/card.php?id='.$object->id; $dir_output = $conf->ficheinter->dir_output; $object_type = 'ficheinter'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $newref); break; case 'FICHINTER_VALIDATE': - $link='/fichinter/card.php?id='.$object->id; + $link = '/fichinter/card.php?id='.$object->id; $dir_output = $conf->ficheinter->dir_output; $object_type = 'ficheinter'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionValidated", $newref); break; case 'ORDER_SUPPLIER_VALIDATE': - $link='/fourn/commande/card.php?id='.$object->id; + $link = '/fourn/commande/card.php?id='.$object->id; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $newref, $user->getFullName($outputlangs)); - $mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $newref, $user->getFullName($outputlangs)); + $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_APPROVE': - $link='/fourn/commande/card.php?id='.$object->id; + $link = '/fourn/commande/card.php?id='.$object->id; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $newref, $user->getFullName($outputlangs)); - $mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $newref, $user->getFullName($outputlangs)); + $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_REFUSE': - $link='/fourn/commande/card.php?id='.$object->id; + $link = '/fourn/commande/card.php?id='.$object->id; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $newref, $user->getFullName($outputlangs)); - $mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $newref, $user->getFullName($outputlangs)); + $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'SHIPPING_VALIDATE': $dir_output = $conf->expedition->dir_output.'/sending/'; @@ -509,7 +509,7 @@ class Notify } $ref = dol_sanitizeFileName($newref); $pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; - if (! dol_is_file($pdf_path)) + if (!dol_is_file($pdf_path)) { // We can't add PDF as it is not generated yet. $filepdf = ''; @@ -520,17 +520,17 @@ class Notify } $message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name)."\n"; - $message.= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; - $message.= "\n"; - $message.= $mesg; - if ($link) $message.= "\n" . $urlwithroot . $link; + $message .= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; + $message .= "\n"; + $message .= $mesg; + if ($link) $message .= "\n".$urlwithroot.$link; - $parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); - $reshook=$hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); + $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { - if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject']; - if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message']; + if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject']; + if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message']; } $mailfile = new CMailFile( @@ -556,13 +556,13 @@ class Notify { if ($obj->type_target == 'touserid') { $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)"; - $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; + $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)"; - $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; + $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; } - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { dol_print_error($this->db); } @@ -570,7 +570,7 @@ class Notify else { $error++; - $this->errors[]=$mailfile->error; + $this->errors[] = $mailfile->error; } } else @@ -588,17 +588,17 @@ class Notify else { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); dol_syslog("Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR); return -1; } // Check notification using fixed email - if (! $error) + if (!$error) { - foreach($conf->global as $key => $val) + foreach ($conf->global as $key => $val) { - if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; $threshold = (float) $reg[1]; if (!empty($object->total_ht) && $object->total_ht <= $threshold) @@ -607,7 +607,7 @@ class Notify continue; } - $param='NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1]; + $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1]; $sendto = $conf->global->$param; $notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid'); @@ -617,82 +617,82 @@ class Notify $link = ''; $num++; - $subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification").($projtitle?' '.$projtitle:''); + $subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : ''); switch ($notifcode) { case 'BILL_VALIDATE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->facture->dir_output; $object_type = 'facture'; $mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated", $link); break; case 'BILL_PAYED': - $link ='' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->facture->dir_output; $object_type = 'facture'; $mesg = $langs->transnoentitiesnoconv("EMailTextInvoicePayed", $link); break; case 'ORDER_VALIDATE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->commande->dir_output; $object_type = 'order'; $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated", $link); break; case 'PROPAL_VALIDATE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated", $link); break; case 'PROPAL_CLOSE_SIGNED': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $link); break; case 'FICHINTER_ADD_CONTACT': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->facture->dir_output; $object_type = 'ficheinter'; $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $link); break; case 'FICHINTER_VALIDATE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->facture->dir_output; $object_type = 'ficheinter'; $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated", $link); break; case 'ORDER_SUPPLIER_VALIDATE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $link, $user->getFullName($langs)); - $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $link, $user->getFullName($langs)); + $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_APPROVE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); - $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); + $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_APPROVE2': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); - $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); + $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_REFUSE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->dir_output.'/commande/'; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $link, $user->getFullName($langs)); - $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $link, $user->getFullName($langs)); + $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'SHIPPING_VALIDATE': $dir_output = $conf->expedition->dir_output.'/sending/'; @@ -722,7 +722,7 @@ class Notify } $ref = dol_sanitizeFileName($newref); $pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; - if (! dol_is_file($pdf_path)) + if (!dol_is_file($pdf_path)) { // We can't add PDF as it is not generated yet. $filepdf = ''; @@ -733,9 +733,9 @@ class Notify } $message = $langs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name)."\n"; - $message.= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; - $message.= "\n"; - $message.= $mesg; + $message .= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; + $message .= "\n"; + $message .= $mesg; //if ($link) $message.= "\n" . $urlwithroot . $link; // link already added around the ref into the text $message = nl2br($message); @@ -743,28 +743,28 @@ class Notify // Replace keyword __SUPERVISOREMAIL__ if (preg_match('/__SUPERVISOREMAIL__/', $sendto)) { - $newval=''; + $newval = ''; if ($user->fk_user > 0) { - $supervisoruser=new User($this->db); + $supervisoruser = new User($this->db); $supervisoruser->fetch($user->fk_user); - if ($supervisoruser->email) $newval=trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>'); + if ($supervisoruser->email) $newval = trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>'); } dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval); $sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto); - $sendto = preg_replace('/,\s*,/', ',', $sendto); // in some case you can have $sendto like "email, __SUPERVISOREMAIL__ , otheremail" then you have "email, , othermail" and it's not valid - $sendto = preg_replace('/^[\s,]+/', '', $sendto); // Clean start of string - $sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string + $sendto = preg_replace('/,\s*,/', ',', $sendto); // in some case you can have $sendto like "email, __SUPERVISOREMAIL__ , otheremail" then you have "email, , othermail" and it's not valid + $sendto = preg_replace('/^[\s,]+/', '', $sendto); // Clean start of string + $sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string } if ($sendto) { - $parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); - $reshook=$hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); + $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { - if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject']; - if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message']; + if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject']; + if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message']; } $mailfile = new CMailFile( $subject, @@ -788,8 +788,8 @@ class Notify if ($mailfile->sendfile()) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)"; - $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')"; - if (! $this->db->query($sql)) + $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')"; + if (!$this->db->query($sql)) { dol_print_error($this->db); } @@ -797,13 +797,13 @@ class Notify else { $error++; - $this->errors[]=$mailfile->error; + $this->errors[] = $mailfile->error; } } } } - if (! $error) return $num; + if (!$error) return $num; else return -1 * $error; } } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 86f5043f1bf..fea8e204aeb 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1311,7 +1311,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref); // Add date of deposit - if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice.= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; + if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice .= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; } elseif ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 962d3ec9766..0c0c70b5708 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2099,8 +2099,8 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide if ($diffval >= 0) { // good $out .= '
'; - if(!empty($task->progress)) { - $out .= '
'; + if (!empty($task->progress)) { + $out .= '
'; } $out .= '
'; } diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index f052d6a55f8..22154d40d79 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -68,37 +68,37 @@ class doc_generic_order_odt extends ModelePDFCommandes global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -110,83 +110,83 @@ class doc_generic_order_odt extends ModelePDFCommandes */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
'; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
'; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '
'; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=count($listoffiles); + $texte .= count($listoffiles); //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
'; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -206,7 +206,7 @@ class doc_generic_order_odt extends ModelePDFCommandes public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -215,28 +215,28 @@ class doc_generic_order_odt extends ModelePDFCommandes } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); if ($conf->commande->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Commande($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -246,14 +246,14 @@ class doc_generic_order_odt extends ModelePDFCommandes $dir = $conf->commande->multidir_output[$object->entity]; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -261,25 +261,25 @@ class doc_generic_order_odt extends ModelePDFCommandes if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -289,20 +289,20 @@ class doc_generic_order_odt extends ModelePDFCommandes // If CUSTOMER contact defined on order, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use @@ -311,11 +311,11 @@ class doc_generic_order_odt extends ModelePDFCommandes } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, @@ -324,15 +324,15 @@ class doc_generic_order_odt extends ModelePDFCommandes ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='ORDER_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'ORDER_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -342,15 +342,15 @@ class doc_generic_order_odt extends ModelePDFCommandes $srctemplatepath, array( 'PATH_TO_TMP' => $conf->commande->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -365,31 +365,31 @@ class doc_generic_order_odt extends ModelePDFCommandes try { $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -402,7 +402,7 @@ class doc_generic_order_odt extends ModelePDFCommandes $odfHandler->setVars($key, $value, true, 'UTF-8'); } } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -414,7 +414,7 @@ class doc_generic_order_odt extends ModelePDFCommandes try { $listlines = $odfHandler->setSegment('lines'); } - catch(OdfException $e) + catch (OdfException $e) { // We may arrive here if tags for lines not present into template $foundtagforlines = 0; @@ -424,22 +424,22 @@ class doc_generic_order_odt extends ModelePDFCommandes { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -449,21 +449,21 @@ class doc_generic_order_odt extends ModelePDFCommandes $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -471,15 +471,15 @@ class doc_generic_order_odt extends ModelePDFCommandes // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); - }catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -488,27 +488,27 @@ class doc_generic_order_odt extends ModelePDFCommandes try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index 62634ec07b8..12b8fc604f6 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -26,7 +26,7 @@ * \brief Fichier contenant la classe du modele de numerotation de reference de commande Saphir */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/commande/modules_commande.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; /** @@ -38,7 +38,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error message @@ -48,7 +48,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes /** * @var string name */ - public $name='Saphir'; + public $name = 'Saphir'; /** @@ -65,28 +65,28 @@ class mod_commande_saphir extends ModeleNumRefCommandes $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order")); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -98,17 +98,17 @@ class mod_commande_saphir extends ModeleNumRefCommandes */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; - $old_code_client=$mysoc->code_client; - $old_code_type=$mysoc->typent_code; - $mysoc->code_client='CCCCCCCCCC'; - $mysoc->typent_code='TTTTTTTTTT'; + $old_code_client = $mysoc->code_client; + $old_code_type = $mysoc->typent_code; + $mysoc->code_client = 'CCCCCCCCCC'; + $mysoc->typent_code = 'TTTTTTTTTT'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client=$old_code_client; - $mysoc->typent_code=$old_code_type; + $mysoc->code_client = $old_code_client; + $mysoc->typent_code = $old_code_type; - if (! $numExample) + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } @@ -124,16 +124,16 @@ class mod_commande_saphir extends ModeleNumRefCommandes */ public function getNextValue($objsoc, $object) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // We get cursor rule - $mask=$conf->global->COMMANDE_SAPHIR_MASK; + $mask = $conf->global->COMMANDE_SAPHIR_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } @@ -142,7 +142,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes $date = ($object->date_commande ? $object->date_commande : $object->date); - $numFinal=get_next_value($db, $mask, 'commande', 'ref', '', $objsoc, $date, 'next', false, null, $entity); + $numFinal = get_next_value($db, $mask, 'commande', 'ref', '', $objsoc, $date, 'next', false, null, $entity); return $numFinal; } diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 54fd4ebff57..ca2146703bd 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -67,37 +67,37 @@ class doc_generic_contract_odt extends ModelePDFContract global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'CONTRACT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'CONTRACT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva CONTRACT_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva CONTRACT_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -109,7 +109,7 @@ class doc_generic_contract_odt extends ModelePDFContract */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page $langs->loadLangs(array('companies', 'errors')); @@ -117,66 +117,66 @@ class doc_generic_contract_odt extends ModelePDFContract $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
'; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
'; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '
'; // Scan directories if (count($listofdir)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + $texte .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; } // Add select to upload a new template file. TODO Copy this feature on other admin pages. - $texte.= '
'.$langs->trans("UploadNewTemplate").' '; - $texte.= ''; - $texte.= ''; - $texte.= '
'; + $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $texte.= '
'; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -196,7 +196,7 @@ class doc_generic_contract_odt extends ModelePDFContract public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -205,17 +205,17 @@ class doc_generic_contract_odt extends ModelePDFContract } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); @@ -223,11 +223,11 @@ class doc_generic_contract_odt extends ModelePDFContract if ($conf->contrat->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Contrat($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -237,14 +237,14 @@ class doc_generic_contract_odt extends ModelePDFContract $dir = $conf->contrat->dir_output; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -252,26 +252,26 @@ class doc_generic_contract_odt extends ModelePDFContract if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -281,19 +281,19 @@ class doc_generic_contract_odt extends ModelePDFContract // If CUSTOMER contact defined on contract, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) { + $contactobject = null; + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; @@ -303,7 +303,7 @@ class doc_generic_contract_odt extends ModelePDFContract } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } $object->fetch_optionals(); @@ -311,15 +311,15 @@ class doc_generic_contract_odt extends ModelePDFContract // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); // complete with vars not set as properties by get_substitutionarray_each_var_object - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); // complete with vars not set as properties by get_substitutionarray_each_var_object + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in order as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $substitutionarray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); complete_substitutions_array($substitutionarray, $outputlangs, $object); @@ -327,15 +327,15 @@ class doc_generic_contract_odt extends ModelePDFContract $tmparray = $substitutionarray; // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='CONTRACT_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'CONTRACT_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $tmparray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $tmparray); } @@ -346,15 +346,15 @@ class doc_generic_contract_odt extends ModelePDFContract $srctemplatepath, array( 'PATH_TO_TMP' => $conf->contrat->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -374,7 +374,7 @@ class doc_generic_contract_odt extends ModelePDFContract dol_syslog($e->getMessage(), LOG_INFO); } - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -400,7 +400,7 @@ class doc_generic_contract_odt extends ModelePDFContract try { $listlines = $odfHandler->setSegment('lines'); } - catch(OdfException $e) + catch (OdfException $e) { // We may arrive here if tags for lines not present into template $foundtagforlines = 0; @@ -410,22 +410,22 @@ class doc_generic_contract_odt extends ModelePDFContract { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -435,36 +435,36 @@ class doc_generic_contract_odt extends ModelePDFContract $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); return -1; } } @@ -472,25 +472,25 @@ class doc_generic_contract_odt extends ModelePDFContract try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); return -1; } } - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index e441cc81365..b9bfa0a35d6 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -46,17 +46,17 @@ class mod_contract_magre extends ModelNumRefContracts * @deprecated * @see $name */ - public $nom='Magre'; + public $nom = 'Magre'; /** * @var string name */ - public $name='Magre'; + public $name = 'Magre'; /** * @var int Automatic numbering */ - public $code_auto=1; + public $code_auto = 1; /** * Return default description of numbering model @@ -65,31 +65,31 @@ class mod_contract_magre extends ModelNumRefContracts */ public function info() { - global $conf,$langs, $db; + global $conf, $langs, $db; $langs->load("bills"); $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Contract"), $langs->transnoentities("Contract")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Contract"), $langs->transnoentities("Contract")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Contract"), $langs->transnoentities("Contract")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Contract"), $langs->transnoentities("Contract")); + $tooltip .= $langs->trans("GenericMaskCodes5"); - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' 
'; - $texte.= '
'; + $texte .= ''.$langs->trans("Mask").':'; + $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte .= '  '; + $texte .= ''; + $texte .= ''; + $texte .= ''; return $texte; } diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 65b7f5011cc..0e9db902662 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -118,56 +118,56 @@ class pdf_rouget extends ModelePdfExpedition */ public function __construct($db = 0) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; $this->db = $db; $this->name = "rouget"; $this->description = $langs->trans("DocumentModelStandardPDF"); $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Display logo + $this->option_logo = 1; // Display logo // Get source company - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined // Define position of columns - $this->posxdesc=$this->marge_gauche+1; - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78; - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56; - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28; - $this->posxpuht=$this->page_largeur - $this->marge_droite; + $this->posxdesc = $this->marge_gauche + 1; + $this->posxweightvol = $this->page_largeur - $this->marge_droite - 78; + $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 56; + $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28; + $this->posxpuht = $this->page_largeur - $this->marge_droite; if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) { // Show also the prices - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; - $this->posxpuht=$this->page_largeur - $this->marge_droite - 40; - $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20; + $this->posxweightvol = $this->page_largeur - $this->marge_droite - 118; + $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96; + $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68; + $this->posxpuht = $this->page_largeur - $this->marge_droite - 40; + $this->posxtotalht = $this->page_largeur - $this->marge_droite - 20; } - if(!empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) $this->posxweightvol = $this->posxqtyordered; + if (!empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) $this->posxweightvol = $this->posxqtyordered; - $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + $this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images // To work with US executive format if ($this->page_largeur < 210) { - $this->posxweightvol-=20; - $this->posxpicture-=20; - $this->posxqtyordered-=20; - $this->posxqtytoship-=20; + $this->posxweightvol -= 20; + $this->posxpicture -= 20; + $this->posxqtyordered -= 20; + $this->posxqtytoship -= 20; } - if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { + if (!empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); $this->posxqtyordered = $this->posxqtytoship; @@ -189,13 +189,13 @@ class pdf_rouget extends ModelePdfExpedition public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$conf,$langs,$hookmanager; + global $user, $conf, $langs, $hookmanager; $object->fetch_thirdparty(); - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); @@ -203,49 +203,49 @@ class pdf_rouget extends ModelePdfExpedition $nblines = count($object->lines); // Loop on each lines to detect if there is at least one image to show - $realpatharray=array(); - if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) + $realpatharray = array(); + if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) { $objphoto = new Product($this->db); - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if (empty($object->lines[$i]->fk_product)) continue; $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/"; + $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; - $realpath=''; + $realpath = ''; foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo if ($obj['photo_vignette']) { - $filename= $obj['photo_vignette']; + $filename = $obj['photo_vignette']; } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } $realpath = $dir.$filename; break; } - if ($realpath) $realpatharray[$i]=$realpath; + if ($realpath) $realpatharray[$i] = $realpath; } } - if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; + if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol; if ($conf->expedition->dir_output) { @@ -253,20 +253,20 @@ class pdf_rouget extends ModelePdfExpedition if ($object->specimen) { $dir = $conf->expedition->dir_output."/sending"; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $expref = dol_sanitizeFileName($object->ref); - $dir = $conf->expedition->dir_output."/sending/" . $expref; - $file = $dir . "/" . $expref . ".pdf"; + $dir = $conf->expedition->dir_output."/sending/".$expref; + $file = $dir."/".$expref.".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -274,25 +274,25 @@ class pdf_rouget extends ModelePdfExpedition if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Set nblines with the new facture lines content after hook $nblines = count($object->lines); - $pdf=pdf_getInstance($this->format); + $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); - $heightforinfotot = 8; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; + $heightforinfotot = 8; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -302,14 +302,14 @@ class pdf_rouget extends ModelePdfExpedition } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -319,21 +319,21 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment")); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 90; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); $tab_height = 130; $tab_height_newpage = 150; @@ -347,51 +347,51 @@ class pdf_rouget extends ModelePdfExpedition $tab_top = 88; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); - $height_incoterms=$nexY-$tab_top; + $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; $height_incoterms += 4; } } - if (! empty($object->note_public) || ! empty($object->tracking_number)) + if (!empty($object->note_public) || !empty($object->tracking_number)) { $tab_top = 88 + $height_incoterms; $tab_top_alt = $tab_top; $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L'); + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L'); $tab_top_alt = $pdf->GetY(); //$tab_top_alt += 1; // Tracking number - if (! empty($object->tracking_number)) + if (!empty($object->tracking_number)) { $object->getUrlTrackingStatus($object->tracking_number); - if (! empty($object->tracking_url)) + if (!empty($object->tracking_url)) { if ($object->shipping_method_id > 0) { // Get code using getLabelFromKey - $code=$outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); - $label=''; - if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."
"; - $label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); + $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); + $label = ''; + if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."
"; + $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); //var_dump($object->tracking_url != $object->tracking_number);exit; if ($object->tracking_url != $object->tracking_number) { - $label.=" : "; - $label.=$object->tracking_url; + $label .= " : "; + $label .= $object->tracking_url; } $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L'); + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); $tab_top_alt = $pdf->GetY(); } @@ -399,25 +399,25 @@ class pdf_rouget extends ModelePdfExpedition } // Notes - if (! empty($object->note_public)) + if (!empty($object->note_public)) { - $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); + $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); } $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $height_note = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } else { - $height_note=0; + $height_note = 0; } $iniY = $tab_top + 7; @@ -428,87 +428,87 @@ class pdf_rouget extends ModelePdfExpedition for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it - $imglinesize=array(); - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $imglinesize = array(); + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); - $showpricebeforepagebreak=1; - $posYAfterImage=0; - $posYAfterDescription=0; + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposbefore+1); + $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } if (isset($imglinesize['width']) && isset($imglinesize['height'])) { - $curX = $this->posxpicture-1; - $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + $curX = $this->posxpicture - 1; + $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage=$curY+$imglinesize['height']; + $posYAfterImage = $curY + $imglinesize['height']; } // Description of product line - $curX = $this->posxdesc-1; + $curX = $this->posxdesc - 1; $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc); + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc); + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak { $pdf->commitTransaction(); } - $posYAfterDescription=$pdf->GetY(); + $posYAfterDescription = $pdf->GetY(); $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { @@ -520,23 +520,23 @@ class pdf_rouget extends ModelePdfExpedition $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetXY($this->posxweightvol, $curY); - $weighttxt=''; + $weighttxt = ''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { - $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units); + $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units); } - $voltxt=''; + $voltxt = ''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { - $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0); + $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0); } if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) { - $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt, 0, 0, false, true, 'C'); + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '
' : '').$voltxt, 0, 0, false, true, 'C'); //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt,'','C'); } @@ -552,25 +552,25 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped, '', 'C'); } - if(!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) + if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $curY); - $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R'); + $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R'); $pdf->SetXY($this->posxtotalht, $curY); $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs), '', 'R'); } - $nexY+=3; - if ($weighttxt && $voltxt) $nexY+=2; + $nexY += 3; + if ($weighttxt && $voltxt) $nexY += 2; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1); + $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1); $pdf->SetLineStyle(array('dash'=>0)); } @@ -589,10 +589,10 @@ class pdf_rouget extends ModelePdfExpedition $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -605,7 +605,7 @@ class pdf_rouget extends ModelePdfExpedition $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -615,16 +615,16 @@ class pdf_rouget extends ModelePdfExpedition if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); + $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); @@ -636,31 +636,31 @@ class pdf_rouget extends ModelePdfExpedition // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); return 0; } } @@ -680,9 +680,9 @@ class pdf_rouget extends ModelePdfExpedition protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable - global $conf,$mysoc; + global $conf, $mysoc; - $sign=1; + $sign = 1; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -691,7 +691,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFont('', 'B', $default_font_size - 1); // Tableau total - $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol; + $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol; /*if ($this->page_largeur < 210) // To work with US executive format { $col2x-=20; @@ -699,33 +699,33 @@ class pdf_rouget extends ModelePdfExpedition if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); - $useborder=0; + $useborder = 0; $index = 0; - $totalWeighttoshow=''; - $totalVolumetoshow=''; + $totalWeighttoshow = ''; + $totalVolumetoshow = ''; // Load dim data - $tmparray=$object->getTotalWeightVolume(); - $totalWeight=$tmparray['weight']; - $totalVolume=$tmparray['volume']; - $totalOrdered=$tmparray['ordered']; - $totalToShip=$tmparray['toship']; + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; + $totalOrdered = $tmparray['ordered']; + $totalToShip = $tmparray['toship']; // Set trueVolume and volume_units not currently stored into database if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); - $object->volume_units=$object->size_units * 3; + $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); + $object->volume_units = $object->size_units * 3; } - if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); - if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); - if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); - if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); + if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); + if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); + if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); + if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { @@ -765,7 +765,7 @@ class pdf_rouget extends ModelePdfExpedition $index++; } - if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; + if (!$totalWeighttoshow && !$totalVolumetoshow) $index++; } $pdf->SetTextColor(0, 0, 0); @@ -791,8 +791,8 @@ class pdf_rouget extends ModelePdfExpedition global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -801,61 +801,61 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFont('', '', $default_font_size - 2); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); - $pdf->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L'); } if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) { - $pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height); + $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxweightvol-1, $tab_top+1); + $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C'); } } if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { - $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); + $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqtyordered-1, $tab_top+1); + $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1); $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C'); } } if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) { - $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); + $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqtytoship, $tab_top+1); + $pdf->SetXY($this->posxqtytoship, $tab_top + 1); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"), '', 'C'); } } if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) { - $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); + $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxpuht-1, $tab_top+1); + $pdf->SetXY($this->posxpuht - 1, $tab_top + 1); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); } - $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); + $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxtotalht-1, $tab_top+1); + $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1); $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); } } @@ -873,7 +873,7 @@ class pdf_rouget extends ModelePdfExpedition */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; $langs->load("orders"); @@ -882,7 +882,7 @@ class pdf_rouget extends ModelePdfExpedition pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==0 && (! empty($conf->global->SHIPPING_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK); } @@ -893,19 +893,19 @@ class pdf_rouget extends ModelePdfExpedition $w = 110; - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-$w; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - $w; $pdf->SetXY($this->marge_gauche, $posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) { if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { @@ -917,21 +917,21 @@ class pdf_rouget extends ModelePdfExpedition } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } // Show barcode - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { - $posx=105; + $posx = 105; } else { - $posx=$this->marge_gauche+3; + $posx = $this->marge_gauche + 3; } //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); @@ -939,7 +939,7 @@ class pdf_rouget extends ModelePdfExpedition } $pdf->SetDrawColor(128, 128, 128); - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); @@ -947,67 +947,67 @@ class pdf_rouget extends ModelePdfExpedition } - $posx=$this->page_largeur - $w - $this->marge_droite; - $posy=$this->marge_haute; + $posx = $this->page_largeur - $w - $this->marge_droite; + $posy = $this->marge_haute; $pdf->SetFont('', 'B', $default_font_size + 2); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title=$outputlangs->transnoentities("SendingSheet"); + $title = $outputlangs->transnoentities("SendingSheet"); $pdf->MultiCell($w, 4, $title, '', 'R'); $pdf->SetFont('', '', $default_font_size + 1); - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R'); + $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending")." : ".$object->ref, '', 'R'); // Date planned delivery - if (! empty($object->date_delivery)) + if (!empty($object->date_delivery)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R'); } - if (! empty($object->thirdparty->code_client)) + if (!empty($object->thirdparty->code_client)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } $pdf->SetFont('', '', $default_font_size + 3); - $Yoff=25; + $Yoff = 25; // Add list of linked orders - $origin = $object->origin; - $origin_id = $object->origin_id; + $origin = $object->origin; + $origin_id = $object->origin_id; // TODO move to external function - if (! empty($conf->$origin->enabled)) // commonly $origin='commande' + if (!empty($conf->$origin->enabled)) // commonly $origin='commande' { $outputlangs->load('orders'); $classname = ucfirst($origin); $linkedobject = new $classname($this->db); - $result=$linkedobject->fetch($origin_id); + $result = $linkedobject->fetch($origin_id); if ($result >= 0) { //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects $pdf->SetFont('', '', $default_font_size - 2); - $text=$linkedobject->ref; - if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; - $Yoff = $Yoff+8; + $text = $linkedobject->ref; + if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')'; + $Yoff = $Yoff + 8; $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); - $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); - $Yoff = $Yoff+3; + $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R'); + $Yoff = $Yoff + 3; $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R'); } @@ -1016,30 +1016,30 @@ class pdf_rouget extends ModelePdfExpedition if ($showaddress) { // Sender properties - $carac_emetteur=''; + $carac_emetteur = ''; // Add internal contact of origin element if defined - $arrayidcontact=array(); - if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = array(); + if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user(reset($arrayidcontact)); - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; - $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; + $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -1048,24 +1048,24 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFillColor(255, 255, 255); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); - $pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L'); + $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L'); // If SHIPPING contact defined, we use it - $usecontact=false; - $arrayidcontact=$object->$origin->getIdContact('external', 'SHIPPING'); + $usecontact = false; + $arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } //Recipient name @@ -1076,26 +1076,26 @@ class pdf_rouget extends ModelePdfExpedition $thirdparty = $object->thirdparty; } - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact)?$object->contact:null), $usecontact, 'targetwithdetails', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object); // Show recipient - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; - $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L'); @@ -1103,7 +1103,7 @@ class pdf_rouget extends ModelePdfExpedition // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } @@ -1123,7 +1123,7 @@ class pdf_rouget extends ModelePdfExpedition protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } } diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index c2fec907775..5e0cc4d4076 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -66,37 +66,37 @@ class doc_generic_product_odt extends ModelePDFProduct global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'PRODUCT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'PRODUCT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva PRODUCT_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva PRODUCT_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -111,60 +111,60 @@ class doc_generic_product_odt extends ModelePDFProduct global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) { - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; } - $texte.= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PRODUCT_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PRODUCT_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
'; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
'; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '
'; // Scan directories if (count($listofdir)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + $texte .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; /*if ($conf->global->MAIN_PRODUCT_CHOOSE_ODT_DOCUMENT > 0) { @@ -192,15 +192,15 @@ class doc_generic_product_odt extends ModelePDFProduct }*/ } - $texte.= '
'; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -220,7 +220,7 @@ class doc_generic_product_odt extends ModelePDFProduct public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $product,$langs,$conf,$mysoc,$hookmanager,$user; + global $product, $langs, $conf, $mysoc, $hookmanager, $user; if (empty($srctemplatepath)) { @@ -229,17 +229,17 @@ class doc_generic_product_odt extends ModelePDFProduct } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); @@ -247,11 +247,11 @@ class doc_generic_product_odt extends ModelePDFProduct if ($conf->product->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Product($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -264,14 +264,14 @@ class doc_generic_product_odt extends ModelePDFProduct $dir = $conf->product->dir_output; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -279,26 +279,26 @@ class doc_generic_product_odt extends ModelePDFProduct if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -308,20 +308,20 @@ class doc_generic_product_odt extends ModelePDFProduct // If CUSTOMER contact defined on product, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; @@ -331,10 +331,10 @@ class doc_generic_product_odt extends ModelePDFProduct } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, @@ -343,15 +343,15 @@ class doc_generic_product_odt extends ModelePDFProduct ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='product_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'product_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -361,7 +361,7 @@ class doc_generic_product_odt extends ModelePDFProduct $srctemplatepath, array( 'PATH_TO_TMP' => $conf->product->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) @@ -369,7 +369,7 @@ class doc_generic_product_odt extends ModelePDFProduct } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -394,22 +394,22 @@ class doc_generic_product_odt extends ModelePDFProduct $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); //$array_objet=$this->get_substitutionarray_object($object,$outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -431,15 +431,15 @@ class doc_generic_product_odt extends ModelePDFProduct try { $listlines = $odfHandler->setSegment('supplierprices'); - if(!empty($object->supplierprices)){ + if (!empty($object->supplierprices)) { foreach ($object->supplierprices as $supplierprice) { $array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs); complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$array_lines,'line'=>$supplierprice); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($array_lines as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$array_lines, 'line'=>$supplierprice); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($array_lines as $key => $val) { try { @@ -461,34 +461,34 @@ class doc_generic_product_odt extends ModelePDFProduct } catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -497,26 +497,26 @@ class doc_generic_product_odt extends ModelePDFProduct try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php index cb6a8411543..ba6329004e3 100644 --- a/htdocs/core/modules/product/mod_codeproduct_elephant.php +++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php @@ -39,26 +39,26 @@ class mod_codeproduct_elephant extends ModeleProductCode * @deprecated * @see $name */ - public $nom='Elephant'; + public $nom = 'Elephant'; /** * @var string model name */ - public $name='Elephant'; + public $name = 'Elephant'; - public $code_modifiable; // Code modifiable + public $code_modifiable; // Code modifiable - public $code_modifiable_invalide; // Code modifiable si il est invalide + public $code_modifiable_invalide; // Code modifiable si il est invalide - public $code_modifiable_null; // Code modifiables si il est null + public $code_modifiable_null; // Code modifiables si il est null - public $code_null; // Code facultatif + public $code_null; // Code facultatif /** * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var int Automatic numbering @@ -99,36 +99,36 @@ class mod_codeproduct_elephant extends ModeleProductCode $langs->load("products"); - $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); + $disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Product"), $langs->transnoentities("Product")); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4c"); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Product"), $langs->transnoentities("Product")); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4c"); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix customers - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; // Parametrage du prefix suppliers - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").' ('.$langs->trans("ProductCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").' ('.$langs->trans("ProductCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'   
'.$langs->trans("Mask").' ('.$langs->trans("ServiceCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").' ('.$langs->trans("ServiceCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -147,27 +147,27 @@ class mod_codeproduct_elephant extends ModeleProductCode if ($type == 0 || $type == -1) { $exampleproduct = $this->getNextValue($objproduct, 0); - if (! $exampleproduct) + if (!$exampleproduct) { $exampleproduct = $langs->trans('NotConfigured'); } - if($exampleproduct=="ErrorBadMask") + if ($exampleproduct == "ErrorBadMask") { $langs->load("errors"); - $exampleproduct=$langs->trans($exampleproduct); + $exampleproduct = $langs->trans($exampleproduct); } } if ($type == 1 || $type == -1) { $exampleservice = $this->getNextValue($objproduct, 1); - if (! $exampleservice) + if (!$exampleservice) { $exampleservice = $langs->trans('NotConfigured'); } - if($exampleservice=="ErrorBadMask") + if ($exampleservice == "ErrorBadMask") { $langs->load("errors"); - $exampleservice=$langs->trans($exampleservice); + $exampleservice = $langs->trans($exampleservice); } } @@ -185,24 +185,24 @@ class mod_codeproduct_elephant extends ModeleProductCode */ public function getNextValue($objproduct = 0, $type = -1) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Get Mask value $mask = ''; - if ($type == 0 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)) + if ($type == 0 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)) $mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; - elseif ($type == 1 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)) + elseif ($type == 1 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)) $mask = $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; if (empty($mask)) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return ''; } - $field='';$where=''; + $field = ''; $where = ''; if ($type == 0) { $field = 'ref'; @@ -215,14 +215,14 @@ class mod_codeproduct_elephant extends ModeleProductCode } else return -1; - $now=dol_now(); + $now = dol_now(); - if (! empty($conf->global->PRODUCT_ELEPHANT_ADD_WHERE)) + if (!empty($conf->global->PRODUCT_ELEPHANT_ADD_WHERE)) { $where = ' AND ('.dol_string_nospecial(dol_string_unaccent($conf->global->PRODUCT_ELEPHANT_ADD_WHERE), '_', array(',', '@', '"', "|", ";", ":")).')'; } - $numFinal=get_next_value($db, $mask, 'product', $field, $where, '', $now); + $numFinal = get_next_value($db, $mask, 'product', $field, $where, '', $now); return $numFinal; } @@ -267,32 +267,32 @@ class mod_codeproduct_elephant extends ModeleProductCode { global $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $result=0; + $result = 0; $code = strtoupper(trim($code)); if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) { - $result=0; + $result = 0; } - elseif (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) + elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) { - $result=-2; + $result = -2; } else { // Get Mask value $mask = ''; - if ($type==0) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)?'':$conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; - if ($type==1) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)?'':$conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; - if (! $mask) + if ($type == 0) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT) ? '' : $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; + if ($type == 1) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE) ? '' : $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return -5; } - $result=check_value($mask, $code); + $result = check_value($mask, $code); if (is_string($result)) { $this->error = $result; @@ -318,10 +318,10 @@ class mod_codeproduct_elephant extends ModeleProductCode { // phpcs:enable $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE ref = '".$code."'"; - if ($product->id > 0) $sql.= " AND rowid <> ".$product->id; + $sql .= " WHERE ref = '".$code."'"; + if ($product->id > 0) $sql .= " AND rowid <> ".$product->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) == 0) diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 4219d8100cb..9bf0d313ae8 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -22,7 +22,7 @@ * \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/modules_project.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; /** @@ -34,7 +34,7 @@ class mod_project_universal extends ModeleNumRefProjects * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error code (or message) @@ -46,12 +46,12 @@ class mod_project_universal extends ModeleNumRefProjects * @deprecated * @see name */ - public $nom='Universal'; + public $nom = 'Universal'; /** * @var string model name */ - public $name='Universal'; + public $name = 'Universal'; /** @@ -64,33 +64,33 @@ class mod_project_universal extends ModeleNumRefProjects global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("projects","admin")); + $langs->loadLangs(array("projects", "admin")); $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project")); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -102,14 +102,14 @@ class mod_project_universal extends ModeleNumRefProjects */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; - $old_code_client=$mysoc->code_client; - $mysoc->code_client='CCCCCCCCCC'; + $old_code_client = $mysoc->code_client; + $mysoc->code_client = 'CCCCCCCCCC'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client=$old_code_client; + $mysoc->code_client = $old_code_client; - if (! $numExample) + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } @@ -125,21 +125,21 @@ class mod_project_universal extends ModeleNumRefProjects */ public function getNextValue($objsoc, $project) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // On defini critere recherche compteur - $mask=$conf->global->PROJECT_UNIVERSAL_MASK; + $mask = $conf->global->PROJECT_UNIVERSAL_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } - $date=empty($project->date_c)?dol_now():$project->date_c; - $numFinal=get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); + $date = empty($project->date_c) ?dol_now() : $project->date_c; + $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); return $numFinal; } diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 98158e4cf05..a53e7647711 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -38,16 +38,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; -if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; -if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +if (!empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; /** @@ -84,37 +84,37 @@ class doc_generic_task_odt extends ModelePDFTask global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 0; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 0; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini + $this->emetteur = $mysoc; + if (!$this->emetteur->pays_code) $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini } @@ -132,7 +132,7 @@ class doc_generic_task_odt extends ModelePDFTask // phpcs:enable global $conf; - $resarray=array( + $resarray = array( $array_key.'_id'=>$object->id, $array_key.'_ref'=>$object->ref, $array_key.'_title'=>$object->title, @@ -150,7 +150,7 @@ class doc_generic_task_odt extends ModelePDFTask // Retrieve extrafields if (is_array($object->array_options) && count($object->array_options)) { - $extrafieldkey=$object->element; + $extrafieldkey = $object->element; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); @@ -341,83 +341,83 @@ class doc_generic_task_odt extends ModelePDFTask */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
'; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
'; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '
'; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=$nbofiles; + $texte .= $nbofiles; //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
'; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -434,7 +434,7 @@ class doc_generic_task_odt extends ModelePDFTask public function write_file($object, $outputlangs, $srctemplatepath) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -442,9 +442,9 @@ class doc_generic_task_odt extends ModelePDFTask return -1; } - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); @@ -452,32 +452,32 @@ class doc_generic_task_odt extends ModelePDFTask if ($conf->projet->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Task($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); return -1; } } - $project= new Project($this->db); + $project = new Project($this->db); $project->fetch($object->fk_project); $project->fetch_thirdparty(); - $dir = $conf->projet->dir_output. "/" . $project->ref. "/"; + $dir = $conf->projet->dir_output."/".$project->ref."/"; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { print '$dir'.$dir; if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -486,13 +486,13 @@ class doc_generic_task_odt extends ModelePDFTask if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.(ods|odt)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.(ods|odt)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; - $file=$dir.'/'.$newfiletmp.'.odt'; + $file = $dir.'/'.$newfiletmp.'.odt'; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -500,17 +500,17 @@ class doc_generic_task_odt extends ModelePDFTask dol_mkdir($conf->projet->dir_temp); - $socobject=$project->thirdparty; + $socobject = $project->thirdparty; // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Open and load template require_once ODTPHP_PATH.'odf.php'; @@ -519,15 +519,15 @@ class doc_generic_task_odt extends ModelePDFTask $srctemplatepath, array( 'PATH_TO_TMP' => $conf->projet->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); return -1; } // After construction $odfHandler->contentXml contains content and @@ -540,16 +540,16 @@ class doc_generic_task_odt extends ModelePDFTask // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($project, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_objet = $this->get_substitutionarray_object($project, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other); complete_substitutions_array($tmparray, $outputlangs, $object); - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -570,30 +570,30 @@ class doc_generic_task_odt extends ModelePDFTask try { // Security check - $socid=0; + $socid = 0; if (!empty($project->fk_soc)) $socid = $project->fk_soc; - $tmparray=$this->get_substitutionarray_tasks($object, $outputlangs); + $tmparray = $this->get_substitutionarray_tasks($object, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $odfHandler->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); - } catch(SegmentException $e) { + } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } // Replace tags of lines for contacts task - $sourcearray=array('internal','external'); - $contact_arrray=array(); + $sourcearray = array('internal', 'external'); + $contact_arrray = array(); foreach ($sourcearray as $source) { - $contact_temp=$object->liste_contact(-1, $source); + $contact_temp = $object->liste_contact(-1, $source); if ((is_array($contact_temp) && count($contact_temp) > 0)) { - $contact_arrray=array_merge($contact_arrray, $contact_temp); + $contact_arrray = array_merge($contact_arrray, $contact_temp); } } if ((is_array($contact_arrray) && count($contact_arrray) > 0)) @@ -602,23 +602,23 @@ class doc_generic_task_odt extends ModelePDFTask foreach ($contact_arrray as $contact) { - if ($contact['source']=='internal') { - $objectdetail=new User($this->db); + if ($contact['source'] == 'internal') { + $objectdetail = new User($this->db); $objectdetail->fetch($contact['id']); - $contact['socname']=$mysoc->name; - } elseif ($contact['source']=='external') { - $objectdetail=new Contact($this->db); + $contact['socname'] = $mysoc->name; + } elseif ($contact['source'] == 'external') { + $objectdetail = new Contact($this->db); $objectdetail->fetch($contact['id']); - $soc=new Societe($this->db); + $soc = new Societe($this->db); $soc->fetch($contact['socid']); - $contact['socname']=$soc->name; + $contact['socname'] = $soc->name; } - $contact['fullname']=$objectdetail->getFullName($outputlangs, 1); + $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); - $tmparray=$this->get_substitutionarray_tasksressource($contact, $outputlangs); + $tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlinestaskres->setVars($key, $val, true, 'UTF-8'); @@ -636,7 +636,7 @@ class doc_generic_task_odt extends ModelePDFTask // Time ressources $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; - $sql.= ", u.lastname, u.firstname"; + $sql .= ", u.lastname, u.firstname"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_task =".$object->id; @@ -654,27 +654,27 @@ class doc_generic_task_odt extends ModelePDFTask { $row = $this->db->fetch_array($resql); if (!empty($row['fk_user'])) { - $objectdetail=new User($this->db); + $objectdetail = new User($this->db); $objectdetail->fetch($row['fk_user']); // TODO Use a cache to aoid fetch for same user - $row['fullcivname']=$objectdetail->getFullName($outputlangs, 1); + $row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1); } else { - $row['fullcivname']=''; + $row['fullcivname'] = ''; } - $tmparray=$this->get_substitutionarray_taskstime($row, $outputlangs); + $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlinestasktime->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -692,24 +692,24 @@ class doc_generic_task_odt extends ModelePDFTask $listtasksfiles = $odfHandler->setSegment('tasksfiles'); $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref); - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); foreach ($filearray as $filedetail) { - $tmparray=$this->get_substitutionarray_task_file($filedetail, $outputlangs); + $tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs); //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true)); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listtasksfiles->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -720,9 +720,9 @@ class doc_generic_task_odt extends ModelePDFTask $odfHandler->mergeSegment($listtasksfiles); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } @@ -735,25 +735,25 @@ class doc_generic_task_odt extends ModelePDFTask $listlines = $odfHandler->setSegment('projectfiles'); $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref); - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); foreach ($filearray as $filedetail) { //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true)); - $tmparray=$this->get_substitutionarray_project_file($filedetail, $outputlangs); + $tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -762,21 +762,21 @@ class doc_generic_task_odt extends ModelePDFTask } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace tags of lines for contacts - $sourcearray=array('internal','external'); - $contact_arrray=array(); + $sourcearray = array('internal', 'external'); + $contact_arrray = array(); foreach ($sourcearray as $source) { - $contact_temp=$project->liste_contact(-1, $source); + $contact_temp = $project->liste_contact(-1, $source); if ((is_array($contact_temp) && count($contact_temp) > 0)) { - $contact_arrray=array_merge($contact_arrray, $contact_temp); + $contact_arrray = array_merge($contact_arrray, $contact_temp); } } if ((is_array($contact_arrray) && count($contact_arrray) > 0)) @@ -787,33 +787,33 @@ class doc_generic_task_odt extends ModelePDFTask foreach ($contact_arrray as $contact) { - if ($contact['source']=='internal') { - $objectdetail=new User($this->db); + if ($contact['source'] == 'internal') { + $objectdetail = new User($this->db); $objectdetail->fetch($contact['id']); - $contact['socname']=$mysoc->name; - } elseif ($contact['source']=='external') { - $objectdetail=new Contact($this->db); + $contact['socname'] = $mysoc->name; + } elseif ($contact['source'] == 'external') { + $objectdetail = new Contact($this->db); $objectdetail->fetch($contact['id']); - $soc=new Societe($this->db); + $soc = new Societe($this->db); $soc->fetch($contact['socid']); - $contact['socname']=$soc->name; + $contact['socname'] = $soc->name; } - $contact['fullname']=$objectdetail->getFullName($outputlangs, 1); + $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); - $tmparray=$this->get_substitutionarray_project_contacts($contact, $outputlangs); + $tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -822,9 +822,9 @@ class doc_generic_task_odt extends ModelePDFTask } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } @@ -832,8 +832,8 @@ class doc_generic_task_odt extends ModelePDFTask // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file @@ -841,7 +841,7 @@ class doc_generic_task_odt extends ModelePDFTask try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -850,26 +850,26 @@ class doc_generic_task_odt extends ModelePDFTask try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index 2740f522ff2..1eecf94734b 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -22,7 +22,7 @@ * \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; /** @@ -34,7 +34,7 @@ class mod_task_universal extends ModeleNumRefTask * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error code (or message) @@ -46,12 +46,12 @@ class mod_task_universal extends ModeleNumRefTask * @deprecated * @see name */ - public $nom='Universal'; + public $nom = 'Universal'; /** * @var string name */ - public $name='Universal'; + public $name = 'Universal'; /** @@ -61,36 +61,36 @@ class mod_task_universal extends ModeleNumRefTask */ public function info() { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("projects","admin")); + $langs->loadLangs(array("projects", "admin")); $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Task"), $langs->transnoentities("Task")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Task"), $langs->transnoentities("Task")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Task"), $langs->transnoentities("Task")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Task"), $langs->transnoentities("Task")); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -102,14 +102,14 @@ class mod_task_universal extends ModeleNumRefTask */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; - $old_code_client=$mysoc->code_client; - $mysoc->code_client='CCCCCCCCCC'; + $old_code_client = $mysoc->code_client; + $mysoc->code_client = 'CCCCCCCCCC'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client=$old_code_client; + $mysoc->code_client = $old_code_client; - if (! $numExample) + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } @@ -125,21 +125,21 @@ class mod_task_universal extends ModeleNumRefTask */ public function getNextValue($objsoc, $object) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // On defini critere recherche compteur - $mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK; + $mask = $conf->global->PROJECT_TASK_UNIVERSAL_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } - $date=empty($object->date_c)?dol_now():$object->date_c; - $numFinal=get_next_value($db, $mask, 'projet_task', 'ref', '', (is_object($objsoc)?$objsoc->code_client:''), $date); + $date = empty($object->date_c) ?dol_now() : $object->date_c; + $numFinal = get_next_value($db, $mask, 'projet_task', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); return $numFinal; } diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 3404d450a9f..b3c26ffd0bb 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -65,37 +65,37 @@ class doc_generic_proposal_odt extends ModelePDFPropales global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'PROPALE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'PROPALE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -107,114 +107,114 @@ class doc_generic_proposal_odt extends ModelePDFPropales */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) { - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; } - $texte.= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= '"; + $texte .= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROPALE_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROPALE_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
'; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
'; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '
'; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->PROPALE_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->PROPALE_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=count($listoffiles); + $texte .= count($listoffiles); //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
'.$langs->trans("DefaultModelPropalClosed").''; + $texte .= $form->selectarray('value4', $liste, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED); + $texte .= "
'; } } - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; + $texte .= ''; - $texte.= ''; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -234,7 +234,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -243,17 +243,17 @@ class doc_generic_proposal_odt extends ModelePDFPropales } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); @@ -261,11 +261,11 @@ class doc_generic_proposal_odt extends ModelePDFPropales if ($conf->propal->multidir_output[$conf->entity]) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Propal($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -275,14 +275,14 @@ class doc_generic_proposal_odt extends ModelePDFPropales $dir = $conf->propal->multidir_output[$object->entity]; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -290,26 +290,26 @@ class doc_generic_proposal_odt extends ModelePDFPropales if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -319,20 +319,20 @@ class doc_generic_proposal_odt extends ModelePDFPropales // If CUSTOMER contact defined on proposal, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use @@ -341,10 +341,10 @@ class doc_generic_proposal_odt extends ModelePDFPropales } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, @@ -353,15 +353,15 @@ class doc_generic_proposal_odt extends ModelePDFPropales ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='PROPOSAL_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'PROPOSAL_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -371,15 +371,15 @@ class doc_generic_proposal_odt extends ModelePDFPropales $srctemplatepath, array( 'PATH_TO_TMP' => $conf->propal->multidir_temp[$object->entity], - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -402,24 +402,24 @@ class doc_generic_proposal_odt extends ModelePDFPropales // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -432,7 +432,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $odfHandler->setVars($key, $value, true, 'UTF-8'); } } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -444,7 +444,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales try { $listlines = $odfHandler->setSegment('lines'); } - catch(OdfException $e) + catch (OdfException $e) { // We may arrive here if tags for lines not present into template $foundtagforlines = 0; @@ -454,22 +454,22 @@ class doc_generic_proposal_odt extends ModelePDFPropales { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -479,16 +479,16 @@ class doc_generic_proposal_odt extends ModelePDFPropales $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); @@ -500,15 +500,15 @@ class doc_generic_proposal_odt extends ModelePDFPropales } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -517,26 +517,26 @@ class doc_generic_proposal_odt extends ModelePDFPropales try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 3004a15d1ba..de5f8b33c03 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -25,7 +25,7 @@ * \brief File that contains the numbering module rules Saphir */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; /** @@ -37,7 +37,7 @@ class mod_propale_saphir extends ModeleNumRefPropales * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error code (or message) @@ -49,12 +49,12 @@ class mod_propale_saphir extends ModeleNumRefPropales * @deprecated * @see name */ - public $nom='Saphir'; + public $nom = 'Saphir'; /** * @var string model name */ - public $name='Saphir'; + public $name = 'Saphir'; /** @@ -71,28 +71,28 @@ class mod_propale_saphir extends ModeleNumRefPropales $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal")); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -104,17 +104,17 @@ class mod_propale_saphir extends ModeleNumRefPropales */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; - $old_code_client=$mysoc->code_client; - $old_code_type=$mysoc->typent_code; - $mysoc->code_client='CCCCCCCCCC'; - $mysoc->typent_code='TTTTTTTTTT'; + $old_code_client = $mysoc->code_client; + $old_code_type = $mysoc->typent_code; + $mysoc->code_client = 'CCCCCCCCCC'; + $mysoc->typent_code = 'TTTTTTTTTT'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client=$old_code_client; - $mysoc->typent_code=$old_code_type; + $mysoc->code_client = $old_code_client; + $mysoc->typent_code = $old_code_type; - if (! $numExample) + if (!$numExample) { $numExample = 'NotConfigured'; } @@ -130,16 +130,16 @@ class mod_propale_saphir extends ModeleNumRefPropales */ public function getNextValue($objsoc, $propal) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // On defini critere recherche compteur $mask = $conf->global->PROPALE_SAPHIR_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } @@ -148,7 +148,7 @@ class mod_propale_saphir extends ModeleNumRefPropales $date = $propal->date; - $numFinal=get_next_value($db, $mask, 'propal', 'ref', '', $objsoc, $date, 'next', false, null, $entity); + $numFinal = get_next_value($db, $mask, 'propal', 'ref', '', $objsoc, $date, 'next', false, null, $entity); return $numFinal; } diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 59ca0a1a97e..a9b95c6035f 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -59,28 +59,28 @@ class doc_generic_odt extends ModeleThirdPartyDoc global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo + $this->option_logo = 1; // Affiche logo // Retrieves transmitter - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini } @@ -92,7 +92,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load traductions files required by page $langs->loadLangs(array("companies", "errors")); @@ -100,76 +100,76 @@ class doc_generic_odt extends ModeleThirdPartyDoc $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0, true); // Disable hook for the moment - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0, true); // Disable hook for the moment + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '  '; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '  '; + $texte .= ''; + $texte .= '
'; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->COMPANY_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->COMPANY_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=$nbofiles; + $texte .= $nbofiles; //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
'; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -189,7 +189,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -198,16 +198,16 @@ class doc_generic_odt extends ModeleThirdPartyDoc } // Add odtgeneration hook - if (! is_object($hookmanager)) { + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); @@ -216,13 +216,13 @@ class doc_generic_odt extends ModeleThirdPartyDoc { $dir = $conf->societe->multidir_output[$object->entity]; $objectref = dol_sanitizeFileName($object->id); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -230,28 +230,28 @@ class doc_generic_odt extends ModeleThirdPartyDoc if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(s|t)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(s|t)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME)) { $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp; } - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; - $object->builddoc_filename=$filename; // For triggers + $file = $dir.'/'.$filename; + $object->builddoc_filename = $filename; // For triggers //print "newfileformat=".$newfileformat; //print "newdir=".$dir; //print "newfile=".$newfile; @@ -268,22 +268,22 @@ class doc_generic_odt extends ModeleThirdPartyDoc $srctemplatepath, array( 'PATH_TO_TMP' => $conf->societe->multidir_temp[$object->entity], - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } //print $odfHandler->__toString()."\n"; // Replace tags of lines for contacts - $contact_arrray=array(); + $contact_arrray = array(); $sql = "SELECT p.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; @@ -296,10 +296,10 @@ class doc_generic_odt extends ModeleThirdPartyDoc { require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $i=0; + $i = 0; $contactstatic = new Contact($this->db); - while($i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($result); @@ -307,27 +307,27 @@ class doc_generic_odt extends ModeleThirdPartyDoc $i++; } } - if((is_array($contact_arrray) && count($contact_arrray) > 0)) + if ((is_array($contact_arrray) && count($contact_arrray) > 0)) { try { $listlines = $odfHandler->setSegment('companycontacts'); - foreach($contact_arrray as $array_key => $contact_id) + foreach ($contact_arrray as $array_key => $contact_id) { $res_contact = $contactstatic->fetch($contact_id); - $tmparray=$this->get_substitutionarray_contact($contactstatic, $outputlangs, 'contact'); - foreach($tmparray as $key => $val) + $tmparray = $this->get_substitutionarray_contact($contactstatic, $outputlangs, 'contact'); + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -336,29 +336,29 @@ class doc_generic_odt extends ModeleThirdPartyDoc } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); //return -1; } } // Make substitutions into odt - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($object, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($object, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); $tmparray = array_merge($array_user, $array_soc, $array_thirdparty, $array_other); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Replace variables into document - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -379,8 +379,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); @@ -392,15 +392,15 @@ class doc_generic_odt extends ModeleThirdPartyDoc } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -411,38 +411,38 @@ class doc_generic_odt extends ModeleThirdPartyDoc $odfHandler->title = $object->builddoc_filename; $odfHandler->subject = $object->builddoc_filename; - if (! empty($conf->global->ODT_ADD_DOLIBARR_ID)) { + if (!empty($conf->global->ODT_ADD_DOLIBARR_ID)) { $odfHandler->userdefined['dol_id'] = $object->id; $odfHandler->userdefined['dol_element'] = $object->element; } $odfHandler->saveToDisk($file); - } catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } - $this->error='UnknownError'; + $this->error = 'UnknownError'; return -1; } } diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 49af977c0d1..22ec06c8aa6 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -37,21 +37,21 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode /** * @var string model name */ - public $name='Elephant'; + public $name = 'Elephant'; - public $code_modifiable; // Code modifiable + public $code_modifiable; // Code modifiable - public $code_modifiable_invalide; // Code modifiable si il est invalide + public $code_modifiable_invalide; // Code modifiable si il est invalide - public $code_modifiable_null; // Code modifiables si il est null + public $code_modifiable_null; // Code modifiables si il est null - public $code_null; // Code facultatif + public $code_null; // Code facultatif /** * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var int Automatic numbering @@ -92,37 +92,37 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode $langs->load("companies"); - $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); + $disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("ThirdParty"), $langs->transnoentities("ThirdParty")); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("ThirdParty"), $langs->transnoentities("ThirdParty")); //$tooltip.=$langs->trans("GenericMaskCodes2"); Not required for third party numbering - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4b"); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4b"); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix customers - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; // Parametrage du prefix suppliers - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'   
'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -141,47 +141,47 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode if ($type == 0 || $type == -1) { $examplecust = $this->getNextValue($objsoc, 0); - if (! $examplecust) + if (!$examplecust) { $examplecust = $langs->trans('NotConfigured'); } - if($examplecust=="ErrorBadMask") + if ($examplecust == "ErrorBadMask") { $langs->load("errors"); - $examplecust=$langs->trans($examplecust); + $examplecust = $langs->trans($examplecust); } - if($examplecust=="ErrorCantUseRazIfNoYearInMask") + if ($examplecust == "ErrorCantUseRazIfNoYearInMask") { $langs->load("errors"); - $examplecust=$langs->trans($examplecust); + $examplecust = $langs->trans($examplecust); } - if($examplecust=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask") + if ($examplecust == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") { $langs->load("errors"); - $examplecust=$langs->trans($examplecust); + $examplecust = $langs->trans($examplecust); } } if ($type == 1 || $type == -1) { $examplesup = $this->getNextValue($objsoc, 1); - if (! $examplesup) + if (!$examplesup) { $examplesup = $langs->trans('NotConfigured'); } - if($examplesup=="ErrorBadMask") + if ($examplesup == "ErrorBadMask") { $langs->load("errors"); - $examplesup=$langs->trans($examplesup); + $examplesup = $langs->trans($examplesup); } - if($examplesup=="ErrorCantUseRazIfNoYearInMask") + if ($examplesup == "ErrorCantUseRazIfNoYearInMask") { $langs->load("errors"); - $examplesup=$langs->trans($examplesup); + $examplesup = $langs->trans($examplesup); } - if($examplesup=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask") + if ($examplesup == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") { $langs->load("errors"); - $examplesup=$langs->trans($examplesup); + $examplesup = $langs->trans($examplesup); } } @@ -199,21 +199,21 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode */ public function getNextValue($objsoc = 0, $type = -1) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Get Mask value $mask = ''; - if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; - if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; - if (! $mask) + if ($type == 0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; + if ($type == 1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return ''; } - $field='';$where=''; + $field = ''; $where = ''; if ($type == 0) { $field = 'code_client'; @@ -226,9 +226,9 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode } else return -1; - $now=dol_now(); + $now = dol_now(); - $numFinal=get_next_value($db, $mask, 'societe', $field, $where, '', $now); + $numFinal = get_next_value($db, $mask, 'societe', $field, $where, '', $now); return $numFinal; } @@ -273,32 +273,32 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode { global $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $result=0; + $result = 0; $code = strtoupper(trim($code)); if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) { - $result=0; + $result = 0; } - elseif (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) + elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) { - $result=-2; + $result = -2; } else { // Get Mask value $mask = ''; - if ($type==0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; - if ($type==1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; - if (! $mask) + if ($type == 0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; + if ($type == 1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return -5; } - $result=check_value($mask, $code); + $result = check_value($mask, $code); if (is_string($result)) { $this->error = $result; @@ -325,11 +325,11 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode { // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; - if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'"; - else $sql.= " WHERE code_client = '".$code."'"; - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; + if ($type == 1) $sql .= " WHERE code_fournisseur = '".$code."'"; + else $sql .= " WHERE code_client = '".$code."'"; + if ($soc->id > 0) $sql .= " AND rowid <> ".$soc->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) == 0) diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index a38f27997c9..78b0e2fae8e 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -34,13 +34,13 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode /** * @var string model name */ - public $name='Aquarium'; + public $name = 'Aquarium'; /** * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' public $prefixcustomeraccountancycode; @@ -55,10 +55,10 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode public function __construct() { global $conf; - if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; - if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; - $this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; - $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; + if (!isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER = '411'; + if (!isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER = '401'; + $this->prefixcustomeraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; + $this->prefixsupplieraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; } @@ -75,26 +75,26 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode $langs->load("companies"); - $tooltip=''; + $tooltip = ''; $texte = '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $s1= $form->textwithpicto('', $tooltip, 1, 1); - $s2= $form->textwithpicto('', $tooltip, 1, 1); - $texte.= ''; + $texte .= ''; + $texte .= '
'; - $texte.=$langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2)."
\n"; - $texte.=$langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1)."
\n"; - $texte.="
\n"; - if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte.=$langs->trans('RemoveSpecialChars').' = '.yn(1)."
\n"; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $s1 = $form->textwithpicto('', $tooltip, 1, 1); + $s2 = $form->textwithpicto('', $tooltip, 1, 1); + $texte .= ''; - $texte.= ''; - $texte.= '
'; + $texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2)."
\n"; + $texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1)."
\n"; + $texte .= "
\n"; + if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte .= $langs->trans('RemoveSpecialChars').' = '.yn(1)."
\n"; //if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_ALPHA').' = '.yn($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)."
\n"; - if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) $texte.=$langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."
\n"; - $texte.= '
'; - $texte.= ''; + if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) $texte .= $langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."
\n"; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -109,10 +109,10 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode */ public function getExample($langs, $objsoc = 0, $type = -1) { - $s=''; - $s.=$this->prefixcustomeraccountancycode.'CUSTCODE'; - $s.="
\n"; - $s.=$this->prefixsupplieraccountancycode.'SUPPCODE'; + $s = ''; + $s .= $this->prefixcustomeraccountancycode.'CUSTCODE'; + $s .= "
\n"; + $s .= $this->prefixsupplieraccountancycode.'SUPPCODE'; return $s; } @@ -134,17 +134,17 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode $i = 0; $this->db = $db; - dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(! empty($societe->name)?$societe->name:'')); + dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(!empty($societe->name) ? $societe->name : '')); // Regle gestion compte compta if ($type == 'customer') { - $codetouse=(! empty($societe->code_client)?$societe->code_client:'CUSTCODE'); + $codetouse = (!empty($societe->code_client) ? $societe->code_client : 'CUSTCODE'); $prefix = $this->prefixcustomeraccountancycode; } elseif ($type == 'supplier') { - $codetouse=(! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE'); + $codetouse = (!empty($societe->code_fournisseur) ? $societe->code_fournisseur : 'SUPPCODE'); $prefix = $this->prefixsupplieraccountancycode; } else @@ -156,26 +156,26 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode //$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; // Remove special char if COMPANY_AQUARIUM_REMOVE_SPECIAL is set to 1 or not set (default) - if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse=preg_replace('/([^a-z0-9])/i', '', $codetouse); + if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse = preg_replace('/([^a-z0-9])/i', '', $codetouse); // Remove special alpha if COMPANY_AQUARIUM_REMOVE_ALPHA is set to 1 - if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $codetouse=preg_replace('/([a-z])/i', '', $codetouse); + if (!empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $codetouse = preg_replace('/([a-z])/i', '', $codetouse); // Apply a regex replacement pattern on code if COMPANY_AQUARIUM_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed. - if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) // Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; + if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) // Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; { - $codetouse=preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/', '\1\2\3', $codetouse); + $codetouse = preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/', '\1\2\3', $codetouse); } - $codetouse=$prefix.strtoupper($codetouse); + $codetouse = $prefix.strtoupper($codetouse); $is_dispo = $this->verif($db, $codetouse, $societe, $type); - if (! $is_dispo) + if (!$is_dispo) { - $this->code=$codetouse; + $this->code = $codetouse; } else { // Pour retour - $this->code=$codetouse; + $this->code = $codetouse; } dol_syslog("mod_codecompta_aquarium::get_code found code=".$this->code); return $is_dispo; @@ -194,33 +194,33 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode public function verif($db, $code, $societe, $type) { $sql = "SELECT "; - if ($type == 'customer') $sql.= "code_compta"; - elseif ($type == 'supplier') $sql.= "code_compta_fournisseur"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE "; - if ($type == 'customer') $sql.= "code_compta"; - elseif ($type == 'supplier') $sql.= "code_compta_fournisseur"; - $sql.= " = '".$db->escape($code)."'"; - if (! empty($societe->id)) $sql.= " AND rowid <> ".$societe->id; + if ($type == 'customer') $sql .= "code_compta"; + elseif ($type == 'supplier') $sql .= "code_compta_fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe"; + $sql .= " WHERE "; + if ($type == 'customer') $sql .= "code_compta"; + elseif ($type == 'supplier') $sql .= "code_compta_fournisseur"; + $sql .= " = '".$db->escape($code)."'"; + if (!empty($societe->id)) $sql .= " AND rowid <> ".$societe->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) == 0) { dol_syslog("mod_codecompta_aquarium::verif code '".$code."' available"); - return 1; // Dispo + return 1; // Dispo } else { dol_syslog("mod_codecompta_aquarium::verif code '".$code."' not available"); - return 0; // Non dispo + return 0; // Non dispo } } else { - $this->error=$db->error()." sql=".$sql; - return -1; // Erreur + $this->error = $db->error()." sql=".$sql; + return -1; // Erreur } } } diff --git a/htdocs/core/modules/societe/mod_codecompta_digitaria.php b/htdocs/core/modules/societe/mod_codecompta_digitaria.php index bb7defa67e0..7dbf129b766 100644 --- a/htdocs/core/modules/societe/mod_codecompta_digitaria.php +++ b/htdocs/core/modules/societe/mod_codecompta_digitaria.php @@ -34,13 +34,13 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode /** * @var string model name */ - public $name='Digitaria'; + public $name = 'Digitaria'; /** * Dolibarr version of the loaded document * @var string */ - public $version='dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' public $prefixcustomeraccountancycode; @@ -55,15 +55,15 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode public function __construct() { global $conf, $langs; - if (! isset($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER='411'; - if (! isset($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER='401'; - $this->prefixcustomeraccountancycode=$conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER; - $this->prefixsupplieraccountancycode=$conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER; + if (!isset($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER = '411'; + if (!isset($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER = '401'; + $this->prefixcustomeraccountancycode = $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER; + $this->prefixsupplieraccountancycode = $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER; - if (! isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER='5'; - if (! isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER='5'; - $this->customeraccountancycodecharacternumber=$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER; - $this->supplieraccountancycodecharacternumber=$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER; + if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER = '5'; + if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER = '5'; + $this->customeraccountancycodecharacternumber = $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER; + $this->supplieraccountancycodecharacternumber = $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER; } /** @@ -76,33 +76,33 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode { global $conf, $form; - $tooltip=''; + $tooltip = ''; $texte = '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $s1= $form->textwithpicto('', $tooltip, 1, 1); - $s2= $form->textwithpicto('', $tooltip, 1, 1); - $s3= $form->textwithpicto('', $tooltip, 1, 1); - $s4= $form->textwithpicto('', $tooltip, 1, 1); - $texte.= ''; + $texte .= ''; + $texte .= '
'; - $texte.= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2, $s4)."
\n"; - $texte.= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1, $s3)."
\n"; - $texte.= "
\n"; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $s1 = $form->textwithpicto('', $tooltip, 1, 1); + $s2 = $form->textwithpicto('', $tooltip, 1, 1); + $s3 = $form->textwithpicto('', $tooltip, 1, 1); + $s4 = $form->textwithpicto('', $tooltip, 1, 1); + $texte .= ''; - $texte.= ''; - $texte.= '
'; + $texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2, $s4)."
\n"; + $texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1, $s3)."
\n"; + $texte .= "
\n"; // Remove special char if COMPANY_DIGITARIA_REMOVE_SPECIAL is set to 1 or not set (default) - if (! isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $texte.= $langs->trans('RemoveSpecialChars').' = '.yn(1)."
\n"; + if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $texte .= $langs->trans('RemoveSpecialChars').' = '.yn(1)."
\n"; // Apply a regex replacement pattern on code if COMPANY_DIGITARIA_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed. - if (! empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) $texte.= $langs->trans('COMPANY_DIGITARIA_CLEAN_REGEX').' = '.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX."
\n"; + if (!empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) $texte .= $langs->trans('COMPANY_DIGITARIA_CLEAN_REGEX').' = '.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX."
\n"; // Unique index on code if COMPANY_DIGITARIA_UNIQUE_CODE is set to 1 or not set (default) - if (! isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || ! empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) $texte.= $langs->trans('COMPANY_DIGITARIA_UNIQUE_CODE').' = '.yn(1)."
\n"; - $texte.= '
'; - $texte.= ''; + if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || !empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) $texte .= $langs->trans('COMPANY_DIGITARIA_UNIQUE_CODE').' = '.yn(1)."
\n"; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -119,14 +119,14 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode { global $mysoc; - $s= $langs->trans("ThirdPartyName").": ".$mysoc->name; - $s.="
\n"; + $s = $langs->trans("ThirdPartyName").": ".$mysoc->name; + $s .= "
\n"; - if (! isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $thirdpartylabelexample = preg_replace('/([^a-z0-9])/i', '', $mysoc->name); - $s.="
\n"; - $s.=$this->prefixcustomeraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->customeraccountancycodecharacternumber)); - $s.="
\n"; - $s.=$this->prefixsupplieraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->supplieraccountancycodecharacternumber)); + if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $thirdpartylabelexample = preg_replace('/([^a-z0-9])/i', '', $mysoc->name); + $s .= "
\n"; + $s .= $this->prefixcustomeraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->customeraccountancycodecharacternumber)); + $s .= "
\n"; + $s .= $this->prefixsupplieraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->supplieraccountancycodecharacternumber)); return $s; } @@ -143,11 +143,11 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode { // phpcs:enable $i = 0; - $this->code=''; + $this->code = ''; if (is_object($societe)) { - dol_syslog("mod_codecompta_digitaria::get_code search code for type=".$type." & company=".(! empty($societe->name)?$societe->name:'')); + dol_syslog("mod_codecompta_digitaria::get_code search code for type=".$type." & company=".(!empty($societe->name) ? $societe->name : '')); if ($type == 'supplier') { $codetouse = $societe->name; @@ -167,18 +167,18 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode } // Remove special char if COMPANY_DIGITARIA_REMOVE_SPECIAL is set to 1 or not set (default) - if (! isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $codetouse=preg_replace('/([^a-z0-9])/i', '', $codetouse); + if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $codetouse = preg_replace('/([^a-z0-9])/i', '', $codetouse); // Apply a regex replacement pattern on code if COMPANY_DIGITARIA_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed. - if (! empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) // Example: $conf->global->COMPANY_DIGITARIA_CLEAN_REGEX='^..(..)..'; + if (!empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) // Example: $conf->global->COMPANY_DIGITARIA_CLEAN_REGEX='^..(..)..'; { - $codetouse=preg_replace('/'.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX.'/', '\1\2\3', $codetouse); + $codetouse = preg_replace('/'.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX.'/', '\1\2\3', $codetouse); } $this->code = $prefix.strtoupper(substr($codetouse, 0, $width)); dol_syslog("mod_codecompta_digitaria::get_code search code proposed=".$this->code); // Unique index on code if COMPANY_DIGITARIA_UNIQUE_CODE is set to 1 or not set (default) - if (! isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || ! empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) + if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || !empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) { $disponibility = $this->checkIfAccountancyCodeIsAlreadyUsed($db, $this->code, $type); @@ -194,9 +194,9 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode } if ($type == 'supplier') { - $this->code = $prefix . strtoupper(substr($codetouse, 0, $widthsupplier - $a)) . $i; + $this->code = $prefix.strtoupper(substr($codetouse, 0, $widthsupplier - $a)).$i; } elseif ($type == 'customer') { - $this->code = $prefix . strtoupper(substr($codetouse, 0, $widthcustomer - $a)) . $i; + $this->code = $prefix.strtoupper(substr($codetouse, 0, $widthcustomer - $a)).$i; } $disponibility = $this->checkIfAccountancyCodeIsAlreadyUsed($db, $this->code, $type); @@ -242,26 +242,26 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode } $sql = "SELECT ".$typethirdparty." FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE ".$typethirdparty." = '".$code."'"; + $sql .= " WHERE ".$typethirdparty." = '".$code."'"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) == 0) { dol_syslog("mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code."' available"); - return 0; // Available + return 0; // Available } else { dol_syslog("mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code."' not available"); - return -1; // Not available + return -1; // Not available } } else { - $this->error=$db->error()." sql=".$sql; - return -2; // Error + $this->error = $db->error()." sql=".$sql; + return -2; // Error } } } diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 72a6c140ee1..f8767a82163 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -72,19 +72,19 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] } //print $key.'-'.$enabled.'-'.$perms.'-'.$label.$_POST["options_" . $key].'
'."\n"; - if (empty($enabled)) continue; // 0 = Never visible field - if (abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list - if (empty($perms)) continue; // 0 = Not visible + if (empty($enabled)) continue; // 0 = Never visible field + if (abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list + if (empty($perms)) continue; // 0 = Not visible // Load language if required - if (! empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$object->table_element]['langfile'][$key]); + if (!empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$object->table_element]['langfile'][$key]); if ($action == 'edit_extras') { - $value = (isset($_POST["options_" . $key]) ? $_POST["options_" . $key] : $object->array_options["options_" . $key]); + $value = (isset($_POST["options_".$key]) ? $_POST["options_".$key] : $object->array_options["options_".$key]); } else { - $value = $object->array_options["options_" . $key]; + $value = $object->array_options["options_".$key]; //var_dump($key.' - '.$value); } if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') @@ -116,64 +116,64 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] print ''; - if (! empty($extrafields->attributes[$object->table_element]['help'][$key])) print $form->textwithpicto($langs->trans($label), $langs->trans($extrafields->attributes[$object->table_element]['help'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['help'][$key])) print $form->textwithpicto($langs->trans($label), $langs->trans($extrafields->attributes[$object->table_element]['help'][$key])); else print $langs->trans($label); print ''; //TODO Improve element and rights detection //var_dump($user->rights); - $permok=false; - $keyforperm=$object->element; - if ($object->element == 'fichinter') $keyforperm='ficheinter'; - if (isset($user->rights->$keyforperm)) $permok=$user->rights->$keyforperm->creer||$user->rights->$keyforperm->create||$user->rights->$keyforperm->write; - if ($object->element=='order_supplier') $permok=$user->rights->fournisseur->commande->creer; - if ($object->element=='invoice_supplier') $permok=$user->rights->fournisseur->facture->creer; - if ($object->element=='shipping') $permok=$user->rights->expedition->creer; - if ($object->element=='delivery') $permok=$user->rights->expedition->livraison->creer; - if ($object->element=='productlot') $permok=$user->rights->stock->creer; - if ($object->element=='facturerec') $permok=$user->rights->facture->creer; - if (($object->statut == 0 || ! empty($extrafields->attributes[$object->table_element]['alwayseditable'][$key])) + $permok = false; + $keyforperm = $object->element; + if ($object->element == 'fichinter') $keyforperm = 'ficheinter'; + if (isset($user->rights->$keyforperm)) $permok = $user->rights->$keyforperm->creer || $user->rights->$keyforperm->create || $user->rights->$keyforperm->write; + if ($object->element == 'order_supplier') $permok = $user->rights->fournisseur->commande->creer; + if ($object->element == 'invoice_supplier') $permok = $user->rights->fournisseur->facture->creer; + if ($object->element == 'shipping') $permok = $user->rights->expedition->creer; + if ($object->element == 'delivery') $permok = $user->rights->expedition->livraison->creer; + if ($object->element == 'productlot') $permok = $user->rights->stock->creer; + if ($object->element == 'facturerec') $permok = $user->rights->facture->creer; + if (($object->statut == 0 || !empty($extrafields->attributes[$object->table_element]['alwayseditable'][$key])) && $permok && ($action != 'edit_extras' || GETPOST('attribute') != $key) && empty($extrafields->attributes[$object->table_element]['computed'][$key])) { - $fieldid='id'; - if ($object->table_element == 'societe') $fieldid='socid'; - print '' . img_edit().''; + $fieldid = 'id'; + if ($object->table_element == 'societe') $fieldid = 'socid'; + print ''.img_edit().''; } print ''; print ''; $html_id = !empty($object->id) ? $object->element.'_extras_'.$key.'_'.$object->id : ''; - print ''; + print ''; // Convert date into timestamp format - if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date','datetime'))) + if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date', 'datetime'))) { - $datenotinstring = $object->array_options['options_' . $key]; + $datenotinstring = $object->array_options['options_'.$key]; // print 'X'.$object->array_options['options_' . $key].'-'.$datenotinstring.'x'; - if (! is_numeric($object->array_options['options_' . $key])) // For backward compatibility + if (!is_numeric($object->array_options['options_'.$key])) // For backward compatibility { $datenotinstring = $db->jdate($datenotinstring); } //print 'x'.$object->array_options['options_' . $key].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour'); - $value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $datenotinstring; + $value = isset($_POST["options_".$key]) ? dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]) : $datenotinstring; } //TODO Improve element and rights detection if ($action == 'edit_extras' && $permok && GETPOST('attribute', 'none') == $key) { - $fieldid='id'; - if ($object->table_element == 'societe') $fieldid='socid'; - print '
'; + $fieldid = 'id'; + if ($object->table_element == 'societe') $fieldid = 'socid'; + print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print $extrafields->showInputField($key, $value, '', '', '', 0, $object->id, $object->table_element); - print ''; + print ''; print '
'; } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 656c93cca55..61536e1d154 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -84,11 +84,11 @@ if (!empty($extrafields)) } } print "\n"; -$nolinesbefore=(count($this->lines) == 0 || $forcetoshowtitlelines); +$nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines); if ($nolinesbefore) { ?> - - global->MAIN_VIEW_LINE_NUMBER)) { ?> + + global->MAIN_VIEW_LINE_NUMBER)) { ?> @@ -124,10 +124,10 @@ if ($nolinesbefore) { situation_cycle_ref) { - print '' . $langs->trans('Progress') . ''; + print ''.$langs->trans('Progress').''; print ''; } - if (! empty($usemargins)) + if (!empty($usemargins)) { if (empty($user->rights->margins->creer)) { $colspan++; @@ -139,8 +139,8 @@ if ($nolinesbefore) { else echo $langs->trans('CostPrice'); echo ''; - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) echo ''.$langs->trans('MarginRate').''; - if (! empty($conf->global->DISPLAY_MARK_RATES)) echo ''.$langs->trans('MarkRate').''; + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) echo ''.$langs->trans('MarginRate').''; + if (!empty($conf->global->DISPLAY_MARK_RATES)) echo ''.$langs->trans('MarkRate').''; } } ?> @@ -149,11 +149,11 @@ if ($nolinesbefore) { - + global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $coldisplay++; echo ''; } @@ -166,21 +166,21 @@ if ($nolinesbefore) { if (empty($conf->global->MAIN_DISABLE_FREE_LINES)) { $freelines = true; - $forceall=1; // We always force all type for free lines (module product or service means we use predefined product or service) + $forceall = 1; // We always force all type for free lines (module product or service means we use predefined product or service) if ($object->element == 'contrat') { - if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set - elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3; + if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall = -1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set + elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall = 3; } // Free line echo ''; // Show radio free line - if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) + if ($forceall >= 0 && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { echo ''; } // Predefined product/service - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { if ($forceall >= 0 && $freelines) echo '
'; echo ''; echo ''; echo ' '; - $filtertype=''; - if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1'; + $filtertype = ''; + if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype = '1'; if (empty($senderissupplier)) { $statustoshow = 1; - if (! empty($conf->global->ENTREPOT_EXTRA_STATUS)) + if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) { // hide products in closed warehouse, but show products for internal transfer $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); @@ -236,7 +236,7 @@ if ($nolinesbefore) { { $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array')); } - if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) + if (!empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) { ?> diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 7dae554fd91..dcb15ea27db 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -30,15 +30,15 @@ $langs->loadLangs(array("companies", "bills", "products", "margins")); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if (! empty($user->socid)) $socid=$user->socid; -$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -if(empty($user->rights->margins->liretous)) accessforbidden(); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if (!empty($user->socid)) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +if (empty($user->rights->margins->liretous)) accessforbidden(); $object = new Product($db); @@ -51,19 +51,19 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="f.datef"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "f.datef"; /* * View */ -$invoicestatic=new Facture($db); +$invoicestatic = new Facture($db); $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); @@ -72,13 +72,13 @@ if ($id > 0 || ! empty($ref)) $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Card'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Card'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); @@ -88,14 +88,14 @@ if ($id > 0 || ! empty($ref)) */ if ($result > 0) { - $head=product_prepare_head($object); - $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); + $head = product_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'margin', $titre, -1, $picto); $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref'); + dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref'); print '
'; @@ -109,14 +109,14 @@ if ($id > 0 || ! empty($ref)) print ''; // Margin Rate - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print ''; } // Mark Rate - if (! empty($conf->global->DISPLAY_MARK_RATES)) { + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ''.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) print ''; @@ -132,29 +132,29 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client,"; - $sql.= " f.rowid as facid, f.ref, f.total as total_ht,"; - $sql.= " f.datef, f.paye, f.fk_statut as statut, f.type,"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " sc.fk_soc, sc.fk_user,"; - $sql.= " sum(d.total_ht) as selling_price,"; // may be negative or positive - $sql.= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty) as qty,"; // not always positive in case of Credit note - $sql.= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty * d.buy_price_ht) as buying_price,"; // not always positive in case of Credit note - $sql.= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge" ; // not always positive in case of Credit note - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."facture as f"; - $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.fk_statut > 0"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - $sql.= " AND d.fk_facture = f.rowid"; - $sql.= " AND d.fk_product =".$object->id; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if (! empty($socid)) $sql.= " AND f.fk_soc = $socid"; + $sql .= " f.rowid as facid, f.ref, f.total as total_ht,"; + $sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,"; + $sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive + $sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty) as qty,"; // not always positive in case of Credit note + $sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty * d.buy_price_ht) as buying_price,"; // not always positive in case of Credit note + $sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge"; // not always positive in case of Credit note + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."facture as f"; + $sql .= ", ".MAIN_DB_PREFIX."facturedet as d"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.fk_statut > 0"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= " AND d.fk_facture = f.rowid"; + $sql .= " AND d.fk_product =".$object->id; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if (!empty($socid)) $sql .= " AND f.fk_soc = $socid"; $sql .= " AND d.buy_price_ht IS NOT NULL"; if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; - $sql.= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user"; - $sql.= $db->order($sortfield, $sortorder); + $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; + $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); dol_syslog('margin:tabs:productMargins.php', LOG_DEBUG); @@ -178,9 +178,9 @@ if ($id > 0 || ! empty($ref)) print_liste_field_titre("BuyingPrice", $_SERVER["PHP_SELF"], "buying_price", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); - if (! empty($conf->global->DISPLAY_MARK_RATES)) + if (!empty($conf->global->DISPLAY_MARK_RATES)) print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print "\n"; @@ -194,13 +194,13 @@ if ($id > 0 || ! empty($ref)) while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); - $marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ; - $markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ; + $marginRate = ($objp->buying_price != 0) ? (100 * $objp->marge / $objp->buying_price) : ''; + $markRate = ($objp->selling_price != 0) ? (100 * $objp->marge / $objp->selling_price) : ''; print ''; print ''; - $invoicestatic->id=$objp->facid; - $invoicestatic->ref=$objp->ref; + $invoicestatic->id = $objp->facid; + $invoicestatic->ref = $objp->ref; print $invoicestatic->getNomUrl(1); print "\n"; print ''.img_object($langs->trans("ShowCompany"), "company").' '.dol_trunc($objp->name, 44).''; @@ -211,10 +211,10 @@ if ($id > 0 || ! empty($ref)) print "".price($objp->buying_price, null, null, null, null, $rounding)."\n"; print "".price($objp->qty, null, null, null, null, $rounding)."\n"; print "".price($objp->marge, null, null, null, null, $rounding)."\n"; - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + print "".(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."\n"; + if (!empty($conf->global->DISPLAY_MARK_RATES)) + print "".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."\n"; print ''.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).''; print "\n"; $i++; @@ -229,13 +229,13 @@ if ($id > 0 || ! empty($ref)) $totalMargin = $cumul_vente - $cumul_achat; if ($totalMargin < 0) { - $marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):''; - $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):''; + $marginRate = ($cumul_achat != 0) ?-1 * (100 * $totalMargin / $cumul_achat) : ''; + $markRate = ($cumul_vente != 0) ?-1 * (100 * $totalMargin / $cumul_vente) : ''; } else { - $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; - $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; + $marginRate = ($cumul_achat != 0) ? (100 * $totalMargin / $cumul_achat) : ''; + $markRate = ($cumul_vente != 0) ? (100 * $totalMargin / $cumul_vente) : ''; } print ''; print ''.$langs->trans('TotalMargin').""; @@ -243,10 +243,10 @@ if ($id > 0 || ! empty($ref)) print ''.price($cumul_achat, null, null, null, null, $rounding)."\n"; print ''.price($cumul_qty, null, null, null, null, $rounding)."\n"; print ''.price($totalMargin, null, null, null, null, $rounding)."\n"; - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''.(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + print ''.(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."\n"; + if (!empty($conf->global->DISPLAY_MARK_RATES)) + print "".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."\n"; print ' '; print "\n"; print ""; @@ -265,8 +265,8 @@ print ' '; diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 1b6d35e65a3..65eae44c2c0 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -37,12 +37,12 @@ class Opensurveysondage extends CommonObject /** * @var string ID to identify managed object */ - public $element='opensurvey_sondage'; + public $element = 'opensurvey_sondage'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='opensurvey_sondage'; + public $table_element = 'opensurvey_sondage'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -71,8 +71,8 @@ class Opensurveysondage extends CommonObject public $fk_user_creat; public $titre; - public $date_fin=''; - public $status=1; + public $date_fin = ''; + public $status = 1; public $format; public $mailsonde; @@ -126,60 +126,60 @@ class Opensurveysondage extends CommonObject */ public function create(User $user, $notrigger = 0) { - $error=0; + $error = 0; // Clean parameters $this->cleanParameters(); // Check parameters - if (! $this->date_fin > 0) + if (!$this->date_fin > 0) { - $this->error='BadValueForEndDate'; + $this->error = 'BadValueForEndDate'; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage("; - $sql.= "id_sondage,"; - $sql.= "commentaires,"; - $sql.= "fk_user_creat,"; - $sql.= "titre,"; - $sql.= "date_fin,"; - $sql.= "status,"; - $sql.= "format,"; - $sql.= "mailsonde,"; - $sql.= "allow_comments,"; - $sql.= "allow_spy,"; - $sql.= "sujet"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->id_sondage)."',"; - $sql.= " ".(empty($this->commentaires)?'NULL':"'".$this->db->escape($this->commentaires)."'").","; - $sql.= " ".$user->id.","; - $sql.= " '".$this->db->escape($this->titre)."',"; - $sql.= " '".$this->db->idate($this->date_fin)."',"; - $sql.= " ".$this->status.","; - $sql.= " '".$this->db->escape($this->format)."',"; - $sql.= " ".$this->db->escape($this->mailsonde).","; - $sql.= " ".$this->db->escape($this->allow_comments).","; - $sql.= " ".$this->db->escape($this->allow_spy).","; - $sql.= " '".$this->db->escape($this->sujet)."'"; - $sql.= ")"; + $sql .= "id_sondage,"; + $sql .= "commentaires,"; + $sql .= "fk_user_creat,"; + $sql .= "titre,"; + $sql .= "date_fin,"; + $sql .= "status,"; + $sql .= "format,"; + $sql .= "mailsonde,"; + $sql .= "allow_comments,"; + $sql .= "allow_spy,"; + $sql .= "sujet"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($this->id_sondage)."',"; + $sql .= " ".(empty($this->commentaires) ? 'NULL' : "'".$this->db->escape($this->commentaires)."'").","; + $sql .= " ".$user->id.","; + $sql .= " '".$this->db->escape($this->titre)."',"; + $sql .= " '".$this->db->idate($this->date_fin)."',"; + $sql .= " ".$this->status.","; + $sql .= " '".$this->db->escape($this->format)."',"; + $sql .= " ".$this->db->escape($this->mailsonde).","; + $sql .= " ".$this->db->escape($this->allow_comments).","; + $sql .= " ".$this->db->escape($this->allow_spy).","; + $sql .= " '".$this->db->escape($this->sujet)."'"; + $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { global $langs, $conf; // Call trigger - $result=$this->call_trigger('OPENSURVEY_CREATE', $user); + $result = $this->call_trigger('OPENSURVEY_CREATE', $user); if ($result < 0) $error++; // End call triggers } @@ -188,13 +188,13 @@ class Opensurveysondage extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -214,25 +214,25 @@ class Opensurveysondage extends CommonObject public function fetch($id, $numsurvey = '') { $sql = "SELECT"; - $sql.= " t.id_sondage,"; - $sql.= " t.commentaires as description,"; - $sql.= " t.mail_admin,"; - $sql.= " t.nom_admin,"; - $sql.= " t.fk_user_creat,"; - $sql.= " t.titre,"; - $sql.= " t.date_fin,"; - $sql.= " t.status,"; - $sql.= " t.format,"; - $sql.= " t.mailsonde,"; - $sql.= " t.allow_comments,"; - $sql.= " t.allow_spy,"; - $sql.= " t.sujet,"; - $sql.= " t.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t"; - $sql.= " WHERE t.id_sondage = '".$this->db->escape($id ? $id : $numsurvey)."'"; + $sql .= " t.id_sondage,"; + $sql .= " t.commentaires as description,"; + $sql .= " t.mail_admin,"; + $sql .= " t.nom_admin,"; + $sql .= " t.fk_user_creat,"; + $sql .= " t.titre,"; + $sql .= " t.date_fin,"; + $sql .= " t.status,"; + $sql .= " t.format,"; + $sql .= " t.mailsonde,"; + $sql .= " t.allow_comments,"; + $sql .= " t.allow_spy,"; + $sql .= " t.sujet,"; + $sql .= " t.tms"; + $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t"; + $sql .= " WHERE t.id_sondage = '".$this->db->escape($id ? $id : $numsurvey)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -240,9 +240,9 @@ class Opensurveysondage extends CommonObject $obj = $this->db->fetch_object($resql); $this->id_sondage = $obj->id_sondage; - $this->ref = $this->id_sondage; //For compatibility + $this->ref = $this->id_sondage; //For compatibility - $this->commentaires = $obj->description; // deprecated + $this->commentaires = $obj->description; // deprecated $this->description = $obj->description; $this->mail_admin = $obj->mail_admin; $this->nom_admin = $obj->nom_admin; @@ -257,12 +257,12 @@ class Opensurveysondage extends CommonObject $this->fk_user_creat = $obj->fk_user_creat; $this->date_m = $this->db->jdate($obj->tls); - $ret=1; + $ret = 1; } else { $sondage = ($id ? 'id='.$id : 'sondageid='.$numsurvey); - $this->error='Fetch no poll found for '.$sondage; + $this->error = 'Fetch no poll found for '.$sondage; dol_syslog($this->error, LOG_ERR); $ret = 0; } @@ -271,8 +271,8 @@ class Opensurveysondage extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); - $ret=-1; + $this->error = "Error ".$this->db->lasterror(); + $ret = -1; } return $ret; @@ -289,7 +289,7 @@ class Opensurveysondage extends CommonObject public function update(User $user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters $this->cleanParameters(); @@ -300,35 +300,35 @@ class Opensurveysondage extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."opensurvey_sondage SET"; - $sql.= " id_sondage=".(isset($this->id_sondage)?"'".$this->db->escape($this->id_sondage)."'":"null").","; - $sql.= " commentaires=".(isset($this->commentaires)?"'".$this->db->escape($this->commentaires)."'":"null").","; - $sql.= " mail_admin=".(isset($this->mail_admin)?"'".$this->db->escape($this->mail_admin)."'":"null").","; - $sql.= " nom_admin=".(isset($this->nom_admin)?"'".$this->db->escape($this->nom_admin)."'":"null").","; - $sql.= " titre=".(isset($this->titre)?"'".$this->db->escape($this->titre)."'":"null").","; - $sql.= " date_fin=".(dol_strlen($this->date_fin)!=0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').","; - $sql.= " status=".(isset($this->status)?"'".$this->db->escape($this->status)."'":"null").","; - $sql.= " format=".(isset($this->format)?"'".$this->db->escape($this->format)."'":"null").","; - $sql.= " mailsonde=".(isset($this->mailsonde)?$this->db->escape($this->mailsonde):"null").","; - $sql.= " allow_comments=".$this->db->escape($this->allow_comments).","; - $sql.= " allow_spy=".$this->db->escape($this->allow_spy); + $sql .= " id_sondage=".(isset($this->id_sondage) ? "'".$this->db->escape($this->id_sondage)."'" : "null").","; + $sql .= " commentaires=".(isset($this->commentaires) ? "'".$this->db->escape($this->commentaires)."'" : "null").","; + $sql .= " mail_admin=".(isset($this->mail_admin) ? "'".$this->db->escape($this->mail_admin)."'" : "null").","; + $sql .= " nom_admin=".(isset($this->nom_admin) ? "'".$this->db->escape($this->nom_admin)."'" : "null").","; + $sql .= " titre=".(isset($this->titre) ? "'".$this->db->escape($this->titre)."'" : "null").","; + $sql .= " date_fin=".(dol_strlen($this->date_fin) != 0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').","; + $sql .= " status=".(isset($this->status) ? "'".$this->db->escape($this->status)."'" : "null").","; + $sql .= " format=".(isset($this->format) ? "'".$this->db->escape($this->format)."'" : "null").","; + $sql .= " mailsonde=".(isset($this->mailsonde) ? $this->db->escape($this->mailsonde) : "null").","; + $sql .= " allow_comments=".$this->db->escape($this->allow_comments).","; + $sql .= " allow_spy=".$this->db->escape($this->allow_spy); - $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; + $sql .= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; $this->db->begin(); dol_syslog(get_class($this)."::update", 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) { - if (! $notrigger) + if (!$notrigger) { // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('OPENSURVEY_MODIFY', $this, $user, $langs, $conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interface = new Interfaces($this->db); + $result = $interface->run_triggers('OPENSURVEY_MODIFY', $this, $user, $langs, $conf); + if ($result < 0) { $error++; $this->errors = $interface->errors; } // End call triggers } } @@ -336,13 +336,13 @@ class Opensurveysondage extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -362,7 +362,7 @@ class Opensurveysondage extends CommonObject public function delete(User $user, $notrigger = 0, $numsondage = '') { global $conf, $langs; - $error=0; + $error = 0; if (empty($numsondage)) { @@ -371,44 +371,44 @@ class Opensurveysondage extends CommonObject $this->db->begin(); - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('OPENSURVEY_DELETE', $user); + $result = $this->call_trigger('OPENSURVEY_DELETE', $user); if ($result < 0) $error++; // End call triggers } } - if (! $error) + if (!$error) { - $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + $resql = $this->db->query($sql); + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$this->db->escape($numsondage)."'"; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."opensurvey_sondage"; - $sql.= " WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + $sql .= " WHERE id_sondage = '".$this->db->escape($numsondage)."'"; 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(); } } // Commit or rollback if ($error) { - 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); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -432,43 +432,43 @@ class Opensurveysondage extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - 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 = ''; $companylink = ''; - $label = '' . $langs->trans("ShowSurvey") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref.'
'; - $label.= '' . $langs->trans('Title') . ': ' . $this->title.'
'; + $label = ''.$langs->trans("ShowSurvey").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref.'
'; + $label .= ''.$langs->trans('Title').': '.$this->title.'
'; $url = DOL_URL_ROOT.'/opensurvey/card.php?id='.$this->id; // Add param to save lastsearch_values or not - $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'; - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowMyObject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($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 ? $this->picto : 'generic'), ($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; @@ -483,28 +483,28 @@ class Opensurveysondage extends CommonObject public function fetch_lines() { // phpcs:enable - $ret=array(); + $ret = array(); $sql = "SELECT id_users, nom as name, reponses FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'"; - $resql=$this->db->query($sql); + $sql .= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'"; + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $i=0; + $num = $this->db->num_rows($resql); + $i = 0; while ($i < $num) { - $obj=$this->db->fetch_object($resql); - $tmp=array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses); + $obj = $this->db->fetch_object($resql); + $tmp = array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses); - $ret[]=$tmp; + $ret[] = $tmp; $i++; } } else dol_print_error($this->db); - $this->lines=$ret; + $this->lines = $ret; return count($this->lines); } @@ -517,18 +517,18 @@ class Opensurveysondage extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->id_sondage=''; - $this->commentaires='Comment of the specimen survey'; - $this->description='Comment of the specimen survey'; - $this->mail_admin=''; - $this->nom_admin=''; - $this->titre='This is a specimen survey'; - $this->date_fin=dol_now()+3600*24*10; - $this->status=1; - $this->format='classic'; - $this->mailsonde=''; + $this->id_sondage = ''; + $this->commentaires = 'Comment of the specimen survey'; + $this->description = 'Comment of the specimen survey'; + $this->mail_admin = ''; + $this->nom_admin = ''; + $this->titre = 'This is a specimen survey'; + $this->date_fin = dol_now() + 3600 * 24 * 10; + $this->status = 1; + $this->format = 'classic'; + $this->mailsonde = ''; } /** @@ -541,14 +541,14 @@ class Opensurveysondage extends CommonObject $comments = array(); $sql = 'SELECT id_comment, usercomment, comment'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments'; - $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; - $sql.= " ORDER BY id_comment"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments'; + $sql .= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; + $sql .= " ORDER BY id_comment"; $resql = $this->db->query($sql); if ($resql) { - $num_rows=$this->db->num_rows($resql); + $num_rows = $this->db->num_rows($resql); if ($num_rows > 0) { @@ -572,7 +572,7 @@ class Opensurveysondage extends CommonObject public function addComment($comment, $comment_user) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment)"; - $sql.= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')"; + $sql .= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')"; $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index a1d218e4e3c..c8ab3d4fbee 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -60,37 +60,37 @@ $object = new Opensurveysondage($db); $opensurvey_static = new Opensurveysondage($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->opensurvey->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('surveylist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->opensurvey->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('surveylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="p.date_fin"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "p.date_fin"; +if (!$sortorder) $sortorder = "DESC"; // Security check if (!$user->rights->opensurvey->read) accessforbidden(); // Definition of fields for list -$arrayfields=array(); -foreach($arrayfields as $key => $val) +$arrayfields = array(); +foreach ($arrayfields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], - 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), + 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], - 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key]) + 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]) ); } } @@ -120,23 +120,23 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 { - $search_status=''; - $search_title=''; - $search_ref=''; - $toselect=''; - $search_array_options=array(); + $search_status = ''; + $search_title = ''; + $search_ref = ''; + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Opensurveysondage'; - $objectlabel='Opensurveysondage'; + $objectclass = 'Opensurveysondage'; + $objectlabel = 'Opensurveysondage'; $uploaddir = $conf->opensurvey->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -220,25 +220,25 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ llxHeader('', $title, $help_url); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -$fieldtosortuser=empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?'firstname':'lastname'; +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +$fieldtosortuser = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 'firstname' : 'lastname'; -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($permissiontodelete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); // List of surveys into database @@ -258,16 +258,16 @@ $newcardbutton = dolGetButtonTitle($langs->trans('NewSurvey'), '', 'fa fa-plus-c print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendOpenSurveyRef"; -$modelmail="opensurvey"; -$objecttmp=new Opensurveysondage($db); -$trackid='surv'.$object->id; +$topicmail = "SendOpenSurveyRef"; +$modelmail = "opensurvey"; +$objecttmp = new Opensurveysondage($db); +$trackid = 'surv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -304,18 +304,18 @@ print ''; print ''; print ''; print ''; -$arraystatus=array('-1'=>' ','0'=>$langs->trans("Draft"),'1'=>$langs->trans("Opened"),'2'=>$langs->trans("Closed")); -print ''. $form->selectarray('search_status', $arraystatus, $search_status).''; +$arraystatus = array('-1'=>' ', '0'=>$langs->trans("Draft"), '1'=>$langs->trans("Opened"), '2'=>$langs->trans("Closed")); +print ''.$form->selectarray('search_status', $arraystatus, $search_status).''; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print ''; print ''."\n"; @@ -374,19 +374,19 @@ while ($i < min($num, $limit)) print ''; print $opensurvey_static->getNomUrl(1); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Title print ''.dol_htmlentities($obj->titre).''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Type print ''; - $type=($obj->format=='A')?'classic':'date'; - print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'), 1), 'width="16"', 1); - print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate"); + $type = ($obj->format == 'A') ? 'classic' : 'date'; + print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1); + print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate"); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; // Author @@ -402,36 +402,36 @@ while ($i < min($num, $limit)) print dol_htmlentities($obj->nom_admin); } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Nb of voters print''.$nbuser.''."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''.dol_print_date($db->jdate($obj->date_fin), 'day'); if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) { print img_warning($langs->trans("Expired")); } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''.$opensurvey_static->getLibStatut(5).''."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''."\n"; $i++; @@ -445,15 +445,15 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; if ($num == 0) { $colspan = 8; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''.$langs->trans("NoRecordFound").''; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ''."\n"; @@ -463,19 +463,19 @@ print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$permissiontoread; - $delallowed=$permissiontoadd; + $filedir = $diroutputmassaction; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index e65a6975844..30032c927cc 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -70,7 +70,7 @@ $refalreadyexists = 0; $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$type = (GETPOST('type', 'int') !== '')? GETPOST('type', 'int'):Product::TYPE_PRODUCT; +$type = (GETPOST('type', 'int') !== '') ? GETPOST('type', 'int') : Product::TYPE_PRODUCT; $action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -1222,15 +1222,15 @@ else // Accountancy codes print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { // Accountancy_code_sell print ''; print ''; @@ -1240,10 +1240,10 @@ else { print ''; print ''; @@ -1252,11 +1252,11 @@ else // Accountancy_code_sell_export print ''; print ''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 68675b3e9dd..7e906103080 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -47,22 +47,22 @@ class Product extends CommonObject /** * @var string ID to identify managed object */ - public $element='product'; + public $element = 'product'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='product'; + public $table_element = 'product'; /** * @var int Field with ID of parent key if this field has a parent */ - public $fk_element='fk_product'; + public $fk_element = 'fk_product'; /** * @var array List of child tables. To test if we can delete object. */ - protected $childtables=array('supplier_proposaldet', 'propaldet', 'commandedet', 'facturedet', 'contratdet', 'facture_fourn_det', 'commande_fournisseurdet'); + protected $childtables = array('supplier_proposaldet', 'propaldet', 'commandedet', 'facturedet', 'contratdet', 'facture_fourn_det', 'commande_fournisseurdet'); /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -383,18 +383,18 @@ class Product extends CommonObject public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1), - 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), - 'note' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1), + 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), + 'note' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_author'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + 'fk_user_author'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), //'tosell' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), //'tobuy' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), ); @@ -466,15 +466,15 @@ class Product extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters $this->ref = dol_sanitizeFileName(dol_string_nospecial(trim($this->ref))); $this->label = trim($this->label); - $this->price_ttc=price2num($this->price_ttc); - $this->price=price2num($this->price); - $this->price_min_ttc=price2num($this->price_min_ttc); - $this->price_min=price2num($this->price_min); + $this->price_ttc = price2num($this->price_ttc); + $this->price = price2num($this->price); + $this->price_min_ttc = price2num($this->price_min_ttc); + $this->price_min = price2num($this->price_min); if (empty($this->tva_tx)) { $this->tva_tx = 0; } @@ -959,117 +959,117 @@ class Product extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."product"; - $sql.= " SET label = '" . $this->db->escape($this->label) ."'"; + $sql .= " SET label = '".$this->db->escape($this->label)."'"; if ($updatetype && ($this->isProduct() || $this->isService())) { - $sql.= ", fk_product_type = " . $this->type; + $sql .= ", fk_product_type = ".$this->type; } - $sql.= ", ref = '" . $this->db->escape($this->ref) ."'"; - $sql.= ", ref_ext = ".(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null"); - $sql.= ", default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null"); - $sql.= ", tva_tx = " . $this->tva_tx; - $sql.= ", recuperableonly = " . $this->tva_npr; - $sql.= ", localtax1_tx = " . $this->localtax1_tx; - $sql.= ", localtax2_tx = " . $this->localtax2_tx; - $sql.= ", localtax1_type = " . ($this->localtax1_type!=''?"'".$this->db->escape($this->localtax1_type)."'":"'0'"); - $sql.= ", localtax2_type = " . ($this->localtax2_type!=''?"'".$this->db->escape($this->localtax2_type)."'":"'0'"); + $sql .= ", ref = '".$this->db->escape($this->ref)."'"; + $sql .= ", ref_ext = ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); + $sql .= ", default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null"); + $sql .= ", tva_tx = ".$this->tva_tx; + $sql .= ", recuperableonly = ".$this->tva_npr; + $sql .= ", localtax1_tx = ".$this->localtax1_tx; + $sql .= ", localtax2_tx = ".$this->localtax2_tx; + $sql .= ", localtax1_type = ".($this->localtax1_type != '' ? "'".$this->db->escape($this->localtax1_type)."'" : "'0'"); + $sql .= ", localtax2_type = ".($this->localtax2_type != '' ? "'".$this->db->escape($this->localtax2_type)."'" : "'0'"); - $sql.= ", barcode = ". (empty($this->barcode)?"null":"'".$this->db->escape($this->barcode)."'"); - $sql.= ", fk_barcode_type = ". (empty($this->barcode_type)?"null":$this->db->escape($this->barcode_type)); + $sql .= ", barcode = ".(empty($this->barcode) ? "null" : "'".$this->db->escape($this->barcode)."'"); + $sql .= ", fk_barcode_type = ".(empty($this->barcode_type) ? "null" : $this->db->escape($this->barcode_type)); - $sql.= ", tosell = " . (int) $this->status; - $sql.= ", tobuy = " . (int) $this->status_buy; - $sql.= ", tobatch = " . ((empty($this->status_batch) || $this->status_batch < 0) ? '0' : (int) $this->status_batch); - $sql.= ", finished = " . ((! isset($this->finished) || $this->finished < 0) ? "null" : (int) $this->finished); - $sql.= ", net_measure = " . ($this->net_measure!='' ? "'".$this->db->escape($this->net_measure)."'" : 'null'); - $sql.= ", net_measure_units = " . ($this->net_measure_units!='' ? "'".$this->db->escape($this->net_measure_units)."'": 'null'); - $sql.= ", weight = " . ($this->weight!='' ? "'".$this->db->escape($this->weight)."'" : 'null'); - $sql.= ", weight_units = " . ($this->weight_units!='' ? "'".$this->db->escape($this->weight_units)."'": 'null'); - $sql.= ", length = " . ($this->length!='' ? "'".$this->db->escape($this->length)."'" : 'null'); - $sql.= ", length_units = " . ($this->length_units!='' ? "'".$this->db->escape($this->length_units)."'" : 'null'); - $sql.= ", width= " . ($this->width!='' ? "'".$this->db->escape($this->width)."'" : 'null'); - $sql.= ", width_units = " . ($this->width_units!='' ? "'".$this->db->escape($this->width_units)."'" : 'null'); - $sql.= ", height = " . ($this->height!='' ? "'".$this->db->escape($this->height)."'" : 'null'); - $sql.= ", height_units = " . ($this->height_units!='' ? "'".$this->db->escape($this->height_units)."'" : 'null'); - $sql.= ", surface = " . ($this->surface!='' ? "'".$this->db->escape($this->surface)."'" : 'null'); - $sql.= ", surface_units = " . ($this->surface_units!='' ? "'".$this->db->escape($this->surface_units)."'" : 'null'); - $sql.= ", volume = " . ($this->volume!='' ? "'".$this->db->escape($this->volume)."'" : 'null'); - $sql.= ", volume_units = " . ($this->volume_units!='' ? "'".$this->db->escape($this->volume_units)."'" : 'null'); - $sql.= ", fk_default_warehouse = " . ($this->fk_default_warehouse > 0 ? $this->db->escape($this->fk_default_warehouse) : 'null'); - $sql.= ", seuil_stock_alerte = " . ((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->db->escape($this->seuil_stock_alerte)."'" : "null"); - $sql.= ", description = '" . $this->db->escape($this->description) ."'"; - $sql.= ", url = " . ($this->url?"'".$this->db->escape($this->url)."'":'null'); - $sql.= ", customcode = '" . $this->db->escape($this->customcode) ."'"; - $sql.= ", fk_country = " . ($this->country_id > 0 ? (int) $this->country_id : 'null'); - $sql.= ", note = ".(isset($this->note) ? "'" .$this->db->escape($this->note)."'" : 'null'); - $sql.= ", duration = '" . $this->db->escape($this->duration_value . $this->duration_unit) ."'"; - $sql.= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy)."'"; - $sql.= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell)."'"; - $sql.= ", accountancy_code_sell_intra= '" . $this->db->escape($this->accountancy_code_sell_intra)."'"; - $sql.= ", accountancy_code_sell_export= '" . $this->db->escape($this->accountancy_code_sell_export)."'"; - $sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? (int) $this->desiredstock : "null"); - $sql.= ", cost_price = " . ($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null'); - $sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : (int) $this->fk_unit); - $sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1); - $sql.= ", fk_price_expression = ".($this->fk_price_expression != 0 ? (int) $this->fk_price_expression : 'NULL'); - $sql.= ", fk_user_modif = ".($user->id > 0 ? $user->id : 'NULL'); + $sql .= ", tosell = ".(int) $this->status; + $sql .= ", tobuy = ".(int) $this->status_buy; + $sql .= ", tobatch = ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : (int) $this->status_batch); + $sql .= ", finished = ".((!isset($this->finished) || $this->finished < 0) ? "null" : (int) $this->finished); + $sql .= ", net_measure = ".($this->net_measure != '' ? "'".$this->db->escape($this->net_measure)."'" : 'null'); + $sql .= ", net_measure_units = ".($this->net_measure_units != '' ? "'".$this->db->escape($this->net_measure_units)."'" : 'null'); + $sql .= ", weight = ".($this->weight != '' ? "'".$this->db->escape($this->weight)."'" : 'null'); + $sql .= ", weight_units = ".($this->weight_units != '' ? "'".$this->db->escape($this->weight_units)."'" : 'null'); + $sql .= ", length = ".($this->length != '' ? "'".$this->db->escape($this->length)."'" : 'null'); + $sql .= ", length_units = ".($this->length_units != '' ? "'".$this->db->escape($this->length_units)."'" : 'null'); + $sql .= ", width= ".($this->width != '' ? "'".$this->db->escape($this->width)."'" : 'null'); + $sql .= ", width_units = ".($this->width_units != '' ? "'".$this->db->escape($this->width_units)."'" : 'null'); + $sql .= ", height = ".($this->height != '' ? "'".$this->db->escape($this->height)."'" : 'null'); + $sql .= ", height_units = ".($this->height_units != '' ? "'".$this->db->escape($this->height_units)."'" : 'null'); + $sql .= ", surface = ".($this->surface != '' ? "'".$this->db->escape($this->surface)."'" : 'null'); + $sql .= ", surface_units = ".($this->surface_units != '' ? "'".$this->db->escape($this->surface_units)."'" : 'null'); + $sql .= ", volume = ".($this->volume != '' ? "'".$this->db->escape($this->volume)."'" : 'null'); + $sql .= ", volume_units = ".($this->volume_units != '' ? "'".$this->db->escape($this->volume_units)."'" : 'null'); + $sql .= ", fk_default_warehouse = ".($this->fk_default_warehouse > 0 ? $this->db->escape($this->fk_default_warehouse) : 'null'); + $sql .= ", seuil_stock_alerte = ".((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->db->escape($this->seuil_stock_alerte)."'" : "null"); + $sql .= ", description = '".$this->db->escape($this->description)."'"; + $sql .= ", url = ".($this->url ? "'".$this->db->escape($this->url)."'" : 'null'); + $sql .= ", customcode = '".$this->db->escape($this->customcode)."'"; + $sql .= ", fk_country = ".($this->country_id > 0 ? (int) $this->country_id : 'null'); + $sql .= ", note = ".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : 'null'); + $sql .= ", duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."'"; + $sql .= ", accountancy_code_buy = '".$this->db->escape($this->accountancy_code_buy)."'"; + $sql .= ", accountancy_code_sell= '".$this->db->escape($this->accountancy_code_sell)."'"; + $sql .= ", accountancy_code_sell_intra= '".$this->db->escape($this->accountancy_code_sell_intra)."'"; + $sql .= ", accountancy_code_sell_export= '".$this->db->escape($this->accountancy_code_sell_export)."'"; + $sql .= ", desiredstock = ".((isset($this->desiredstock) && $this->desiredstock != '') ? (int) $this->desiredstock : "null"); + $sql .= ", cost_price = ".($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null'); + $sql .= ", fk_unit= ".(!$this->fk_unit ? 'NULL' : (int) $this->fk_unit); + $sql .= ", price_autogen = ".(!$this->price_autogen ? 0 : 1); + $sql .= ", fk_price_expression = ".($this->fk_price_expression != 0 ? (int) $this->fk_price_expression : 'NULL'); + $sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id : 'NULL'); // stock field is not here because it is a denormalized value from product_stock. - $sql.= " WHERE rowid = " . $id; + $sql .= " WHERE rowid = ".$id; dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $id; // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { if ($this->setMultiLangs($user) < 0) { - $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql; + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; return -2; } } - $action='update'; + $action = 'update'; // Actions on extra fields - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - $result=$this->insertExtraFields(); + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) { + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('PRODUCT_MODIFY', $user); + $result = $this->call_trigger('PRODUCT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) { + if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) { // We remove directory if ($conf->product->dir_output) { - $olddir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); - $newdir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->ref); + $olddir = $conf->product->dir_output."/".dol_sanitizeFileName($this->oldcopy->ref); + $newdir = $conf->product->dir_output."/".dol_sanitizeFileName($this->ref); if (file_exists($olddir)) { //include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; //$res = dol_move($olddir, $newdir); // do not use dol_move with directory $res = @rename($olddir, $newdir); - if (! $res) { + if (!$res) { $langs->load("errors"); - $this->error=$langs->trans('ErrorFailToRenameDir', $olddir, $newdir); + $this->error = $langs->trans('ErrorFailToRenameDir', $olddir, $newdir); $error++; } } } } - if (! $error) { + if (!$error) { if ($conf->variants->enabled) { include_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; @@ -1623,27 +1623,27 @@ class Product extends CommonObject $price_base_type = $this->price_base_type; // If price per segment - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($thirdparty_buyer->price_level)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($thirdparty_buyer->price_level)) { $pu_ht = $this->multiprices[$thirdparty_buyer->price_level]; $pu_ttc = $this->multiprices_ttc[$thirdparty_buyer->price_level]; $price_min = $this->multiprices_min[$thirdparty_buyer->price_level]; $price_base_type = $this->multiprices_base_type[$thirdparty_buyer->price_level]; - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { - if (isset($this->multiprices_tva_tx[$thirdparty_buyer->price_level])) $tva_tx=$this->multiprices_tva_tx[$thirdparty_buyer->price_level]; - if (isset($this->multiprices_recuperableonly[$thirdparty_buyer->price_level])) $tva_npr=$this->multiprices_recuperableonly[$thirdparty_buyer->price_level]; - if (empty($tva_tx)) $tva_npr=0; + if (isset($this->multiprices_tva_tx[$thirdparty_buyer->price_level])) $tva_tx = $this->multiprices_tva_tx[$thirdparty_buyer->price_level]; + if (isset($this->multiprices_recuperableonly[$thirdparty_buyer->price_level])) $tva_npr = $this->multiprices_recuperableonly[$thirdparty_buyer->price_level]; + if (empty($tva_tx)) $tva_npr = 0; } } // If price per customer - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); - $filter = array('t.fk_product' => $this->id,'t.fk_soc' => $thirdparty_buyer->id); + $filter = array('t.fk_product' => $this->id, 't.fk_soc' => $thirdparty_buyer->id); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); if ($result) { @@ -1652,19 +1652,19 @@ class Product extends CommonObject $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; $tva_tx = $prodcustprice->lines[0]->tva_tx; - if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; } } } // If price per quantity - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { if ($this->prices_by_qty[0]) // yes, this product has some prices per quantity { // Search price into product_price_by_qty from $this->id - foreach($this->prices_by_qty_list[0] as $priceforthequantityarray) + foreach ($this->prices_by_qty_list[0] as $priceforthequantityarray) { if ($priceforthequantityarray['rowid'] != $pqp) continue; // We found the price @@ -1681,12 +1681,12 @@ class Product extends CommonObject } } // If price per quantity and customer - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { if ($this->prices_by_qty[$thirdparty_buyer->price_level]) // yes, this product has some prices per quantity { // Search price into product_price_by_qty from $this->id - foreach($this->prices_by_qty_list[$thirdparty_buyer->price_level] as $priceforthequantityarray) + foreach ($this->prices_by_qty_list[$thirdparty_buyer->price_level] as $priceforthequantityarray) { if ($priceforthequantityarray['rowid'] != $pqp) continue; // We found the price @@ -2066,31 +2066,31 @@ class Product extends CommonObject dol_syslog(get_class($this)."::fetch id=".$id." ref=".$ref." ref_ext=".$ref_ext); // Check parameters - if (! $id && ! $ref && ! $ref_ext && ! $barcode) { - $this->error='ErrorWrongParameters'; + if (!$id && !$ref && !$ref_ext && !$barcode) { + $this->error = 'ErrorWrongParameters'; dol_syslog(get_class($this)."::fetch ".$this->error); return -1; } $sql = "SELECT rowid, ref, ref_ext, label, description, url, note as note_private, customcode, fk_country, price, price_ttc,"; - $sql.= " price_min, price_min_ttc, price_base_type, cost_price, default_vat_code, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,"; - $sql.= " tobuy, fk_product_type, duration, fk_default_warehouse, seuil_stock_alerte, canvas, net_measure, net_measure_units, weight, weight_units,"; - $sql.= " length, length_units, width, width_units, height, height_units,"; - $sql.= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; - $sql.= " accountancy_code_buy, accountancy_code_sell, accountancy_code_sell_intra, accountancy_code_sell_export, stock, pmp,"; - $sql.= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,"; - $sql.= " fk_price_expression, price_autogen"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " price_min, price_min_ttc, price_base_type, cost_price, default_vat_code, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,"; + $sql .= " tobuy, fk_product_type, duration, fk_default_warehouse, seuil_stock_alerte, canvas, net_measure, net_measure_units, weight, weight_units,"; + $sql .= " length, length_units, width, width_units, height, height_units,"; + $sql .= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; + $sql .= " accountancy_code_buy, accountancy_code_sell, accountancy_code_sell_intra, accountancy_code_sell_export, stock, pmp,"; + $sql .= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,"; + $sql .= " fk_price_expression, price_autogen"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; if ($id) { - $sql.= " WHERE rowid = ".(int) $id; + $sql .= " WHERE rowid = ".(int) $id; } else { - $sql.= " WHERE entity IN (".getEntity($this->element).")"; + $sql .= " WHERE entity IN (".getEntity($this->element).")"; if ($ref) { - $sql.= " AND ref = '".$this->db->escape($ref)."'"; + $sql .= " AND ref = '".$this->db->escape($ref)."'"; } elseif ($ref_ext) { - $sql.= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; + $sql .= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; } elseif ($barcode) { - $sql.= " AND barcode = '".$this->db->escape($barcode)."'"; + $sql .= " AND barcode = '".$this->db->escape($barcode)."'"; } } @@ -2108,7 +2108,7 @@ class Product extends CommonObject $this->description = $obj->description; $this->url = $obj->url; $this->note_private = $obj->note_private; - $this->note = $obj->note_private; // deprecated + $this->note = $obj->note_private; // deprecated $this->type = $obj->fk_product_type; $this->status = $obj->tosell; @@ -2137,37 +2137,37 @@ class Product extends CommonObject $this->finished = $obj->finished; $this->duration = $obj->duration; - $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration)-1); - $this->duration_unit = substr($obj->duration, -1); + $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); + $this->duration_unit = substr($obj->duration, -1); $this->canvas = $obj->canvas; - $this->net_measure = $obj->net_measure; - $this->net_measure_units = $obj->net_measure_units; + $this->net_measure = $obj->net_measure; + $this->net_measure_units = $obj->net_measure_units; $this->weight = $obj->weight; $this->weight_units = $obj->weight_units; $this->length = $obj->length; $this->length_units = $obj->length_units; - $this->width = $obj->width; - $this->width_units = $obj->width_units; - $this->height = $obj->height; - $this->height_units = $obj->height_units; + $this->width = $obj->width; + $this->width_units = $obj->width_units; + $this->height = $obj->height; + $this->height_units = $obj->height_units; - $this->surface = $obj->surface; - $this->surface_units = $obj->surface_units; - $this->volume = $obj->volume; + $this->surface = $obj->surface; + $this->surface_units = $obj->surface_units; + $this->volume = $obj->volume; $this->volume_units = $obj->volume_units; - $this->barcode = $obj->barcode; + $this->barcode = $obj->barcode; $this->barcode_type = $obj->fk_barcode_type; $this->accountancy_code_buy = $obj->accountancy_code_buy; - $this->accountancy_code_sell = $obj->accountancy_code_sell; - $this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; + $this->accountancy_code_sell = $obj->accountancy_code_sell; + $this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; $this->accountancy_code_sell_export = $obj->accountancy_code_sell_export; $this->fk_default_warehouse = $obj->fk_default_warehouse; $this->seuil_stock_alerte = $obj->seuil_stock_alerte; $this->desiredstock = $obj->desiredstock; $this->stock_reel = $obj->stock; - $this->pmp = $obj->pmp; + $this->pmp = $obj->pmp; $this->date_creation = $obj->datec; $this->date_modification = $obj->tms; @@ -2425,38 +2425,38 @@ class Product extends CommonObject global $user; $sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_customers, COUNT(DISTINCT p.rowid) as nb,"; - $sql.= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd"; - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pd"; + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE p.rowid = pd.fk_propal"; - $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - $sql.= " AND pd.fk_product = ".$this->id; + $sql .= " WHERE p.rowid = pd.fk_propal"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + $sql .= " AND pd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } //$sql.= " AND pr.fk_statut != 0"; if ($socid > 0) { - $sql.= " AND p.fk_soc = ".$socid; + $sql .= " AND p.fk_soc = ".$socid; } $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_propale['customers']=$obj->nb_customers; - $this->stats_propale['nb']=$obj->nb; - $this->stats_propale['rows']=$obj->nb_rows; - $this->stats_propale['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_propale['customers'] = $obj->nb_customers; + $this->stats_propale['nb'] = $obj->nb; + $this->stats_propale['rows'] = $obj->nb_rows; + $this->stats_propale['qty'] = $obj->qty ? $obj->qty : 0; // if it's a virtual product, maybe it is in proposal by extension - if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { $TFather = $this->getFather(); if (is_array($TFather) && !empty($TFather)) { - foreach($TFather as &$fatherData) { + foreach ($TFather as &$fatherData) { $pFather = new Product($this->db); $pFather->id = $fatherData['id']; $qtyCoef = $fatherData['qty']; @@ -2464,10 +2464,10 @@ class Product extends CommonObject if ($fatherData['incdec']) { $pFather->load_stats_propale($socid); - $this->stats_propale['customers']+=$pFather->stats_propale['customers']; - $this->stats_propale['nb']+=$pFather->stats_propale['nb']; - $this->stats_propale['rows']+=$pFather->stats_propale['rows']; - $this->stats_propale['qty']+=$pFather->stats_propale['qty'] * $qtyCoef; + $this->stats_propale['customers'] += $pFather->stats_propale['customers']; + $this->stats_propale['nb'] += $pFather->stats_propale['nb']; + $this->stats_propale['rows'] += $pFather->stats_propale['rows']; + $this->stats_propale['qty'] += $pFather->stats_propale['qty'] * $qtyCoef; } } } @@ -2477,7 +2477,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2542,43 +2542,43 @@ class Product extends CommonObject public function load_stats_commande($socid = 0, $filtrestatut = '', $forVirtualStock = 0) { // phpcs:enable - global $conf,$user; + global $conf, $user; $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; - $sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE c.rowid = cd.fk_commande"; - $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; - $sql.= " AND cd.fk_product = ".$this->id; + $sql .= " WHERE c.rowid = cd.fk_commande"; + $sql .= " AND c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { - $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql.= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_soc = ".$socid; } if ($filtrestatut <> '') { - $sql.= " AND c.fk_statut in (".$filtrestatut.")"; + $sql .= " AND c.fk_statut in (".$filtrestatut.")"; } $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_commande['customers']=$obj->nb_customers; - $this->stats_commande['nb']=$obj->nb; - $this->stats_commande['rows']=$obj->nb_rows; - $this->stats_commande['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_commande['customers'] = $obj->nb_customers; + $this->stats_commande['nb'] = $obj->nb; + $this->stats_commande['rows'] = $obj->nb_rows; + $this->stats_commande['qty'] = $obj->qty ? $obj->qty : 0; // if it's a virtual product, maybe it is in order by extension - if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { $TFather = $this->getFather(); if (is_array($TFather) && !empty($TFather)) { - foreach($TFather as &$fatherData) { + foreach ($TFather as &$fatherData) { $pFather = new Product($this->db); $pFather->id = $fatherData['id']; $qtyCoef = $fatherData['qty']; @@ -2694,48 +2694,48 @@ class Product extends CommonObject public function load_stats_sending($socid = 0, $filtrestatut = '', $forVirtualStock = 0, $filterShipmentStatus = '') { // phpcs:enable - global $conf,$user; + global $conf, $user; $sql = "SELECT COUNT(DISTINCT e.fk_soc) as nb_customers, COUNT(DISTINCT e.rowid) as nb,"; - $sql.= " COUNT(ed.rowid) as nb_rows, SUM(ed.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql.= ", ".MAIN_DB_PREFIX."commandedet as cd"; - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."expedition as e"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " COUNT(ed.rowid) as nb_rows, SUM(ed.qty) as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= ", ".MAIN_DB_PREFIX."commandedet as cd"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE e.rowid = ed.fk_expedition"; - $sql.= " AND c.rowid = cd.fk_commande"; - $sql.= " AND e.fk_soc = s.rowid"; - $sql.= " AND e.entity IN (".getEntity('expedition').")"; - $sql.= " AND ed.fk_origin_line = cd.rowid"; - $sql.= " AND cd.fk_product = ".$this->id; + $sql .= " WHERE e.rowid = ed.fk_expedition"; + $sql .= " AND c.rowid = cd.fk_commande"; + $sql .= " AND e.fk_soc = s.rowid"; + $sql .= " AND e.entity IN (".getEntity('expedition').")"; + $sql .= " AND ed.fk_origin_line = cd.rowid"; + $sql .= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { - $sql.= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql.= " AND e.fk_soc = ".$socid; + $sql .= " AND e.fk_soc = ".$socid; } if ($filtrestatut <> '') { - $sql.= " AND c.fk_statut in (".$filtrestatut.")"; + $sql .= " AND c.fk_statut in (".$filtrestatut.")"; } - if (!empty($filterShipmentStatus)) $sql.= " AND e.fk_statut IN (" . $filterShipmentStatus . ")"; + if (!empty($filterShipmentStatus)) $sql .= " AND e.fk_statut IN (".$filterShipmentStatus.")"; $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_expedition['customers']=$obj->nb_customers; - $this->stats_expedition['nb']=$obj->nb; - $this->stats_expedition['rows']=$obj->nb_rows; - $this->stats_expedition['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_expedition['customers'] = $obj->nb_customers; + $this->stats_expedition['nb'] = $obj->nb; + $this->stats_expedition['rows'] = $obj->nb_rows; + $this->stats_expedition['qty'] = $obj->qty ? $obj->qty : 0; // if it's a virtual product, maybe it is in sending by extension - if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { $TFather = $this->getFather(); if (is_array($TFather) && !empty($TFather)) { - foreach($TFather as &$fatherData) { + foreach ($TFather as &$fatherData) { $pFather = new Product($this->db); $pFather->id = $fatherData['id']; $qtyCoef = $fatherData['qty']; @@ -2743,10 +2743,10 @@ class Product extends CommonObject if ($fatherData['incdec']) { $pFather->load_stats_sending($socid, $filtrestatut, $forVirtualStock); - $this->stats_expedition['customers']+=$pFather->stats_expedition['customers']; - $this->stats_expedition['nb']+=$pFather->stats_expedition['nb']; - $this->stats_expedition['rows']+=$pFather->stats_expedition['rows']; - $this->stats_expedition['qty']+=$pFather->stats_expedition['qty'] * $qtyCoef; + $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; + $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; + $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; + $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; } } } @@ -2755,7 +2755,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2822,38 +2822,38 @@ class Product extends CommonObject global $user; $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; - $sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE c.rowid = cd.fk_contrat"; - $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('contract').")"; - $sql.= " AND cd.fk_product = ".$this->id; + $sql .= " WHERE c.rowid = cd.fk_contrat"; + $sql .= " AND c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('contract').")"; + $sql .= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } //$sql.= " AND c.statut != 0"; if ($socid > 0) { - $sql.= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_soc = ".$socid; } $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_contrat['customers']=$obj->nb_customers; - $this->stats_contrat['nb']=$obj->nb; - $this->stats_contrat['rows']=$obj->nb_rows; - $this->stats_contrat['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_contrat['customers'] = $obj->nb_customers; + $this->stats_contrat['nb'] = $obj->nb; + $this->stats_contrat['rows'] = $obj->nb_rows; + $this->stats_contrat['qty'] = $obj->qty ? $obj->qty : 0; // if it's a virtual product, maybe it is in contract by extension - if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { $TFather = $this->getFather(); if (is_array($TFather) && !empty($TFather)) { - foreach($TFather as &$fatherData) { + foreach ($TFather as &$fatherData) { $pFather = new Product($this->db); $pFather->id = $fatherData['id']; $qtyCoef = $fatherData['qty']; @@ -2861,10 +2861,10 @@ class Product extends CommonObject if ($fatherData['incdec']) { $pFather->load_stats_contrat($socid); - $this->stats_contrat['customers']+=$pFather->stats_contrat['customers']; - $this->stats_contrat['nb']+=$pFather->stats_contrat['nb']; - $this->stats_contrat['rows']+=$pFather->stats_contrat['rows']; - $this->stats_contrat['qty']+=$pFather->stats_contrat['qty'] * $qtyCoef; + $this->stats_contrat['customers'] += $pFather->stats_contrat['customers']; + $this->stats_contrat['nb'] += $pFather->stats_contrat['nb']; + $this->stats_contrat['rows'] += $pFather->stats_contrat['rows']; + $this->stats_contrat['qty'] += $pFather->stats_contrat['qty'] * $qtyCoef; } } } @@ -2873,7 +2873,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->error().' sql='.$sql; + $this->error = $this->db->error().' sql='.$sql; return -1; } } @@ -2891,19 +2891,19 @@ class Product extends CommonObject global $db, $conf, $user; $sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_customers, COUNT(DISTINCT f.rowid) as nb,"; - $sql.= " COUNT(fd.rowid) as nb_rows, SUM(".$db->ifsql('f.type != 2', 'fd.qty', 'fd.qty * -1').") as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; - $sql.= ", ".MAIN_DB_PREFIX."facture as f"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " COUNT(fd.rowid) as nb_rows, SUM(".$db->ifsql('f.type != 2', 'fd.qty', 'fd.qty * -1').") as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; + $sql .= ", ".MAIN_DB_PREFIX."facture as f"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE f.rowid = fd.fk_facture"; - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - $sql.= " AND fd.fk_product = ".$this->id; + $sql .= " WHERE f.rowid = fd.fk_facture"; + $sql .= " AND f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= " AND fd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } //$sql.= " AND f.fk_statut != 0"; if ($socid > 0) { @@ -2911,18 +2911,18 @@ class Product extends CommonObject } $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_facture['customers']=$obj->nb_customers; - $this->stats_facture['nb']=$obj->nb; - $this->stats_facture['rows']=$obj->nb_rows; - $this->stats_facture['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_facture['customers'] = $obj->nb_customers; + $this->stats_facture['nb'] = $obj->nb; + $this->stats_facture['rows'] = $obj->nb_rows; + $this->stats_facture['qty'] = $obj->qty ? $obj->qty : 0; // if it's a virtual product, maybe it is in invoice by extension - if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { $TFather = $this->getFather(); if (is_array($TFather) && !empty($TFather)) { - foreach($TFather as &$fatherData) { + foreach ($TFather as &$fatherData) { $pFather = new Product($this->db); $pFather->id = $fatherData['id']; $qtyCoef = $fatherData['qty']; @@ -2930,10 +2930,10 @@ class Product extends CommonObject if ($fatherData['incdec']) { $pFather->load_stats_facture($socid); - $this->stats_facture['customers']+=$pFather->stats_facture['customers']; - $this->stats_facture['nb']+=$pFather->stats_facture['nb']; - $this->stats_facture['rows']+=$pFather->stats_facture['rows']; - $this->stats_facture['qty']+=$pFather->stats_facture['qty'] * $qtyCoef; + $this->stats_facture['customers'] += $pFather->stats_facture['customers']; + $this->stats_facture['nb'] += $pFather->stats_facture['nb']; + $this->stats_facture['rows'] += $pFather->stats_facture['rows']; + $this->stats_facture['qty'] += $pFather->stats_facture['qty'] * $qtyCoef; } } } @@ -2942,7 +2942,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -3391,38 +3391,38 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(c.date_contrat, '%Y%m')"; if ($mode == 'bynumber') { - $sql.= ", count(DISTINCT c.rowid)"; + $sql .= ", count(DISTINCT c.rowid)"; } - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as d, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as d, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; if ($filteronproducttype >= 0) { - $sql.=", ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; } if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE c.entity IN (".getEntity('contract').")"; - $sql.= " AND c.rowid = d.fk_contrat"; + $sql .= " WHERE c.entity IN (".getEntity('contract').")"; + $sql .= " AND c.rowid = d.fk_contrat"; if ($this->id > 0) { - $sql.= " AND d.fk_product =".$this->id; + $sql .= " AND d.fk_product =".$this->id; } else { - $sql.=" AND d.fk_product > 0"; + $sql .= " AND d.fk_product > 0"; } if ($filteronproducttype >= 0) { - $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; + $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; } - $sql.= " AND c.fk_soc = s.rowid"; + $sql .= " AND c.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql.= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_soc = ".$socid; } - $sql.=$morefilter; - $sql.= " GROUP BY date_format(c.date_contrat,'%Y%m')"; - $sql.= " ORDER BY date_format(c.date_contrat,'%Y%m') DESC"; + $sql .= $morefilter; + $sql .= " GROUP BY date_format(c.date_contrat,'%Y%m')"; + $sql .= " ORDER BY date_format(c.date_contrat,'%Y%m') DESC"; return $this->_get_stats($sql, $mode, $year); } @@ -3618,7 +3618,7 @@ class Product extends CommonObject // phpcs:enable global $conf; - $now=dol_now(); + $now = dol_now(); dol_syslog(get_class($this)."::add_fournisseur id_fourn = ".$id_fourn." ref_fourn=".$ref_fourn." quantity=".$quantity, LOG_DEBUG); @@ -3627,13 +3627,13 @@ class Product extends CommonObject if ($ref_fourn) { $sql = "SELECT rowid, fk_product"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " WHERE fk_soc = ".$id_fourn; - $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; - $sql.= " AND fk_product != ".$this->id; - $sql.= " AND entity IN (".getEntity('productsupplierprice').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; + $sql .= " WHERE fk_soc = ".$id_fourn; + $sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; + $sql .= " AND fk_product != ".$this->id; + $sql .= " AND entity IN (".getEntity('productsupplierprice').")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); if ($obj) { @@ -3646,40 +3646,40 @@ class Product extends CommonObject } $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " WHERE fk_soc = ".$id_fourn; - if ($ref_fourn) { $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; - } else { $sql.= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; + $sql .= " WHERE fk_soc = ".$id_fourn; + if ($ref_fourn) { $sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; + } else { $sql .= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; } - $sql.= " AND quantity = ".$quantity; - $sql.= " AND fk_product = ".$this->id; - $sql.= " AND entity IN (".getEntity('productsupplierprice').")"; + $sql .= " AND quantity = ".$quantity; + $sql .= " AND fk_product = ".$this->id; + $sql .= " AND entity IN (".getEntity('productsupplierprice').")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); // The reference supplier does not exist, we create it for this product. - if (! $obj) { + if (!$obj) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; - $sql.= "datec"; - $sql.= ", entity"; - $sql.= ", fk_product"; - $sql.= ", fk_soc"; - $sql.= ", ref_fourn"; - $sql.= ", quantity"; - $sql.= ", fk_user"; - $sql.= ", tva_tx"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($now)."'"; - $sql.= ", ".$conf->entity; - $sql.= ", ".$this->id; - $sql.= ", ".$id_fourn; - $sql.= ", '".$this->db->escape($ref_fourn)."'"; - $sql.= ", ".$quantity; - $sql.= ", ".$user->id; - $sql.= ", 0"; - $sql.= ")"; + $sql .= "datec"; + $sql .= ", entity"; + $sql .= ", fk_product"; + $sql .= ", fk_soc"; + $sql .= ", ref_fourn"; + $sql .= ", quantity"; + $sql .= ", fk_user"; + $sql .= ", tva_tx"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($now)."'"; + $sql .= ", ".$conf->entity; + $sql .= ", ".$this->id; + $sql .= ", ".$id_fourn; + $sql .= ", '".$this->db->escape($ref_fourn)."'"; + $sql .= ", ".$quantity; + $sql .= ", ".$user->id; + $sql .= ", 0"; + $sql .= ")"; if ($this->db->query($sql)) { $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); @@ -3756,7 +3756,7 @@ class Product extends CommonObject $this->db->begin(); // prices - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_price ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price ("; $sql .= " entity"; $sql .= ", fk_product"; $sql .= ", date_price"; @@ -3785,8 +3785,8 @@ class Product extends CommonObject $sql .= ")"; $sql .= " SELECT"; $sql .= " entity"; - $sql .= ", " . $toId; - $sql .= ", '" . $this->db->idate($now) . "'"; + $sql .= ", ".$toId; + $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", price_level"; $sql .= ", price"; $sql .= ", price_ttc"; @@ -3800,7 +3800,7 @@ class Product extends CommonObject $sql .= ", localtax1_type"; $sql .= ", localtax2_tx"; $sql .= ", localtax2_type"; - $sql .= ", " . $user->id; + $sql .= ", ".$user->id; $sql .= ", tosell"; $sql .= ", price_by_qty"; $sql .= ", fk_price_expression"; @@ -3809,11 +3809,11 @@ class Product extends CommonObject $sql .= ", multicurrency_tx"; $sql .= ", multicurrency_price"; $sql .= ", multicurrency_price_ttc"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price"; - $sql .= " WHERE fk_product = ". $fromId; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; + $sql .= " WHERE fk_product = ".$fromId; $sql .= " ORDER BY date_price DESC"; - if ($conf->global->PRODUIT_MULTIPRICES_LIMIT>0) { - $sql .= " LIMIT " . $conf->global->PRODUIT_MULTIPRICES_LIMIT; + if ($conf->global->PRODUIT_MULTIPRICES_LIMIT > 0) { + $sql .= " LIMIT ".$conf->global->PRODUIT_MULTIPRICES_LIMIT; } dol_syslog(__METHOD__, LOG_DEBUG); @@ -3917,40 +3917,40 @@ class Product extends CommonObject public function fetch_prod_arbo($prod, $compl_path = "", $multiply = 1, $level = 1, $id_parent = 0) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; $tmpproduct = null; //var_dump($prod); - foreach($prod as $id_product => $desc_pere) // $id_product is 0 (first call starting with root top) or an id of a sub_product + foreach ($prod as $id_product => $desc_pere) // $id_product is 0 (first call starting with root top) or an id of a sub_product { if (is_array($desc_pere)) // If desc_pere is an array, this means it's a child { - $id=(! empty($desc_pere[0]) ? $desc_pere[0] :''); - $nb=(! empty($desc_pere[1]) ? $desc_pere[1] :''); - $type=(! empty($desc_pere[2]) ? $desc_pere[2] :''); - $label=(! empty($desc_pere[3]) ? $desc_pere[3] :''); - $incdec=!empty($desc_pere[4]) ? $desc_pere[4] : 0; + $id = (!empty($desc_pere[0]) ? $desc_pere[0] : ''); + $nb = (!empty($desc_pere[1]) ? $desc_pere[1] : ''); + $type = (!empty($desc_pere[2]) ? $desc_pere[2] : ''); + $label = (!empty($desc_pere[3]) ? $desc_pere[3] : ''); + $incdec = !empty($desc_pere[4]) ? $desc_pere[4] : 0; - if ($multiply < 1) { $multiply=1; + if ($multiply < 1) { $multiply = 1; } //print "XXX We add id=".$id." - label=".$label." - nb=".$nb." - multiply=".$multiply." fullpath=".$compl_path.$label."\n"; - if (is_null($tmpproduct)) $tmpproduct = new Product($this->db); // So we initialize tmpproduct only once for all loop. - $tmpproduct->fetch($id); // Load product to get ->ref - $tmpproduct->load_stock('nobatch,novirtual'); // Load stock to get true ->stock_reel + if (is_null($tmpproduct)) $tmpproduct = new Product($this->db); // So we initialize tmpproduct only once for all loop. + $tmpproduct->fetch($id); // Load product to get ->ref + $tmpproduct->load_stock('nobatch,novirtual'); // Load stock to get true ->stock_reel //$this->fetch($id); // Load product to get ->ref //$this->load_stock('nobatch,novirtual'); // Load stock to get true ->stock_reel - $this->res[]= array( - 'id'=>$id, // Id product + $this->res[] = array( + 'id'=>$id, // Id product 'id_parent'=>$id_parent, - 'ref'=>$tmpproduct->ref, // Ref product - 'nb'=>$nb, // Nb of units that compose parent product - 'nb_total'=>$nb*$multiply, // Nb of units for all nb of product - 'stock'=>$tmpproduct->stock_reel, // Stock - 'stock_alert'=>$tmpproduct->seuil_stock_alerte, // Stock alert + 'ref'=>$tmpproduct->ref, // Ref product + 'nb'=>$nb, // Nb of units that compose parent product + 'nb_total'=>$nb * $multiply, // Nb of units for all nb of product + 'stock'=>$tmpproduct->stock_reel, // Stock + 'stock_alert'=>$tmpproduct->seuil_stock_alerte, // Stock alert 'label'=>$label, - 'fullpath'=>$compl_path.$label, // Label - 'type'=>$type, // Nb of units that compose parent product + 'fullpath'=>$compl_path.$label, // Label + 'type'=>$type, // Nb of units that compose parent product 'desiredstock'=>$tmpproduct->desiredstock, 'level'=>$level, 'incdec'=>$incdec, @@ -4202,81 +4202,81 @@ class Product extends CommonObject global $conf, $langs, $hookmanager; include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; - $result=''; - $newref=$this->ref; - if ($maxlength) { $newref=dol_trunc($newref, $maxlength, 'middle'); + $result = ''; + $newref = $this->ref; + if ($maxlength) { $newref = dol_trunc($newref, $maxlength, 'middle'); } - if ($this->type == Product::TYPE_PRODUCT) { $label = '' . $langs->trans("ShowProduct") . ''; + if ($this->type == Product::TYPE_PRODUCT) { $label = ''.$langs->trans("ShowProduct").''; } - if ($this->type == Product::TYPE_SERVICE) { $label = '' . $langs->trans("ShowService") . ''; + if ($this->type == Product::TYPE_SERVICE) { $label = ''.$langs->trans("ShowService").''; } - if (! empty($this->ref)) { - $label .= '
' . $langs->trans('ProductRef') . ': ' . $this->ref; + if (!empty($this->ref)) { + $label .= '
'.$langs->trans('ProductRef').': '.$this->ref; } - if (! empty($this->label)) { - $label .= '
' . $langs->trans('ProductLabel') . ': ' . $this->label; + if (!empty($this->label)) { + $label .= '
'.$langs->trans('ProductLabel').': '.$this->label; } if ($this->type == Product::TYPE_PRODUCT) { if ($this->weight) { - $label.="
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); + $label .= "
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); } if ($this->length) { - $label.="
".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); + $label .= "
".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); } if ($this->width) { - $label.="
".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); + $label .= "
".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); } if ($this->height) { - $label.="
".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); + $label .= "
".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); } if ($this->surface) { - $label.="
".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); + $label .= "
".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); } if ($this->volume) { - $label.="
".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); + $label .= "
".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); } } - if ($this->type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (! empty($conf->productbatch->enabled)) { + if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + if (!empty($conf->productbatch->enabled)) { $langs->load("productbatch"); - $label.="
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); + $label .= "
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); } } //if ($this->type == Product::TYPE_SERVICE) //{ // //} - if (! empty($conf->accounting->enabled) && $this->status) { + if (!empty($conf->accounting->enabled) && $this->status) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label.= '
' . $langs->trans('ProductAccountancySellCode') . ': '. length_accountg($this->accountancy_code_sell); - if(!empty($conf->global->MAIN_FEATURES_LEVEL)) { - $label.= '
' . $langs->trans('ProductAccountancySellIntraCode') . ': '. length_accountg($this->accountancy_code_sell_export); - $label.= '
' . $langs->trans('ProductAccountancySellExportCode') . ': '. length_accountg($this->accountancy_code_sell_intra); + $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); + if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { + $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_export); + $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_intra); } } - if (! empty($conf->accounting->enabled) && $this->status_buy) { + if (!empty($conf->accounting->enabled) && $this->status_buy) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label.= '
' . $langs->trans('ProductAccountancyBuyCode') . ': '. length_accountg($this->accountancy_code_buy); + $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); } - if (! empty($this->entity)) { + if (!empty($this->entity)) { $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); - if ($this->nbphoto > 0) { $label .= '
' . $tmpphoto; + if ($this->nbphoto > 0) { $label .= '
'.$tmpphoto; } } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowProduct"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("ShowProduct"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; - $linkclose.= ' class="nowraponall classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; + $linkclose .= ' class="nowraponall classfortooltip"'; } else { @@ -4295,34 +4295,34 @@ class Product extends CommonObject if ($option !== 'nolink') { // Add param to save lastsearch_values or not - $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; + $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'; + if ($add_save_lastsearch_values) { $url .= '&save_lastsearch_values=1'; } } $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; - $result.=$linkstart; + $result .= $linkstart; if ($withpicto) { if ($this->type == Product::TYPE_PRODUCT) { - $result.=(img_object(($notooltip?'':$label), 'product', ($notooltip?'class="paddingright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1)); + $result .= (img_object(($notooltip ? '' : $label), 'product', ($notooltip ? 'class="paddingright"' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1)); } if ($this->type == Product::TYPE_SERVICE) { - $result.=(img_object(($notooltip?'':$label), 'service', ($notooltip?'class="paddinright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1)); + $result .= (img_object(($notooltip ? '' : $label), 'service', ($notooltip ? 'class="paddinright"' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1)); } } - $result.= $newref; - $result.= $linkend; + $result .= $newref; + $result .= $linkend; global $action; $hookmanager->initHooks(array('productdao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; } else { @@ -4430,26 +4430,26 @@ class Product extends CommonObject } } - $statuttrans=empty($status)?'status5':'status4'; + $statuttrans = empty($status) ? 'status5' : 'status4'; if ($status == 0) { // $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch" - if($type==0) { + if ($type == 0) { $labelStatus = $langs->trans('ProductStatusNotOnSellShort'); $labelStatusShort = $langs->trans('ProductStatusNotOnSell'); } - elseif($type == 1) { + elseif ($type == 1) { $labelStatus = $langs->trans('ProductStatusNotOnBuyShort'); $labelStatusShort = $langs->trans('ProductStatusNotOnBuy'); } - elseif($type == 2) { + elseif ($type == 2) { $labelStatus = $langs->trans('ProductStatusNotOnBatch'); $labelStatusShort = $langs->trans('ProductStatusNotOnBatchShort'); } } elseif ($status == 1) { // $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch" - if ($type==0) { + if ($type == 0) { $labelStatus = $langs->trans('ProductStatusOnSellShort'); $labelStatusShort = $langs->trans('ProductStatusOnSell'); } @@ -4685,10 +4685,10 @@ class Product extends CommonObject } if (!empty($conf->expedition->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $filterShipmentStatus = ''; if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { - $filterShipmentStatus = Expedition::STATUS_VALIDATED . ',' . Expedition::STATUS_CLOSED; + $filterShipmentStatus = Expedition::STATUS_VALIDATED.','.Expedition::STATUS_CLOSED; } elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { $filterShipmentStatus = Expedition::STATUS_CLOSED; } diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index e2e7745fd0d..3e4bffc967b 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -20,7 +20,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) { +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } @@ -70,10 +70,10 @@ if ($object->element == 'product') { print ''; print ''; } @@ -81,10 +81,10 @@ if ($object->element == 'stock') { print ''; print ''; } @@ -96,7 +96,7 @@ if ($object->element == 'stock') print ''; print ''; print ''; -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { print ''; print ''; // Serial / Eat-by date -if (! empty($conf->productbatch->enabled) && +if (!empty($conf->productbatch->enabled) && (($object->element == 'product' && $object->hasbatch()) || ($object->element == 'stock')) ) { print ''; - print 'element == 'stock'?'': ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; print ''; print ''; print ''; print ''; print ''; } // Label of mouvement of id of inventory - $valformovementlabel=((GETPOST("label") && (GETPOST('label') != $langs->trans("MovementCorrectStock", ''))) ? GETPOST("label") : $langs->trans("MovementCorrectStock", $productref)); + $valformovementlabel = ((GETPOST("label") && (GETPOST('label') != $langs->trans("MovementCorrectStock", ''))) ? GETPOST("label") : $langs->trans("MovementCorrectStock", $productref)); print ''; print ''; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("ProductAccountancySellCode").''; - if($type = 0) { - $accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell')?GETPOST('accountancy_code_sell', 'alpha'):$conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT); + if ($type = 0) { + $accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell') ?GETPOST('accountancy_code_sell', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT); } else { - $accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell')?GETPOST('accountancy_code_sell', 'alpha'):$conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT); + $accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell') ?GETPOST('accountancy_code_sell', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT); } print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, null, 1, 1, ''); print '
'.$langs->trans("ProductAccountancySellIntraCode").''; - if($type = 0) { - $accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra')?GETPOST('accountancy_code_sell_intra', 'alpha'):$conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT); + if ($type = 0) { + $accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra') ?GETPOST('accountancy_code_sell_intra', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT); } else { - $accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra')?GETPOST('accountancy_code_sell_intra', 'alpha'):$conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT); + $accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra') ?GETPOST('accountancy_code_sell_intra', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT); } print $formaccounting->select_account($accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, null, 1, 1, ''); print '
'.$langs->trans("ProductAccountancySellExportCode").''; - if($type = 0) + if ($type = 0) { - $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export')?GETPOST('accountancy_code_sell_export', 'alpha'):$conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT); + $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ?GETPOST('accountancy_code_sell_export', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT); } else { - $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export')?GETPOST('accountancy_code_sell_export', 'alpha'):$conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT); + $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ?GETPOST('accountancy_code_sell_export', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT); } print $formaccounting->select_account($accountancy_code_sell_export, 'accountancy_code_sell_export', 1, null, 1, 1, ''); print '
'.$langs->trans("Warehouse").''; - print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid", 'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot', 'int'):($object->element=='product' && $object->fk_default_warehouse?$object->fk_default_warehouse:'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100'); + print $formproduct->selectWarehouses((GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ?GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100'); print '   '; print ''.$langs->trans("Product").''; - $form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500'); + $form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES) ? '0' : ''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500'); print '   '; print '
'.$langs->trans("UnitPurchaseValue").''.$langs->trans('Project').''; @@ -106,36 +106,36 @@ if (! empty($conf->projet->enabled)) print '
'; + print 'element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; print ''; print '
'.$langs->trans("EatByDate").''; - $eatbyselected=dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); + $eatbyselected = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); print $form->selectDate($eatbyselected, 'eatby', '', '', 1, ""); print ''.$langs->trans("SellByDate").''; - $sellbyselected=dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); + $sellbyselected = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); print $form->selectDate($sellbyselected, 'sellby', '', '', 1, ""); print '
'.$langs->trans("MovementLabel").''; print ''; print ''.$langs->trans("InventoryCode").''.$langs->trans("InventoryCode").'
'; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index cb6976c4b75..854fc1e6b97 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -20,7 +20,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) { +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } @@ -29,23 +29,23 @@ if (empty($conf) || ! is_object($conf)) { element == 'product') $productref = $object->ref; $langs->load("productbatch"); if (empty($id)) $id = $object->id; - $pdluoid=GETPOST('pdluoid', 'int'); + $pdluoid = GETPOST('pdluoid', 'int'); $pdluo = new Productbatch($db); if ($pdluoid > 0) { - $result=$pdluo->fetch($pdluoid); + $result = $pdluo->fetch($pdluoid); if ($result > 0) { - $pdluoid=$pdluo->id; + $pdluoid = $pdluo->id; } else { @@ -74,14 +74,14 @@ if ($object->element == 'product') { print ''.$langs->trans("WarehouseSource").''; print ''; - print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid", 'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot', 'int'):($object->element=='product' && $object->fk_default_warehouse?$object->fk_default_warehouse:'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1); + print $formproduct->selectWarehouses((GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ?GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1); print ''; } if ($object->element == 'stock') { print ''.$langs->trans("Product").''; print ''; - $form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500'); + $form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES) ? '0' : ''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500'); print ''; } @@ -92,44 +92,44 @@ if ($object->element == 'stock') print ''; // Serial / Eat-by date -if (! empty($conf->productbatch->enabled) && +if (!empty($conf->productbatch->enabled) && (($object->element == 'product' && $object->hasbatch()) || ($object->element == 'stock')) ) { print ''; - print 'element == 'stock'?'': ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; + print 'element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; if ($pdluoid > 0) { // If form was opened for a specific pdluoid, field is disabled - print ''; - print ''; + print ''; + print ''; } else { - print ''; + print ''; } print ''; print ''; print ''; print ''.$langs->trans("EatByDate").''; - print $form->selectDate(($d_eatby?$d_eatby:$pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled + print $form->selectDate(($d_eatby ? $d_eatby : $pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled print ''; print ''.$langs->trans("SellByDate").''; - print $form->selectDate(($d_sellby?$d_sellby:$pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled + print $form->selectDate(($d_sellby ? $d_sellby : $pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled print ''; print ''; } // Label - $valformovementlabel=(GETPOST("label")?GETPOST("label"):$langs->trans("MovementTransferStock", $productref)); + $valformovementlabel = (GETPOST("label") ?GETPOST("label") : $langs->trans("MovementTransferStock", $productref)); print ''; print ''.$langs->trans("MovementLabel").''; print ''; print ''; print ''; - print ''.$langs->trans("InventoryCode").''; + print ''.$langs->trans("InventoryCode").''; print ''; print ''; diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 36887b736af..c08abe24c07 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -32,8 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $langs->loadLangs(array("admin", "companies", "other")); -$action=GETPOST('action', 'alpha'); -$value=GETPOST('value', 'alpha'); +$action = GETPOST('action', 'alpha'); +$value = GETPOST('value', 'alpha'); if (!$user->admin) accessforbidden(); @@ -79,8 +79,8 @@ if ($action == 'updateoptions') { $companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT', 'alpha'); $res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -94,8 +94,8 @@ if ($action == 'updateoptions') { $contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT', 'alpha'); $res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -109,8 +109,8 @@ if ($action == 'updateoptions') { $customertypedefault = GETPOST('defaultcustomertype', 'int'); $res = dolibarr_set_const($db, "THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT", $customertypedefault, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -127,25 +127,25 @@ if ($action == 'set') $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); - $type='company'; + $type = 'company'; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); - $sql.= ")"; + $sql .= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; + $sql .= ($label ? "'".$db->escape($label)."'" : 'null').", "; + $sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null"); + $sql .= ")"; - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); } // Disable a document generator module -if ($action== 'del') +if ($action == 'del') { - $type='company'; + $type = 'company'; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql.= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity; - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); + $sql .= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity; + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); } // Define default generator @@ -159,21 +159,21 @@ if ($action == 'setdoc') dolibarr_set_const($db, "COMPANY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity); // On active le modele - $type='company'; + $type = 'company'; $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql_del.= " WHERE nom = '".$db->escape(GETPOST('value', 'alpha'))."'"; - $sql_del.= " AND type = '".$type."'"; - $sql_del.= " AND entity = ".$conf->entity; + $sql_del .= " WHERE nom = '".$db->escape(GETPOST('value', 'alpha'))."'"; + $sql_del .= " AND type = '".$type."'"; + $sql_del .= " AND entity = ".$conf->entity; dol_syslog("societe.php ".$sql); - $result1=$db->query($sql_del); + $result1 = $db->query($sql_del); $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); - $sql.= ")"; + $sql .= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", "; + $sql .= ($label ? "'".$db->escape($label)."'" : 'null').", "; + $sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null"); + $sql .= ")"; dol_syslog("societe.php", LOG_DEBUG); - $result2=$db->query($sql); + $result2 = $db->query($sql); if ($result1 && $result2) { $db->commit(); @@ -185,11 +185,11 @@ if ($action == 'setdoc') } //Activate Set ref in list -if ($action=="setaddrefinlist") { +if ($action == "setaddrefinlist") { $setaddrefinlist = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -200,11 +200,11 @@ if ($action=="setaddrefinlist") { } //Activate Set adress in list -if ($action=="setaddadressinlist") { +if ($action == "setaddadressinlist") { $val = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -215,11 +215,11 @@ if ($action=="setaddadressinlist") { } //Activate Ask For Preferred Shipping Method -if ($action=="setaskforshippingmet") { +if ($action == "setaskforshippingmet") { $setaskforshippingmet = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -230,11 +230,11 @@ if ($action=="setaskforshippingmet") { } //Activate "Disable prospect/customer type" -if ($action=="setdisableprospectcustomer") { +if ($action == "setdisableprospectcustomer") { $setdisableprospectcustomer = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -249,7 +249,7 @@ if ($action == 'setprofid') { $status = GETPOST('status', 'alpha'); - $idprof="SOCIETE_".$value."_UNIQUE"; + $idprof = "SOCIETE_".$value."_UNIQUE"; if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { //header("Location: ".$_SERVER["PHP_SELF"]); @@ -266,7 +266,7 @@ if ($action == 'setprofidmandatory') { $status = GETPOST('status', 'alpha'); - $idprof="SOCIETE_".$value."_MANDATORY"; + $idprof = "SOCIETE_".$value."_MANDATORY"; if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { //header("Location: ".$_SERVER["PHP_SELF"]); @@ -283,7 +283,7 @@ if ($action == 'setprofidinvoicemandatory') { $status = GETPOST('status', 'alpha'); - $idprof="SOCIETE_".$value."_INVOICE_MANDATORY"; + $idprof = "SOCIETE_".$value."_INVOICE_MANDATORY"; if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { //header("Location: ".$_SERVER["PHP_SELF"]); @@ -310,11 +310,11 @@ if ($action == 'sethideinactivethirdparty') dol_print_error($db); } } -if($action=='setonsearchandlistgooncustomerorsuppliercard'){ +if ($action == 'setonsearchandlistgooncustomerorsuppliercard') { $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -330,12 +330,12 @@ if($action=='setonsearchandlistgooncustomerorsuppliercard'){ clearstatcache(); -$form=new Form($db); +$form = new Form($db); -$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers|ES:Configuración_del_módulo_terceros'; +$help_url = 'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers|ES:Configuración_del_módulo_terceros'; llxHeader('', $langs->trans("CompanySetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("CompanySetup"), $linkback, 'title_setup'); @@ -343,8 +343,8 @@ $head = societe_admin_prepare_head(); dol_fiche_head($head, 'general', $langs->trans("ThirdParties"), -1, 'company'); -$dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); -foreach ($conf->modules_parts['models'] as $mo) $dirsociete[]=$mo.'core/modules/societe/'; //Add more models +$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); +foreach ($conf->modules_parts['models'] as $mo) $dirsociete[] = $mo.'core/modules/societe/'; //Add more models // Module to manage customer/supplier code @@ -370,16 +370,16 @@ foreach ($dirsociete as $dirroot) if (is_resource($handle)) { // Loop on each module find in opened directory - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); try { dol_include_once($dirroot.$file.'.php'); } - catch(Exception $e) + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -387,7 +387,7 @@ foreach ($dirsociete as $dirroot) $modCodeTiers = new $file; // Show modules according to features level - if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; $arrayofmodules[$file] = $modCodeTiers; @@ -399,7 +399,7 @@ foreach ($dirsociete as $dirroot) $arrayofmodules = dol_sort_array($arrayofmodules, 'position'); -foreach($arrayofmodules as $file => $modCodeTiers) +foreach ($arrayofmodules as $file => $modCodeTiers) { print ''."\n"; print ''.$modCodeTiers->name.''."\n"; @@ -414,16 +414,16 @@ foreach($arrayofmodules as $file => $modCodeTiers) } else { - $disabled = (! empty($conf->multicompany->enabled) && (is_object($mc) && ! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false); + $disabled = (!empty($conf->multicompany->enabled) && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false); print ''; - if (! $disabled) print ''; + if (!$disabled) print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); - if (! $disabled) print ''; + if (!$disabled) print ''; print ''; } print ''; - $s=$modCodeTiers->getToolTip($langs, null, -1); + $s = $modCodeTiers->getToolTip($langs, null, -1); print $form->textwithpicto('', $s, 1); print ''; @@ -458,16 +458,16 @@ foreach ($dirsociete as $dirroot) $handle = @opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); try { dol_include_once($dirroot.$file.'.php'); } - catch(Exception $e) + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -484,7 +484,7 @@ foreach ($dirsociete as $dirroot) $arrayofmodules = dol_sort_array($arrayofmodules, 'position'); -foreach($arrayofmodules as $file => $modCodeCompta) +foreach ($arrayofmodules as $file => $modCodeCompta) { print ''; print ''.$modCodeCompta->name."\n"; @@ -505,7 +505,7 @@ foreach($arrayofmodules as $file => $modCodeCompta) print ''; } print ''; - $s=$modCodeCompta->getToolTip($langs, null, -1); + $s = $modCodeCompta->getToolTip($langs, null, -1); print $form->textwithpicto('', $s, 1); print ''; print "\n"; @@ -523,14 +523,14 @@ print load_fiche_titre($langs->trans("ModelModules"), '', ''); // Load array def with activated templates $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = 'company'"; -$sql.= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = 'company'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -557,30 +557,30 @@ foreach ($dirsociete as $dirroot) { $dir = dol_buildpath($dirroot.'doc/', 0); - $handle=@opendir($dir); + $handle = @opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (preg_match('/\.modules\.php$/i', $file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); try { dol_include_once($dirroot.'doc/'.$file); } - catch(Exception $e) + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } $module = new $classname($db); - $modulequalified=1; - if (! empty($module->version)) { - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - elseif ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if (!empty($module->version)) { + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + elseif ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; } if ($modulequalified) @@ -625,14 +625,14 @@ foreach ($dirsociete as $dirroot) } // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { - $htmltooltip.='
'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; + $htmltooltip .= '
'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; } - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("WatermarkOnDraft").': '.yn((! empty($module->option_draft_watermark)?$module->option_draft_watermark:''), 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraft").': '.yn((!empty($module->option_draft_watermark) ? $module->option_draft_watermark : ''), 1, 1); print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -642,11 +642,11 @@ foreach ($dirsociete as $dirroot) print ''; if ($module->type == 'pdf') { - $linkspec=''.img_object($langs->trans("Preview"), 'bill').''; + $linkspec = ''.img_object($langs->trans("Preview"), 'bill').''; } else { - $linkspec=img_object($langs->trans("PreviewNotAvailable"), 'generic'); + $linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic'); } print $linkspec; print ''; @@ -676,38 +676,38 @@ print ''.$langs->trans("MustBeMandatory").''; print ''.$langs->trans("MustBeInvoiceMandatory").''; print "\n"; -$profid['IDPROF1'][0]=$langs->trans("ProfId1"); -$profid['IDPROF1'][1]=$langs->transcountry('ProfId1', $mysoc->country_code); -$profid['IDPROF2'][0]=$langs->trans("ProfId2"); -$profid['IDPROF2'][1]=$langs->transcountry('ProfId2', $mysoc->country_code); -$profid['IDPROF3'][0]=$langs->trans("ProfId3"); -$profid['IDPROF3'][1]=$langs->transcountry('ProfId3', $mysoc->country_code); -$profid['IDPROF4'][0]=$langs->trans("ProfId4"); -$profid['IDPROF4'][1]=$langs->transcountry('ProfId4', $mysoc->country_code); -$profid['IDPROF5'][0]=$langs->trans("ProfId5"); -$profid['IDPROF5'][1]=$langs->transcountry('ProfId5', $mysoc->country_code); -$profid['IDPROF6'][0]=$langs->trans("ProfId6"); -$profid['IDPROF6'][1]=$langs->transcountry('ProfId6', $mysoc->country_code); -$profid['EMAIL'][0]=$langs->trans("EMail"); -$profid['EMAIL'][1]=$langs->trans('Email'); +$profid['IDPROF1'][0] = $langs->trans("ProfId1"); +$profid['IDPROF1'][1] = $langs->transcountry('ProfId1', $mysoc->country_code); +$profid['IDPROF2'][0] = $langs->trans("ProfId2"); +$profid['IDPROF2'][1] = $langs->transcountry('ProfId2', $mysoc->country_code); +$profid['IDPROF3'][0] = $langs->trans("ProfId3"); +$profid['IDPROF3'][1] = $langs->transcountry('ProfId3', $mysoc->country_code); +$profid['IDPROF4'][0] = $langs->trans("ProfId4"); +$profid['IDPROF4'][1] = $langs->transcountry('ProfId4', $mysoc->country_code); +$profid['IDPROF5'][0] = $langs->trans("ProfId5"); +$profid['IDPROF5'][1] = $langs->transcountry('ProfId5', $mysoc->country_code); +$profid['IDPROF6'][0] = $langs->trans("ProfId6"); +$profid['IDPROF6'][1] = $langs->transcountry('ProfId6', $mysoc->country_code); +$profid['EMAIL'][0] = $langs->trans("EMail"); +$profid['EMAIL'][1] = $langs->trans('Email'); -$nbofloop=count($profid); -foreach($profid as $key => $val) +$nbofloop = count($profid); +foreach ($profid as $key => $val) { - if ($profid[$key][1]!='-') + if ($profid[$key][1] != '-') { print ''; print ''.$profid[$key][0]."\n"; print $profid[$key][1]; print ''; - $idprof_unique ='SOCIETE_'.$key.'_UNIQUE'; - $idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY'; - $idprof_invoice_mandatory ='SOCIETE_'.$key.'_INVOICE_MANDATORY'; + $idprof_unique = 'SOCIETE_'.$key.'_UNIQUE'; + $idprof_mandatory = 'SOCIETE_'.$key.'_MANDATORY'; + $idprof_invoice_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY'; - $verif=(empty($conf->global->$idprof_unique)?false:true); - $mandatory=(empty($conf->global->$idprof_mandatory)?false:true); - $invoice_mandatory=(empty($conf->global->$idprof_invoice_mandatory)?false:true); + $verif = (empty($conf->global->$idprof_unique) ?false:true); + $mandatory = (empty($conf->global->$idprof_mandatory) ?false:true); + $invoice_mandatory = (empty($conf->global->$idprof_invoice_mandatory) ?false:true); if ($verif) { @@ -761,7 +761,7 @@ print "
\n"; print load_fiche_titre($langs->trans("Other"), '', ''); // Autres options -$form=new Form($db); +$form = new Form($db); print '
'; print ''; @@ -778,7 +778,7 @@ print ' '."\n"; print ''; print ''.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"), $langs->trans('UseSearchToSelectCompanyTooltip'), 1).' '; -if (! $conf->use_javascript_ajax) +if (!$conf->use_javascript_ajax) { print ''; print $langs->trans("NotAvailableWhenAjaxDisabled"); @@ -787,7 +787,7 @@ if (! $conf->use_javascript_ajax) else { print ''; - $arrval=array('0'=>$langs->trans("No"), + $arrval = array('0'=>$langs->trans("No"), '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')', '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', @@ -802,7 +802,7 @@ print ''; print ''; print ''.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"), $langs->trans('UseSearchToSelectContactTooltip'), 1).''; -if (! $conf->use_javascript_ajax) +if (!$conf->use_javascript_ajax) { print ''; print $langs->trans("NotAvailableWhenAjaxDisabled"); @@ -811,7 +811,7 @@ if (! $conf->use_javascript_ajax) else { print ''; - $arrval=array('0'=>$langs->trans("No"), + $arrval = array('0'=>$langs->trans("No"), '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')', '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 6e16e151593..c961b04d8ce 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -42,22 +42,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -$langs->loadLangs(array("companies","commercial","bills","banks","users")); -if (! empty($conf->categorie->enabled)) $langs->load("categories"); -if (! empty($conf->incoterm->enabled)) $langs->load("incoterm"); -if (! empty($conf->notification->enabled)) $langs->load("mails"); +$langs->loadLangs(array("companies", "commercial", "bills", "banks", "users")); +if (!empty($conf->categorie->enabled)) $langs->load("categories"); +if (!empty($conf->incoterm->enabled)) $langs->load("incoterm"); +if (!empty($conf->notification->enabled)) $langs->load("mails"); -$mesg=''; $error=0; $errors=array(); +$mesg = ''; $error = 0; $errors = array(); $action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $confirm = GETPOST('confirm'); -$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; -if (empty($socid) && $action == 'view') $action='create'; +$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); +if ($user->socid) $socid = $user->socid; +if (empty($socid) && $action == 'view') $action = 'create'; $object = new Societe($db); $extrafields = new ExtraFields($db); @@ -88,7 +88,7 @@ if (!empty($canvas)) // Security check $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas); -if(empty($user->rights->societe->contact->lire)) accessforbidden(); +if (empty($user->rights->societe->contact->lire)) accessforbidden(); @@ -151,7 +151,7 @@ dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; -dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); +dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); dol_fiche_end(); diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index 669f1d58c1a..77d6acdaeed 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -37,15 +37,15 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $langs->loadLangs(array('agenda', 'admin', 'other')); $def = array(); -$actiontest=GETPOST('test', 'alpha'); -$actionsave=GETPOST('save', 'alpha'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'useragenda'; // To manage different context of search +$actiontest = GETPOST('test', 'alpha'); +$actionsave = GETPOST('save', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useragenda'; // To manage different context of search -if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; -$MAXAGENDA=$conf->global->AGENDA_EXT_NB; +if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; +$MAXAGENDA = $conf->global->AGENDA_EXT_NB; // List of available colors -$colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5'); +$colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', 'A4A4A5'); // Security check $id = GETPOST('id', 'int'); @@ -54,25 +54,25 @@ $object->fetch($id, '', '', 1); $object->getrights(); // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) $socid = $user->socid; -$feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); +$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); // If user is not user that read and no permission to read other users, we stop -if (($object->id != $user->id) && (! $user->rights->user->user->lire)) +if (($object->id != $user->id) && (!$user->rights->user->user->lire)) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('usercard','useragenda','globalcard')); +$hookmanager->initHooks(array('usercard', 'useragenda', 'globalcard')); /* * Actions */ -$parameters=array('id'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid); +$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 (empty($reshook)) { @@ -97,16 +97,16 @@ if (empty($reshook)) { if (!empty($src) && !dol_is_url($src)) { setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors'); - $error ++; - $errorsaved ++; + $error++; + $errorsaved++; break; } - $tabparam['AGENDA_EXT_NAME_'.$id.'_'.$i]=$name; - $tabparam['AGENDA_EXT_SRC_'.$id.'_'.$i]=$src; - $tabparam['AGENDA_EXT_OFFSETTZ_'.$id.'_'.$i]=$offsettz; - $tabparam['AGENDA_EXT_COLOR_'.$id.'_'.$i]=$color; - $tabparam['AGENDA_EXT_ENABLED_'.$id.'_'.$i]=$enabled; + $tabparam['AGENDA_EXT_NAME_'.$id.'_'.$i] = $name; + $tabparam['AGENDA_EXT_SRC_'.$id.'_'.$i] = $src; + $tabparam['AGENDA_EXT_OFFSETTZ_'.$id.'_'.$i] = $offsettz; + $tabparam['AGENDA_EXT_COLOR_'.$id.'_'.$i] = $color; + $tabparam['AGENDA_EXT_ENABLED_'.$id.'_'.$i] = $enabled; $i++; } @@ -114,7 +114,7 @@ if (empty($reshook)) { if (!$error) { $result = dol_set_user_param($db, $conf, $object, $tabparam); if (!$result > 0) { - $error ++; + $error++; } } @@ -134,12 +134,12 @@ if (empty($reshook)) { * View */ -$form=new Form($db); -$formadmin=new FormAdmin($db); -$formother=new FormOther($db); +$form = new Form($db); +$formadmin = new FormAdmin($db); +$formother = new FormOther($db); -$arrayofjs=array(); -$arrayofcss=array(); +$arrayofjs = array(); +$arrayofcss = array(); llxHeader('', $langs->trans("UserSetup"), '', '', 0, 0, $arrayofjs, $arrayofcss); @@ -148,7 +148,7 @@ print ''; print ''; -$head=user_prepare_head($object); +$head = user_prepare_head($object); dol_fiche_head($head, 'extsites', $langs->trans("User"), -1, 'user'); @@ -167,8 +167,8 @@ print '
'; print ''.$langs->trans("AgendaExtSitesDesc")."
\n"; print "
\n"; -$selectedvalue=$conf->global->AGENDA_DISABLE_EXT; -if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1; +$selectedvalue = $conf->global->AGENDA_DISABLE_EXT; +if ($selectedvalue == 1) $selectedvalue = 0; else $selectedvalue = 1; print '
'; @@ -182,29 +182,29 @@ print "".$form->textwithpicto($langs->trans("FixTZ"), $langs->trans("FillFix print ''.$langs->trans("Color").''; print ""; -$i=1; +$i = 1; while ($i <= $MAXAGENDA) { - $key=$i; - $name='AGENDA_EXT_NAME_'.$id.'_'.$key; - $src='AGENDA_EXT_SRC_'.$id.'_'.$key; - $offsettz='AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key; - $color='AGENDA_EXT_COLOR_'.$id.'_'.$key; + $key = $i; + $name = 'AGENDA_EXT_NAME_'.$id.'_'.$key; + $src = 'AGENDA_EXT_SRC_'.$id.'_'.$key; + $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key; + $color = 'AGENDA_EXT_COLOR_'.$id.'_'.$key; print ''; // Nb print ''.$langs->trans("AgendaExtNb", $key).""; // Name - print ''; + print ''; // URL - print ''; + print ''; // Offset TZ - print ''; + print ''; // Color (Possible colors are limited by Google) print ''; //print $formadmin->selectColor($conf->global->$color, "google_agenda_color".$key, $colorlist); - print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key)?GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key):$object->conf->$color), "AGENDA_EXT_COLOR_".$id.'_'.$key, 'extsitesconfig', 1, '', 'hideifnotset'); + print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key) ?GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key) : $object->conf->$color), "AGENDA_EXT_COLOR_".$id.'_'.$key, 'extsitesconfig', 1, '', 'hideifnotset'); print ''; print ""; $i++;