diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 24c605bd930..0883f9f56bb 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -46,8 +46,8 @@ $action = GETPOST('action', 'aZ09'); // Parameters ACCOUNTING_* and others $list = array( - 'ACCOUNTING_LENGTH_GACCOUNT', - 'ACCOUNTING_LENGTH_AACCOUNT', + 'ACCOUNTING_LENGTH_GACCOUNT', + 'ACCOUNTING_LENGTH_AACCOUNT', // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc ); @@ -67,17 +67,17 @@ if ($action == 'update') { if (!$error) { - foreach ($list as $constname) - { - $constvalue = GETPOST($constname, 'alpha'); + foreach ($list as $constname) + { + $constvalue = GETPOST($constname, 'alpha'); - if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } - if ($error) { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + if ($error) { + setEventMessages($langs->trans("Error"), null, 'errors'); + } foreach ($list_binding as $constname) { @@ -96,46 +96,46 @@ if ($action == 'update') { } } - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } } if ($action == 'setlistsorttodo') { - $setlistsorttodo = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); - if (!$res > 0) - $error++; + $setlistsorttodo = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'mesgs'); - } + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } } if ($action == 'setlistsortdone') { - $setlistsortdone = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity); - if (!$res > 0) - $error++; - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'mesgs'); - } + $setlistsortdone = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } } if ($action == 'setmanagezero') { - $setmanagezero = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity); - if (!$res > 0) - $error++; - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'mesgs'); - } + $setmanagezero = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } } if ($action == 'setdisabledirectinput') { @@ -163,15 +163,15 @@ if ($action == 'setenabledraftexport') { } if ($action == 'setenablesubsidiarylist') { - $setenablesubsidiarylist = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity); - if (!$res > 0) - $error++; - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'mesgs'); - } + $setenablesubsidiarylist = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } } if ($action == 'setdisablebindingonsales') { diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 0f5acd96ae2..6b326ec872f 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -93,7 +93,7 @@ $formaccounting = new FormAccounting($db); 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_societe = ''; - $search_lineid = ''; + $search_lineid = ''; $search_ref = ''; $search_invoice = ''; $search_label = ''; @@ -203,7 +203,7 @@ if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } if ($search_lineid) { - $sql .= natural_search("fd.rowid", $search_lineid, 1); + $sql .= natural_search("fd.rowid", $search_lineid, 1); } if (strlen(trim($search_invoice))) { $sql .= natural_search("f.ref", $search_invoice); @@ -251,13 +251,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -309,9 +309,9 @@ if ($result) { 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, 20, 5); print ''; @@ -349,10 +349,10 @@ if ($result) { print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; - $thirdpartystatic = new Societe($db); - $facturestatic = new Facture($db); + $thirdpartystatic = new Societe($db); + $facturestatic = new Facture($db); $productstatic = new Product($db); - $accountingaccountstatic = new AccountingAccount($db); + $accountingaccountstatic = new AccountingAccount($db); $i = 0; while ($i < min($num_lines, $limit)) { @@ -362,16 +362,16 @@ if ($result) { $facturestatic->id = $objp->facid; $facturestatic->type = $objp->ftype; - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_compta_client = $objp->code_compta_client; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->country_code = $objp->country_code; + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_compta_client = $objp->code_compta_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartystatic->email = $objp->email; + $thirdpartystatic->country_code = $objp->country_code; $productstatic->ref = $objp->product_ref; $productstatic->id = $objp->product_id; @@ -412,7 +412,7 @@ if ($result) { print ''.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).''; // Thirdparty - print '' . $thirdpartystatic->getNomUrl(1, 'customer') . ''; + print ''.$thirdpartystatic->getNomUrl(1, 'customer').''; // Country print ''; @@ -425,7 +425,7 @@ if ($result) { print ''.$objp->tva_intra.''; print ''; - print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); + print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); print ' '; print img_edit(); print ''; @@ -434,14 +434,14 @@ if ($result) { print ''; $i++; } - print ''; - print ""; + print ''; + print ""; - if ($nbtotalofrecords > $limit) { - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); - } + if ($nbtotalofrecords > $limit) { + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); + } - print ''; + print ''; } else { print $db->lasterror(); } diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index b55d587c48b..b7027282281 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -114,7 +114,7 @@ if (empty($reshook)) // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_societe=''; + $search_societe = ''; $search_lineid = ''; $search_ref = ''; $search_invoice = ''; @@ -386,7 +386,7 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1); //print ''; @@ -582,7 +582,7 @@ if ($result) { print ''; // Thirdparty - print '' . $thirdpartystatic->getNomUrl(1, 'customer') . ''; + print ''.$thirdpartystatic->getNomUrl(1, 'customer').''; // Country print ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 4b06c49a0cb..63305791ec7 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -201,16 +201,16 @@ if ($resql) { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); } else print $row[1]; print ''; - for ($i = 2; $i <= 12; $i++) { - print ''.price($row[$i]).''; - } - print ''.price($row[13]).''; - print ''.price($row[14]).''; - print ''; - } - $db->free($resql); + for ($i = 2; $i <= 12; $i++) { + print ''.price($row[$i]).''; + } + print ''.price($row[13]).''; + print ''.price($row[14]).''; + print ''; + } + $db->free($resql); } else { - print $db->lasterror(); // Show last sql error + print $db->lasterror(); // Show last sql error } print "\n"; print ''; @@ -275,16 +275,16 @@ if ($resql) { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); } else print $row[1]; print ''; - for ($i = 2; $i <= 12; $i++) { - print ''.price($row[$i]).''; - } - print ''.price($row[13]).''; - print ''.price($row[14]).''; - print ''; - } - $db->free($resql); + for ($i = 2; $i <= 12; $i++) { + print ''.price($row[$i]).''; + } + print ''.price($row[13]).''; + print ''.price($row[14]).''; + print ''; + } + $db->free($resql); } else { - print $db->lasterror(); // Show last sql error + print $db->lasterror(); // Show last sql error } print "\n"; print ''; @@ -293,60 +293,60 @@ print ''; if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ? { - print '
'; - print '
'; + print '
'; + print '
'; - print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); - //print load_fiche_titre($langs->trans("OtherInfo"), '', ''); + print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); + //print load_fiche_titre($langs->trans("OtherInfo"), '', ''); print '
'; - print ''; - print ''; - for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; - if ($j > 12) $j -= 12; - print ''; - } - print ''; + print '
'.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''.$langs->trans("Total").'
'; + print ''; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; + } + print ''; - $sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,"; - for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; - if ($j > 12) $j -= 12; - $sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; - } - $sql .= " SUM(erd.total_ht) as total"; - $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; - $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; - $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; + $sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; + } + $sql .= " SUM(erd.total_ht) as total"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; + $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; + $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } - $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; - $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy + $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; + $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy - dol_syslog('htdocs/accountancy/expensereport/index.php'); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); + dol_syslog('htdocs/accountancy/expensereport/index.php'); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); - while ($row = $db->fetch_row($resql)) { - print ''; - for ($i = 1; $i <= 12; $i++) { - print ''; - } - print ''; - print ''; - } + while ($row = $db->fetch_row($resql)) { + print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; + } + print ''; + print ''; + } - $db->free($resql); - } else { - print $db->lasterror(); // Show last sql error - } - print "
'.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''.$langs->trans("Total").'
'.$row[0].''.price($row[$i]).''.price($row[13]).'
'.$row[0].''.price($row[$i]).''.price($row[13]).'
\n"; - print '
'; + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "\n"; + print ''; } // End of page diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 5ff43d200d7..6135a213115 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -86,8 +86,8 @@ $formaccounting = new FormAccounting($db); // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $search_login = ''; - $search_expensereport = ''; + $search_login = ''; + $search_expensereport = ''; $search_label = ''; $search_desc = ''; $search_amount = ''; @@ -178,7 +178,7 @@ $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't sha $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; // Add search filter like if (strlen(trim($search_login))) { - $sql .= natural_search("u.login", $search_login); + $sql .= natural_search("u.login", $search_login); } if (strlen(trim($search_expensereport))) { $sql .= natural_search("er.ref", $search_expensereport); @@ -207,13 +207,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -228,7 +228,7 @@ if ($result) { $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($search_login) $param .= '&search_login='.urlencode($search_login); + if ($search_login) $param .= '&search_login='.urlencode($search_login); if ($search_expensereport) $param .= "&search_expensereport=".urlencode($search_expensereport); if ($search_label) $param .= "&search_label=".urlencode($search_label); if ($search_desc) $param .= "&search_desc=".urlencode($search_desc); @@ -257,12 +257,12 @@ if ($result) { $moreforfilter = ''; - print '
'; + print '
'; print ''."\n"; print ''; - print ''; - print ''; + print ''; + print ''; print ''; if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { print ''; @@ -278,14 +278,14 @@ if ($result) { print ''; print ''; print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print ''; print "\n"; print ''; - print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); @@ -296,31 +296,31 @@ if ($result) { print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); - $checkpicto = $form->showCheckAddButtons(); + $checkpicto = $form->showCheckAddButtons(); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; $expensereportstatic = new ExpenseReport($db); $accountingaccountstatic = new AccountingAccount($db); - $userstatic = new User($db); + $userstatic = new User($db); - $i = 0; + $i = 0; while ($i < min($num_lines, $limit)) { $objp = $db->fetch_object($result); $expensereportstatic->ref = $objp->ref; $expensereportstatic->id = $objp->erid; - $userstatic->id = $objp->rowid; - $userstatic->ref = $objp->label; - $userstatic->login = $objp->login; - $userstatic->statut = $objp->statut; - $userstatic->email = $objp->email; - $userstatic->gender = $objp->gender; - $userstatic->firstname = $objp->firstname; - $userstatic->lastname = $objp->lastname; - $userstatic->employee = $objp->employee; - $userstatic->photo = $objp->photo; + $userstatic->id = $objp->rowid; + $userstatic->ref = $objp->label; + $userstatic->login = $objp->login; + $userstatic->statut = $objp->statut; + $userstatic->email = $objp->email; + $userstatic->gender = $objp->gender; + $userstatic->firstname = $objp->firstname; + $userstatic->lastname = $objp->lastname; + $userstatic->employee = $objp->employee; + $userstatic->photo = $objp->photo; $accountingaccountstatic->rowid = $objp->fk_compte; $accountingaccountstatic->label = $objp->label; @@ -329,15 +329,15 @@ if ($result) { print ''; - // Login - print ''; + // Login + print ''; - // Line id + // Line id print ''; - // Ref Expense report + // Ref Expense report print ''; // Date validation @@ -347,10 +347,10 @@ if ($result) { print ''; - // Fees label + // Fees label print ''; - // Fees description -- Can be null + // Fees description -- Can be null print ''; - // Vat rate + // Vat rate print ''; // Accounting account affected print ''; print ''; @@ -379,7 +379,7 @@ if ($result) { print ""; if ($nbtotalofrecords > $limit) { - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); } print ''; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 166a448d5ff..0a5bef0c57e 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -102,16 +102,16 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_login = ''; - $search_expensereport = ''; - $search_label = ''; - $search_desc = ''; - $search_amount = ''; - $search_account = ''; - $search_vat = ''; - $search_day = ''; - $search_month = ''; - $search_year = ''; + $search_login = ''; + $search_expensereport = ''; + $search_label = ''; + $search_desc = ''; + $search_amount = ''; + $search_account = ''; + $search_vat = ''; + $search_day = ''; + $search_month = ''; + $search_year = ''; } // Mass actions @@ -124,46 +124,46 @@ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; if ($massaction == 'ventil') { $msg = ''; - //print '
' . $langs->trans("Processing") . '...
'; - if (!empty($mesCasesCochees)) { - $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; - $msg .= '
'; - $cpt = 0; - $ok = 0; - $ko = 0; + //print '
' . $langs->trans("Processing") . '...
'; + if (!empty($mesCasesCochees)) { + $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; + $msg .= '
'; + $cpt = 0; + $ok = 0; + $ko = 0; - foreach ($mesCasesCochees as $maLigneCochee) { - $maLigneCourante = explode("_", $maLigneCochee); - $monId = $maLigneCourante[0]; - $monCompte = GETPOST('codeventil'.$monId); + foreach ($mesCasesCochees as $maLigneCochee) { + $maLigneCourante = explode("_", $maLigneCochee); + $monId = $maLigneCourante[0]; + $monCompte = GETPOST('codeventil'.$monId); - if ($monCompte <= 0) - { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; - $ko++; - } else { - $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; - $sql .= " SET fk_code_ventilation = ".$monCompte; - $sql .= " WHERE rowid = ".$monId; + if ($monCompte <= 0) + { + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; + $ko++; + } else { + $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; + $sql .= " SET fk_code_ventilation = ".$monCompte; + $sql .= " WHERE rowid = ".$monId; - $accountventilated = new AccountingAccount($db); - $accountventilated->fetch($monCompte, ''); + $accountventilated = new AccountingAccount($db); + $accountventilated->fetch($monCompte, ''); - dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG); - if ($db->query($sql)) { - $msg .= '
'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; - $ok++; - } else { - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; - $ko++; - } - } + dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG); + if ($db->query($sql)) { + $msg .= '
'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; + $ok++; + } else { + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; + $ko++; + } + } - $cpt++; - } - $msg .= '
'; - $msg .= '
'.$langs->trans("EndProcessing").'
'; - } + $cpt++; + } + $msg .= '
'; + $msg .= '
'.$langs->trans("EndProcessing").'
'; + } } @@ -181,8 +181,8 @@ if (empty($chartaccountcode)) { print $langs->trans("ErrorChartOfAccountSystemNotSelected"); // End of page - llxFooter(); - $db->close(); + llxFooter(); + $db->close(); exit; } @@ -204,25 +204,25 @@ if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { } // Add search filter like if (strlen(trim($search_login))) { - $sql .= natural_search("u.login", $search_login); + $sql .= natural_search("u.login", $search_login); } if (strlen(trim($search_expensereport))) { - $sql .= natural_search("er.ref", $search_expensereport); + $sql .= natural_search("er.ref", $search_expensereport); } if (strlen(trim($search_label))) { - $sql .= natural_search("f.label", $search_label); + $sql .= natural_search("f.label", $search_label); } if (strlen(trim($search_desc))) { - $sql .= natural_search("erd.comments", $search_desc); + $sql .= natural_search("erd.comments", $search_desc); } if (strlen(trim($search_amount))) { - $sql .= natural_search("erd.total_ht", $search_amount, 1); + $sql .= natural_search("erd.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= natural_search("aa.account_number", $search_account); + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("erd.tva_tx", $search_vat, 1); + $sql .= natural_search("erd.tva_tx", $search_vat, 1); } $sql .= dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year); $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy @@ -233,13 +233,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -255,7 +255,7 @@ if ($result) { $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($search_login) $param .= '&search_login='.urlencode($search_login); + if ($search_login) $param .= '&search_login='.urlencode($search_login); if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid); if ($search_day) $param .= '&search_day='.urlencode($search_day); if ($search_month) $param .= '&search_month='.urlencode($search_month); @@ -267,7 +267,7 @@ if ($result) { if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); $arrayofmassactions = array( - 'ventil' => $langs->trans("Ventilate") + 'ventil' => $langs->trans("Ventilate") ); $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); @@ -295,12 +295,12 @@ if ($result) { $moreforfilter = ''; - print '
'; + print '
'; print '
'; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print '
'; - print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); - print ''; + print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); + print ''.$objp->rowid.''.$expensereportstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->date), 'day').''.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments)); $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; @@ -360,13 +360,13 @@ if ($result) { // Amount without taxes print ''.price($objp->total_ht).''.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).''; print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); - print ' '; + print ' '; print img_edit(); print '
'."\n"; // We add search filter print ''; - print ''; + print ''; print ''; print ''; if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { @@ -324,7 +324,7 @@ if ($result) { print ''; print ''; - print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { @@ -356,23 +356,23 @@ if ($result) { $expensereport_static->ref = $objp->ref; $expensereport_static->id = $objp->erid; - $userstatic->id = $objp->rowid; - $userstatic->ref = $objp->label; - $userstatic->login = $objp->login; - $userstatic->statut = $objp->statut; - $userstatic->email = $objp->email; - $userstatic->gender = $objp->gender; - $userstatic->firstname = $objp->firstname; - $userstatic->lastname = $objp->lastname; - $userstatic->employee = $objp->employee; - $userstatic->photo = $objp->photo; + $userstatic->id = $objp->rowid; + $userstatic->ref = $objp->label; + $userstatic->login = $objp->login; + $userstatic->statut = $objp->statut; + $userstatic->email = $objp->email; + $userstatic->gender = $objp->gender; + $userstatic->firstname = $objp->firstname; + $userstatic->lastname = $objp->lastname; + $userstatic->employee = $objp->employee; + $userstatic->photo = $objp->photo; - print ''; + print ''; - // Login - print ''; + // Login + print ''; // Line id print ''; @@ -400,7 +400,7 @@ if ($result) { print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments); print ''; - // Amount without taxes + // Amount without taxes print ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 3deb3cc9d1c..f1807c1c2cc 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -331,9 +331,9 @@ $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; dol_syslog('htdocs/accountancy/supplier/index.php'); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - while ($row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for ($i = 2; $i <= 12; $i++) { - print ''; - } - print ''; - print ''; - print ''; - } - $db->free($resql); + for ($i = 2; $i <= 12; $i++) { + print ''; + } + print ''; + print ''; + print ''; + } + $db->free($resql); } else { - print $db->lasterror(); // Show last sql error + print $db->lasterror(); // Show last sql error } print "
'; - print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); - print ''; + print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); + print ''.$objp->rowid.''; print price($objp->price); print '
'; if ($row[0] == 'tobind') { @@ -346,16 +346,16 @@ if ($resql) { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); } else print $row[1]; print ''.price($row[$i]).''.price($row[13]).''.price($row[14]).'
'.price($row[$i]).''.price($row[13]).''.price($row[14]).'
\n"; print '
'; @@ -364,60 +364,60 @@ print '
'; if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? { - print '
'; - print '
'; + print '
'; + print '
'; - print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); - //print load_fiche_titre($langs->trans("OtherInfo"), '', ''); + print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); + //print load_fiche_titre($langs->trans("OtherInfo"), '', ''); print '
'; - print ''; - print ''; - for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; - if ($j > 12) $j -= 12; - print ''; - } - print ''; + print '
'.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''.$langs->trans("Total").'
'; + print ''; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; + } + print ''; - $sql = "SELECT '".$langs->trans("CAHTF")."' AS label,"; - for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; - if ($j > 12) $j -= 12; - $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; - } - $sql .= " SUM(ffd.total_ht) as total"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; - $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; - $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; + $sql = "SELECT '".$langs->trans("CAHTF")."' AS label,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; + } + $sql .= " SUM(ffd.total_ht) as total"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; + $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; + $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; // Define begin binding date if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } - $sql .= " AND ff.fk_statut > 0"; + $sql .= " AND ff.fk_statut > 0"; $sql .= " AND ffd.product_type <= 2"; - $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy + $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy - dol_syslog('htdocs/accountancy/supplier/index.php'); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); + dol_syslog('htdocs/accountancy/supplier/index.php'); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); - while ($row = $db->fetch_row($resql)) { - print ''; - for ($i = 1; $i <= 12; $i++) { - print ''; - } - print ''; - print ''; - } - $db->free($resql); - } else { - print $db->lasterror(); // Show last sql error - } - print "
'.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''.$langs->trans("Total").'
'.$row[0].''.price($row[$i]).''.price($row[13]).'
\n"; - print '
'; + while ($row = $db->fetch_row($resql)) { + print ''.$row[0].''; + for ($i = 1; $i <= 12; $i++) { + print ''.price($row[$i]).''; + } + print ''.price($row[13]).''; + print ''; + } + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "\n"; + print ''; } // End of page diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 9437b0e8c32..6a5e234532c 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -94,7 +94,7 @@ $formaccounting = new FormAccounting($db); 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_societe = ''; - $search_lineid = ''; + $search_lineid = ''; $search_ref = ''; $search_invoice = ''; $search_label = ''; @@ -196,7 +196,7 @@ if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } if ($search_lineid) { - $sql .= natural_search("l.rowid", $search_lineid, 1); + $sql .= natural_search("l.rowid", $search_lineid, 1); } if (strlen(trim($search_invoice))) { $sql .= natural_search("f.ref", $search_invoice); @@ -250,13 +250,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -318,7 +318,7 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1); // print ''; @@ -348,29 +348,29 @@ if ($result) { print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; - $thirdpartystatic = new Societe($db); + $thirdpartystatic = new Societe($db); $facturefournisseur_static = new FactureFournisseur($db); $productstatic = new ProductFournisseur($db); - $accountingaccountstatic = new AccountingAccount($db); + $accountingaccountstatic = new AccountingAccount($db); - $i = 0; + $i = 0; while ($i < min($num_lines, $limit)) - { + { $objp = $db->fetch_object($result); $facturefournisseur_static->ref = $objp->ref; $facturefournisseur_static->id = $objp->facid; - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_compta_client = $objp->code_compta_client; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->country_code = $objp->country_code; + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_compta_client = $objp->code_compta_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartystatic->email = $objp->email; + $thirdpartystatic->country_code = $objp->country_code; $productstatic->ref = $objp->product_ref; $productstatic->id = $objp->product_id; @@ -415,7 +415,7 @@ if ($result) { print ''.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).''; // Thirdparty - print '' . $thirdpartystatic->getNomUrl(1, 'supplier') . ''; + print ''.$thirdpartystatic->getNomUrl(1, 'supplier').''; // Country print ''; @@ -428,7 +428,7 @@ if ($result) { print ''.$objp->tva_intra.''; print ''; - print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); + print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); print ' '; print img_edit(); print ''; @@ -437,14 +437,14 @@ if ($result) { print ''; $i++; } - print ''; - print ""; + print ''; + print ""; - if ($nbtotalofrecords > $limit) { - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); - } + if ($nbtotalofrecords > $limit) { + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); + } - print ''; + print ''; } else { print $db->lasterror(); } diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 073b8791f2b..53c987e0189 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -118,7 +118,7 @@ if (empty($reshook)) // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_societe=''; + $search_societe = ''; $search_lineid = ''; $search_ref = ''; $search_invoice = ''; @@ -385,7 +385,7 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1); //print ''; @@ -419,7 +419,7 @@ if ($result) { print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; - $thirdpartystatic=new Societe($db); + $thirdpartystatic = new Societe($db); $facturefourn_static = new FactureFournisseur($db); $product_static = new Product($db); @@ -569,7 +569,7 @@ if ($result) { print ''; // Thirdparty - print '' . $thirdpartystatic->getNomUrl(1, 'supplier') . ''; + print ''.$thirdpartystatic->getNomUrl(1, 'supplier').''; // Country print ''; diff --git a/htdocs/adherents/admin/adherent_emails.php b/htdocs/adherents/admin/adherent_emails.php index 97411a27abf..1b26a029a01 100644 --- a/htdocs/adherents/admin/adherent_emails.php +++ b/htdocs/adherents/admin/adherent_emails.php @@ -47,15 +47,15 @@ $error = 0; // Editing global variables not related to a specific theme $constantes = array( - 'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))), - 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member', - 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */ - 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */ - 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */ - 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */ - 'ADHERENT_MAIL_FROM'=>'string', - 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string', - 'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html', + 'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))), + 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member', + 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */ + 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */ + 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */ + 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */ + 'ADHERENT_MAIL_FROM'=>'string', + 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string', + 'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html', ); @@ -66,16 +66,16 @@ $constantes = array( // if ($action == 'updateall') { - $db->begin(); - $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; - $res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); - if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) { - setEventMessages('ErrorFailedToSaveDate', null, 'errors'); - $db->rollback(); - } else { - setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); - $db->commit(); - } + $db->begin(); + $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; + $res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); + if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) { + setEventMessages('ErrorFailedToSaveDate', null, 'errors'); + $db->rollback(); + } else { + setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); + $db->commit(); + } } // Action to update or add a constant diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 2a177ebade4..439854229e0 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -335,8 +335,8 @@ if (empty($reshook)) { if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); } else { - // Create thumbs - $object->addThumbs($newfile); + // Create thumbs + $object->addThumbs($newfile); } } } else { @@ -354,8 +354,8 @@ if (empty($reshook)) { } } - $rowid = $object->id; - $id = $object->id; + $rowid = $object->id; + $id = $object->id; $action = ''; if (!empty($backtopage)) { @@ -402,7 +402,7 @@ if (empty($reshook)) { // $skype=GETPOST("member_skype", 'alpha'); // $twitter=GETPOST("member_twitter", 'alpha'); // $facebook=GETPOST("member_facebook", 'alpha'); - // $linkedin=GETPOST("member_linkedin", 'alpha'); + // $linkedin=GETPOST("member_linkedin", 'alpha'); $email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); $login = GETPOST("member_login", 'alpha'); $pass = GETPOST("password", 'alpha'); @@ -755,7 +755,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($result <= 0) dol_print_error('', $object->error); } $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template + $objcanvas->display_canvas($action); // Show template } else { // ----------------------------------------- // When used in standard mode @@ -778,16 +778,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $object->country = $tmparray['label']; } - if (!empty($socid)) { - $object = new Societe($db); - if ($socid > 0) $object->fetch($socid); + if (!empty($socid)) { + $object = new Societe($db); + if ($socid > 0) $object->fetch($socid); - if (!($object->id > 0)) { - $langs->load("errors"); - print($langs->trans('ErrorRecordNotFound')); - exit; - } - } + if (!($object->id > 0)) { + $langs->load("errors"); + print($langs->trans('ErrorRecordNotFound')); + exit; + } + } $adht = new AdherentType($db); @@ -829,7 +829,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; if ($backtopage) print ''; - dol_fiche_head(''); + dol_fiche_head(''); print ''; print ''; @@ -934,14 +934,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; - if (!empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; + if (!$value['active']) break; print ''; } } - // Birth Date + // Birth Date print "\n"; @@ -1167,14 +1167,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; - if (!empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; + if (!$value['active']) break; print ''; } } - // Birth Date + // Birth Date print "\n"; @@ -1447,10 +1447,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { dol_banner_tab($object, 'rowid', $linkback); - print '
'; - print '
'; + print '
'; + print '
'; - print '
'; + print '
'; print '
'.$langs->trans("PhoneMobile").''.img_picto('', 'object_phoning_mobile').'
'.$langs->trans($value['label']).'
".$langs->trans("DateToBirth")."\n"; print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc'); print "
'.$langs->trans("PhoneMobile").''.img_picto('', 'object_phoning_mobile').' phone_mobile).'">
'.$langs->trans($value['label']).'
".$langs->trans("DateToBirth")."\n"; print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc'); print "
'; // Login @@ -1483,13 +1483,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } @@ -1503,8 +1503,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } } else { if ($object->need_subscription == 0) { - print $langs->trans("SubscriptionNotNeeded"); - } elseif (!$adht->subscription) { + print $langs->trans("SubscriptionNotNeeded"); + } elseif (!$adht->subscription) { print $langs->trans("SubscriptionNotRecorded"); if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated } else { @@ -1560,14 +1560,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } print ''; - print '
'.$langs->trans("Password").''.preg_replace('/./i', '*', $object->pass); if ($object->pass) print preg_replace('/./i', '*', $object->pass); else { - if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted; - else print $langs->trans("Hidden"); + if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted; + else print $langs->trans("Hidden"); } if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) { - $langs->load("errors"); - $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); - print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); + $langs->load("errors"); + $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); + print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); } print '
'; + print ''; - print ''; + print ''; - print '
'; - print '
'; + print '
'; + print '
'; - print ''; + print '
'; // Birth Date print ''; @@ -1585,12 +1585,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { //VCard print ''; + print ''; // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; @@ -1598,9 +1598,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "
'.$langs->trans("DateToBirth").''.dol_print_date($object->birth, 'day').'
'; - print $langs->trans("VCard").''; + print $langs->trans("VCard").''; print ''; print img_picto($langs->trans("Download"), 'vcard.png', 'class="paddingrightonly"'); print $langs->trans("Download"); print ''; - print '
\n"; print "
\n"; - print '
'; + print '
'; - dol_fiche_end(); + dol_fiche_end(); /* @@ -1769,7 +1769,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $morehtmlright .= ''; // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', $MAX, '', $morehtmlright); diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 3f8a5ce1b25..94bf34208ff 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -62,26 +62,26 @@ class AdherentType extends CommonObject public $libelle; /** - * @var string Adherent type label - */ - public $label; + * @var string Adherent type label + */ + public $label; - /** - * @var string Adherent type nature - */ - public $morphy; + /** + * @var string Adherent type nature + */ + public $morphy; - public $duration; + public $duration; - /* + /* * type expiration */ - public $duration_value; + public $duration_value; - /** - * Expiration unit - */ - public $duration_unit; + /** + * Expiration unit + */ + public $duration_unit; /** * @var int Subsription required (0 or 1) @@ -101,7 +101,7 @@ class AdherentType extends CommonObject /** @var array Array of members */ public $members = array(); - public $multilangs = array(); + public $multilangs = array(); /** @@ -115,157 +115,157 @@ class AdherentType extends CommonObject $this->status = 1; } - /** - * Load array this->multilangs - * - * @return int <0 if KO, >0 if OK - */ - public function getMultiLangs() - { - global $langs; + /** + * Load array this->multilangs + * + * @return int <0 if KO, >0 if OK + */ + public function getMultiLangs() + { + global $langs; - $current_lang = $langs->getDefaultLang(); + $current_lang = $langs->getDefaultLang(); - $sql = "SELECT lang, label, description, email"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql .= " WHERE fk_type=".$this->id; + $sql = "SELECT lang, label, description, email"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id; - $result = $this->db->query($sql); - if ($result) { - while ($obj = $this->db->fetch_object($result)) { - //print 'lang='.$obj->lang.' current='.$current_lang.'
'; - if ($obj->lang == $current_lang) { // si on a les traduct. dans la langue courante on les charge en infos principales. + $result = $this->db->query($sql); + if ($result) { + while ($obj = $this->db->fetch_object($result)) { + //print 'lang='.$obj->lang.' current='.$current_lang.'
'; + if ($obj->lang == $current_lang) { // si on a les traduct. dans la langue courante on les charge en infos principales. $this->label = $obj->label; - $this->description = $obj->description; - $this->email = $obj->email; - } - $this->multilangs["$obj->lang"]["label"] = $obj->label; - $this->multilangs["$obj->lang"]["description"] = $obj->description; - $this->multilangs["$obj->lang"]["email"] = $obj->email; - } - return 1; - } else { - $this->error = "Error: ".$this->db->lasterror()." - ".$sql; - return -1; - } - } + $this->description = $obj->description; + $this->email = $obj->email; + } + $this->multilangs["$obj->lang"]["label"] = $obj->label; + $this->multilangs["$obj->lang"]["description"] = $obj->description; + $this->multilangs["$obj->lang"]["email"] = $obj->email; + } + return 1; + } else { + $this->error = "Error: ".$this->db->lasterror()." - ".$sql; + return -1; + } + } - /** - * Update or add a translation for a product - * - * @param User $user Object user making update - * @return int <0 if KO, >0 if OK - */ - public function setMultiLangs($user) - { - global $conf, $langs; + /** + * Update or add a translation for a product + * + * @param User $user Object user making update + * @return int <0 if KO, >0 if OK + */ + public function setMultiLangs($user) + { + global $conf, $langs; - $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2); - $current_lang = $langs->getDefaultLang(); + $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2); + $current_lang = $langs->getDefaultLang(); - foreach ($langs_available as $key => $value) { - if ($key == $current_lang) { - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql .= " WHERE fk_type=".$this->id; - $sql .= " AND lang='".$key."'"; + foreach ($langs_available as $key => $value) { + if ($key == $current_lang) { + $sql = "SELECT rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id; + $sql .= " AND lang='".$key."'"; - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($this->db->num_rows($result)) { // if there is already a description line for this language + if ($this->db->num_rows($result)) { // if there is already a description line for this language $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql2 .= " SET "; - $sql2 .= " label='".$this->db->escape($this->label)."',"; - $sql2 .= " description='".$this->db->escape($this->description)."'"; - $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; - } else { - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; - $sql2 .= ")"; - $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',"; - $sql2 .= " '".$this->db->escape($this->description)."'"; - $sql2 .= ")"; - } - dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key); - if (!$this->db->query($sql2)) { - $this->error = $this->db->lasterror(); - return -1; - } - } elseif (isset($this->multilangs[$key])) { - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql .= " WHERE fk_type=".$this->id; - $sql .= " AND lang='".$key."'"; + $sql2 .= " SET "; + $sql2 .= " label='".$this->db->escape($this->label)."',"; + $sql2 .= " description='".$this->db->escape($this->description)."'"; + $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; + } else { + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; + $sql2 .= ")"; + $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',"; + $sql2 .= " '".$this->db->escape($this->description)."'"; + $sql2 .= ")"; + } + dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key); + if (!$this->db->query($sql2)) { + $this->error = $this->db->lasterror(); + return -1; + } + } elseif (isset($this->multilangs[$key])) { + $sql = "SELECT rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id; + $sql .= " AND lang='".$key."'"; - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($this->db->num_rows($result)) { // if there is already a description line for this language + if ($this->db->num_rows($result)) { // if there is already a description line for this language $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql2 .= " SET "; - $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; - $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; - $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; - } else { - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; - $sql2 .= ")"; - $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',"; - $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; - $sql2 .= ")"; - } + $sql2 .= " SET "; + $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; + $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; + } else { + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; + $sql2 .= ")"; + $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; + $sql2 .= ")"; + } - // We do not save if main fields are empty - if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) { - if (!$this->db->query($sql2)) { - $this->error = $this->db->lasterror(); - return -1; - } - } - } else { - // language is not current language and we didn't provide a multilang description for this language - } - } + // We do not save if main fields are empty + if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) { + if (!$this->db->query($sql2)) { + $this->error = $this->db->lasterror(); + return -1; + } + } + } else { + // language is not current language and we didn't provide a multilang description for this language + } + } - // Call trigger - $result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user); - if ($result < 0) { - $this->error = $this->db->lasterror(); - return -1; - } - // End call triggers + // Call trigger + $result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user); + if ($result < 0) { + $this->error = $this->db->lasterror(); + return -1; + } + // End call triggers - return 1; - } + return 1; + } - /** - * Delete a language for this product - * - * @param string $langtodelete Language code to delete - * @param User $user Object user making delete - * - * @return int <0 if KO, >0 if OK - */ - public function delMultiLangs($langtodelete, $user) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; + /** + * Delete a language for this product + * + * @param string $langtodelete Language code to delete + * @param User $user Object user making delete + * + * @return int <0 if KO, >0 if OK + */ + public function delMultiLangs($langtodelete, $user) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; - dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - // Call trigger - $result = $this->call_trigger('ADHERENT_TYPE_DEL_MULTILANGS', $user); - if ($result < 0) { - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); - return -1; - } - // End call triggers - return 1; - } else { - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); - return -1; - } - } + dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + // Call trigger + $result = $this->call_trigger('ADHERENT_TYPE_DEL_MULTILANGS', $user); + if ($result < 0) { + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); + return -1; + } + // End call triggers + return 1; + } else { + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); + return -1; + } + } /** * Fonction qui permet de creer le status de l'adherent @@ -337,7 +337,7 @@ class AdherentType extends CommonObject */ public function update($user, $notrigger = 0) { - global $langs, $conf, $hookmanager; + global $langs, $conf, $hookmanager; $error = 0; @@ -359,15 +359,15 @@ class AdherentType extends CommonObject $result = $this->db->query($sql); if ($result) { - $this->description = $this->db->escape($this->note); + $this->description = $this->db->escape($this->note); - // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { - if ($this->setMultiLangs($user) < 0) { - $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; - return -2; - } - } + // Multilangs + if (!empty($conf->global->MAIN_MULTILANGS)) { + if ($this->setMultiLangs($user) < 0) { + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; + return -2; + } + } $action = 'update'; @@ -439,7 +439,7 @@ class AdherentType extends CommonObject */ public function fetch($rowid) { - global $langs, $conf; + global $langs, $conf; $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.mail_valid, d.note, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; @@ -465,10 +465,10 @@ class AdherentType extends CommonObject $this->note = $obj->note; $this->vote = $obj->vote; - // multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { - $this->getMultiLangs(); - } + // multilangs + if (!empty($conf->global->MAIN_MULTILANGS)) { + $this->getMultiLangs(); + } } return 1; @@ -478,7 +478,7 @@ class AdherentType extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of members' type * @@ -487,7 +487,7 @@ class AdherentType extends CommonObject */ public function liste_array($status = -1) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $adherenttypes = array(); @@ -578,31 +578,31 @@ class AdherentType extends CommonObject //return $morphy; } - /** - * Return clicable name (with picto eventually) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen length max label - * @param int $notooltip 1=Disable tooltip - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) - { - global $langs; + /** + * Return clicable name (with picto eventually) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen length max label + * @param int $notooltip 1=Disable tooltip + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) + { + global $langs; - $result = ''; - $label = $langs->trans("ShowTypeCard", $this->label); + $result = ''; + $label = $langs->trans("ShowTypeCard", $this->label); - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $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 .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label); - $result .= $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 .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label); + $result .= $linkend; - return $result; - } + return $result; + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** @@ -611,7 +611,7 @@ class AdherentType extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ - public function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } @@ -623,9 +623,9 @@ class AdherentType extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Status label */ - public function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load('companies'); @@ -640,10 +640,10 @@ class AdherentType extends CommonObject } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -655,7 +655,7 @@ class AdherentType extends CommonObject */ public function _load_ldap_dn($info, $mode = 0) { - // phpcs:enable + // phpcs:enable global $conf; $dn = ''; if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN; @@ -665,8 +665,8 @@ class AdherentType extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Initialize the info array (array of LDAP values) that will be used to call LDAP functions * @@ -674,7 +674,7 @@ class AdherentType extends CommonObject */ public function _load_ldap_info() { - // phpcs:enable + // phpcs:enable global $conf, $langs; $info = array(); @@ -766,15 +766,15 @@ class AdherentType extends CommonObject * * @return string Return mail model content of type or empty */ - public function getMailOnResiliate() - { - global $conf; + public function getMailOnResiliate() + { + global $conf; - // NOTE mail_resiliate not defined so never used - if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined + // NOTE mail_resiliate not defined so never used + if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined return $this->mail_resiliate; - } + } - return ''; - } + return ''; + } } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 7d744b599de..39ee57a6744 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -81,10 +81,10 @@ $extrafields->fetch_name_optionals_label($object->table_element); 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_lastname = ""; - $search_login = ""; - $search_email = ""; - $type = ""; - $sall = ""; + $search_login = ""; + $search_email = ""; + $type = ""; + $sall = ""; } @@ -226,8 +226,8 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $newcardbutton = ''; if ($user->rights->adherent->configurer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); - } + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); + } print '
'; if ($optioncss != '') print ''; @@ -247,7 +247,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''; print ''.$langs->trans("Ref").''; print ''.$langs->trans("Label").''; - print ''.$langs->trans("MemberNature").''; + print ''.$langs->trans("MemberNature").''; print ''.$langs->trans("SubscriptionRequired").''; print ''.$langs->trans("VoteAllowed").''; print ''.$langs->trans("Status").''; @@ -270,9 +270,9 @@ if (!$rowid && $action != 'create' && $action != 'edit') { //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' print ''; print ''.dol_escape_htmltag($objp->label).''; - print ''; + print ''; if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } else print $langs->trans("MorPhy"); - print ''; + print ''; print ''.yn($objp->subscription).''; print ''.yn($objp->vote).''; print ''.$membertype->getLibStatut(5).''; @@ -308,7 +308,7 @@ if ($action == 'create') { print ''; print ''; - dol_fiche_head(''); + dol_fiche_head(''); print ''; print ''; @@ -319,10 +319,10 @@ if ($action == 'create') { print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1); print ''; - // Morphy + // Morphy $morphys = array(); - $morphys[""] = $langs->trans("MorPhy"); - $morphys["phy"] = $langs->trans("Physical"); + $morphys[""] = $langs->trans("MorPhy"); + $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); print ''; print '
'; - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); - $moreforfilter = ''; + $moreforfilter = ''; - print '
'; - print '
'.$langs->trans("MemberNature").''; print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy'); @@ -447,11 +447,11 @@ if ($rowid > 0) { } // Add - if ($user->rights->adherent->configurer && !empty($object->status)) { - print ''; - } else { - print ''; - } + if ($user->rights->adherent->configurer && !empty($object->status)) { + print ''; + } else { + print ''; + } // Delete if ($user->rights->adherent->configurer) { @@ -479,7 +479,7 @@ if ($rowid > 0) { $sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall); } if ($status != '') { - $sql .= natural_search('d.statut', $status, 2); + $sql .= natural_search('d.statut', $status, 2); } if ($action == 'search') { if (GETPOST('search', 'alpha')) { @@ -495,12 +495,12 @@ if ($rowid > 0) { if (!empty($search_email)) { $sql .= natural_search("d.email", $search_email); } - if ($filter == 'uptodate') { - $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)"; - } - if ($filter == 'outofdate') { - $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; - } + if ($filter == 'uptodate') { + $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)"; + } + if ($filter == 'outofdate') { + $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; + } $sql .= " ".$db->order($sortfield, $sortorder); @@ -508,71 +508,71 @@ if ($rowid > 0) { $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); - if ($resql) $nbtotalofrecords = $db->num_rows($result); - else dol_print_error($db); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if ($resql) $nbtotalofrecords = $db->num_rows($result); + else dol_print_error($db); + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; - $offset = 0; - } + $offset = 0; + } } $sql .= " ".$db->plimit($conf->liste_limit + 1, $offset); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - $titre = $langs->trans("MembersList"); - if ($status != '') { - if ($status == '-1,1') { - $titre = $langs->trans("MembersListQualified"); - } elseif ($status == '-1') { - $titre = $langs->trans("MembersListToValid"); - } elseif ($status == '1' && !$filter) { - $titre = $langs->trans("MembersListValid"); - } elseif ($status == '1' && $filter == 'uptodate') { - $titre = $langs->trans("MembersListUpToDate"); - } elseif ($status == '1' && $filter == 'outofdate') { - $titre = $langs->trans("MembersListNotUpToDate"); - } elseif ($status == '0') { - $titre = $langs->trans("MembersListResiliated"); - } - } elseif ($action == 'search') { - $titre = $langs->trans("MembersListQualified"); - } + $titre = $langs->trans("MembersList"); + if ($status != '') { + if ($status == '-1,1') { + $titre = $langs->trans("MembersListQualified"); + } elseif ($status == '-1') { + $titre = $langs->trans("MembersListToValid"); + } elseif ($status == '1' && !$filter) { + $titre = $langs->trans("MembersListValid"); + } elseif ($status == '1' && $filter == 'uptodate') { + $titre = $langs->trans("MembersListUpToDate"); + } elseif ($status == '1' && $filter == 'outofdate') { + $titre = $langs->trans("MembersListNotUpToDate"); + } elseif ($status == '0') { + $titre = $langs->trans("MembersListResiliated"); + } + } elseif ($action == 'search') { + $titre = $langs->trans("MembersListQualified"); + } - if ($type > 0) { + if ($type > 0) { $membertype = new AdherentType($db); - $result = $membertype->fetch($type); + $result = $membertype->fetch($type); $titre .= " (".$membertype->label.")"; - } + } - $param = "&rowid=".$object->id; - if (!empty($status)) $param .= "&status=".$status; - if (!empty($search_lastname)) $param .= "&search_lastname=".$search_lastname; - if (!empty($search_firstname)) $param .= "&search_firstname=".$search_firstname; - if (!empty($search_login)) $param .= "&search_login=".$search_login; - if (!empty($search_email)) $param .= "&search_email=".$search_email; - if (!empty($filter)) $param .= "&filter=".$filter; + $param = "&rowid=".$object->id; + if (!empty($status)) $param .= "&status=".$status; + if (!empty($search_lastname)) $param .= "&search_lastname=".$search_lastname; + if (!empty($search_firstname)) $param .= "&search_firstname=".$search_firstname; + if (!empty($search_login)) $param .= "&search_login=".$search_login; + if (!empty($search_email)) $param .= "&search_email=".$search_email; + if (!empty($filter)) $param .= "&filter=".$filter; - if ($sall) { - print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; - } + if ($sall) { + print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; + } print ''; - print ''; + print ''; print '
'."\n"; + print '
'; + print '
'."\n"; - // Fields title search + // Fields title search print ''; print ''; print "\n"; print ''; - print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); - print "\n"; + print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); + print "\n"; - while ($i < $num && $i < $conf->liste_limit) { - $objp = $db->fetch_object($resql); + while ($i < $num && $i < $conf->liste_limit) { + $objp = $db->fetch_object($resql); - $datefin = $db->jdate($objp->datefin); + $datefin = $db->jdate($objp->datefin); - $adh = new Adherent($db); - $adh->lastname = $objp->lastname; - $adh->firstname = $objp->firstname; + $adh = new Adherent($db); + $adh->lastname = $objp->lastname; + $adh->firstname = $objp->firstname; - // Lastname - print ''; - if ($objp->company != '') { - print ''."\n"; - } else { - print ''."\n"; - } + // Lastname + print ''; + if ($objp->company != '') { + print ''."\n"; + } else { + print ''."\n"; + } - // Login - print "\n"; + // Login + print "\n"; - // Type - /*print ''; */ - // Moral/Physique - print "\n"; + // Moral/Physique + print "\n"; - // EMail - print "\n"; + // EMail + print "\n"; - // Statut - print '"; + // Statut + print '"; - // Date end subscription - if ($datefin) { - print ''; - } else { - print ''; - } + // Date end subscription + if ($datefin) { + print ''; + } else { + print ''; + } - // Actions - print '"; - print "\n"; - $i++; - } + print "\n"; + $i++; + } - print "
'; @@ -590,105 +590,105 @@ if ($rowid > 0) { print ''; print ''; - print '  '; - print ''; + print '  '; + print ''; print '
'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).''.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).'
'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).''.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).'".$objp->login."".$objp->login."'; + // Type + /*print ''; $membertypestatic->id=$objp->type_id; $membertypestatic->label=$objp->type; print $membertypestatic->getNomUrl(1,12); print '".$adh->getmorphylib($objp->morphy)."".$adh->getmorphylib($objp->morphy)."".dol_print_email($objp->email, 0, 0, 1)."".dol_print_email($objp->email, 0, 0, 1)."'; - print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2); - print "'; + print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2); + print "'; - if ($datefin < dol_now() && $objp->status > 0) { - print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate")); - } else { - print dol_print_date($datefin, 'day'); - } - print ''; - if ($objp->subscription == 'yes') { - print $langs->trans("SubscriptionNotReceived"); - if ($objp->status > 0) print " ".img_warning(); - } else { - print ' '; - } - print ''; + if ($datefin < dol_now() && $objp->status > 0) { + print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate")); + } else { + print dol_print_date($datefin, 'day'); + } + print ''; + if ($objp->subscription == 'yes') { + print $langs->trans("SubscriptionNotReceived"); + if ($objp->status > 0) print " ".img_warning(); + } else { + print ' '; + } + print ''; + // Actions + print ''; if ($user->rights->adherent->creer) { print ''.img_edit().''; } print ' '; if ($user->rights->adherent->supprimer) { print ''.img_picto($langs->trans("Resiliate"), 'disable.png').''; - } + } print "
\n"; - print '
'; - print ''; + print "\n"; + print ''; + print ''; if ($num > $conf->liste_limit) { - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); } } else { - dol_print_error($db); + dol_print_error($db); } } @@ -719,18 +719,18 @@ if ($rowid > 0) { print ''.$langs->trans("Label").''; print ''.$langs->trans("Status").''; - print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status); - print ''; + print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status); + print ''; - // Morphy - $morphys[""] = $langs->trans("MorPhy"); - $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Moral"); - print ''.$langs->trans("MemberNature").''; - print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy); - print ""; + // Morphy + $morphys[""] = $langs->trans("MorPhy"); + $morphys["phy"] = $langs->trans("Physical"); + $morphys["mor"] = $langs->trans("Moral"); + print ''.$langs->trans("MemberNature").''; + print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy); + print ""; - print ''.$langs->trans("SubscriptionRequired").''; + print ''.$langs->trans("SubscriptionRequired").''; print $form->selectyesno("subscription", $object->subscription, 1); print ''; diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 94632dc0184..9b66b8e5c7f 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $langs->loadLangs(array("admin", "companies", "bills", "other", "banks")); if (!$user->admin) - accessforbidden(); + accessforbidden(); $action = GETPOST('action', 'alpha'); $actionsave = GETPOST('save', 'alpha'); @@ -240,31 +240,31 @@ $i = 0; $nbofbank = count($bankorder); while ($i < $nbofbank) { - print ''; - print ''.$bankorder[$i][0]."\n"; - print $bankorder[$i][1]; - print ''; - print ''; - $tmparray = explode(' ', $bankorder[$i][2]); - foreach ($tmparray as $key => $val) { - if ($key > 0) - print ', '; - print $langs->trans($val); - } - print "\n"; + print ''; + print ''.$bankorder[$i][0]."\n"; + print $bankorder[$i][1]; + print ''; + print ''; + $tmparray = explode(' ', $bankorder[$i][2]); + foreach ($tmparray as $key => $val) { + if ($key > 0) + print ', '; + print $langs->trans($val); + } + print "\n"; - if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) { - print ''; - print img_picto($langs->trans("Activated"), 'on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'off'); - print ''; - } - print ' '; - print ''."\n"; - $i++; + if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) { + print ''; + print img_picto($langs->trans("Activated"), 'on'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'off'); + print ''; + } + print ' '; + print ''."\n"; + $i++; } print ''."\n"; @@ -287,15 +287,15 @@ $sql .= " WHERE type = '".$type."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); - while ($i < $num_rows) { - $array = $db->fetch_array($resql); - array_push($def, $array[0]); - $i++; - } + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } } else { - dol_print_error($db); + dol_print_error($db); } print "\n"; @@ -311,100 +311,100 @@ print "\n"; clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) { - $dir = dol_buildpath($reldir."core/modules/bank".$valdir); + foreach (array('', '/doc') as $valdir) { + $dir = dol_buildpath($reldir."core/modules/bank".$valdir); - if (is_dir($dir)) { - $handle = opendir($dir); - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) { + $handle = opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) - $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) - $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) + $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) + $modulequalified = 0; - if ($modulequalified) { - print ''; + if ($modulequalified) { + print ''; - // Active - if (in_array($name, $def)) { - print ''; - } else { - print '"; - } + // Active + if (in_array($name, $def)) { + print ''; + } else { + print '"; + } - // Default - print ''; + // Default + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - //$htmltooltip .= '
' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1); - //$htmltooltip .= '
' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - // $htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); - // $htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); - //$htmltooltip .= '
' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1); + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + //$htmltooltip .= '
' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1); + //$htmltooltip .= '
' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + // $htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); + // $htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); + //$htmltooltip .= '
' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1); - print ''; + print ''; - // Preview - print ''; + // Preview + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print '
'; - print(empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) - print $module->info($langs); - else print $module->description; - print '
'; + print(empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) + print $module->info($langs); + else print $module->description; + print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print "'."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; - if ($conf->global->BANKADDON_PDF == $name) { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + if ($conf->global->BANKADDON_PDF == $name) { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + if ($module->type == 'pdf') { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
'; //} @@ -423,38 +423,38 @@ print $langs->trans('BankColorizeMovementDesc'); print ""; // Active if ($conf->global->BANK_COLORIZE_MOVEMENT) { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; } else { - print ''."\n"; - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; + print ''."\n"; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; } print "\n"; if (!empty($conf->global->BANK_COLORIZE_MOVEMENT)) { - $i = 1; - while ($i <= 2) - { - $key = $i; - $color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key; + $i = 1; + while ($i <= 2) + { + $key = $i; + $color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key; - print ''; + print ''; - // Label - print ''.$langs->trans("BankColorizeMovementName".$key).""; - // Color - print ''; - print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : $conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset'); - print ''; - print ""; - $i++; - } + // Label + print ''.$langs->trans("BankColorizeMovementName".$key).""; + // Color + print ''; + print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : $conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset'); + print ''; + print ""; + $i++; + } } print ''; @@ -482,15 +482,15 @@ print $langs->trans('AutoReportLastAccountStatement'); print ''; // Active if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; } else { - print ''."\n"; - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; + print ''."\n"; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; } print "\n"; diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index 3aebadf25a6..621a994cabe 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -55,11 +55,11 @@ if ($action == 'updateMask') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); @@ -72,7 +72,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -110,7 +110,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity); + if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity); } } @@ -144,11 +144,11 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_BOM_FREE_TEXT') { $freetext = GETPOST("BOM_FREE_TEXT", 'none'); // No alpha here, we want exact string @@ -158,11 +158,11 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -211,7 +211,7 @@ foreach ($dirmodels as $reldir) { while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php') + if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { $file = substr($file, 0, dol_strlen($file) - 4); @@ -229,13 +229,13 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering model - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering model + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; print ''; if ($conf->global->BOM_ADDON == $file) @@ -256,16 +256,16 @@ foreach ($dirmodels as $reldir) $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $bom->type = 0; $nextval = $module->getNextValue($mysoc, $bom); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -324,108 +324,108 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/bom".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/bom".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Default - print ''; - if ($conf->global->BOM_ADDON_PDF == $name) - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Default + print ''; + if ($conf->global->BOM_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -457,11 +457,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans(" $variablename = 'BOM_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index ca3fd795b8b..8f28addc994 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -48,99 +48,99 @@ $boxes = array(); if ($action == 'addconst') { - dolibarr_set_const($db, "MAIN_BOXES_MAXLINES", $_POST["MAIN_BOXES_MAXLINES"], '', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_ACTIVATE_FILECACHE", $_POST["MAIN_ACTIVATE_FILECACHE"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_BOXES_MAXLINES", $_POST["MAIN_BOXES_MAXLINES"], '', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_ACTIVATE_FILECACHE", $_POST["MAIN_ACTIVATE_FILECACHE"], 'chaine', 0, '', $conf->entity); } if ($action == 'add') { - $error = 0; - $db->begin(); - if (isset($_POST['boxid']) && is_array($_POST['boxid'])) - { - foreach ($_POST['boxid'] as $boxid) - { - if (is_numeric($boxid['pos']) && $boxid['pos'] >= 0) // 0=Home, 1=... - { - $pos = $boxid['pos']; + $error = 0; + $db->begin(); + if (isset($_POST['boxid']) && is_array($_POST['boxid'])) + { + foreach ($_POST['boxid'] as $boxid) + { + if (is_numeric($boxid['pos']) && $boxid['pos'] >= 0) // 0=Home, 1=... + { + $pos = $boxid['pos']; - // Initialize distinct fk_user with all already existing values of fk_user (user that use a personalized view of boxes for page "pos") - $distinctfkuser = array(); - if (!$error) - { - $sql = "SELECT fk_user"; - $sql .= " FROM ".MAIN_DB_PREFIX."user_param"; - $sql .= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'"; - $sql .= " AND entity = ".$conf->entity; - dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $distinctfkuser[$obj->fk_user] = $obj->fk_user; - $i++; - } - } else { - setEventMessages($db->lasterror(), null, 'errors'); - $error++; - } - } + // Initialize distinct fk_user with all already existing values of fk_user (user that use a personalized view of boxes for page "pos") + $distinctfkuser = array(); + if (!$error) + { + $sql = "SELECT fk_user"; + $sql .= " FROM ".MAIN_DB_PREFIX."user_param"; + $sql .= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'"; + $sql .= " AND entity = ".$conf->entity; + dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $distinctfkuser[$obj->fk_user] = $obj->fk_user; + $i++; + } + } else { + setEventMessages($db->lasterror(), null, 'errors'); + $error++; + } + } - $distinctfkuser['0'] = '0'; // Add entry for fk_user = 0. We must use string as key and val + $distinctfkuser['0'] = '0'; // Add entry for fk_user = 0. We must use string as key and val - foreach ($distinctfkuser as $fk_user) - { - if (!$error && $fk_user != '') - { - $arrayofexistingboxid = array(); - $nbboxonleft = $nbboxonright = 0; - $sql = "SELECT box_id, box_order FROM ".MAIN_DB_PREFIX."boxes"; - $sql .= " WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity; - dol_syslog("boxes.php activate box", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - while ($obj = $db->fetch_object($resql)) - { - $boxorder = $obj->box_order; - if (preg_match('/A/', $boxorder)) $nbboxonleft++; - if (preg_match('/B/', $boxorder)) $nbboxonright++; - $arrayofexistingboxid[$obj->box_id] = 1; - } - } else dol_print_error($db); + foreach ($distinctfkuser as $fk_user) + { + if (!$error && $fk_user != '') + { + $arrayofexistingboxid = array(); + $nbboxonleft = $nbboxonright = 0; + $sql = "SELECT box_id, box_order FROM ".MAIN_DB_PREFIX."boxes"; + $sql .= " WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity; + dol_syslog("boxes.php activate box", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + while ($obj = $db->fetch_object($resql)) + { + $boxorder = $obj->box_order; + if (preg_match('/A/', $boxorder)) $nbboxonleft++; + if (preg_match('/B/', $boxorder)) $nbboxonright++; + $arrayofexistingboxid[$obj->box_id] = 1; + } + } else dol_print_error($db); - if (empty($arrayofexistingboxid[$boxid['value']])) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes ("; - $sql .= "box_id, position, box_order, fk_user, entity"; - $sql .= ") values ("; - $sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity; - $sql .= ")"; + if (empty($arrayofexistingboxid[$boxid['value']])) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes ("; + $sql .= "box_id, position, box_order, fk_user, entity"; + $sql .= ") values ("; + $sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity; + $sql .= ")"; - dol_syslog("boxes.php activate box", LOG_DEBUG); - $resql = $db->query($sql); - if (!$resql) - { - setEventMessages($db->lasterror(), null, 'errors'); - $error++; - } - } else { - dol_syslog("boxes.php activate box - already exists in database", LOG_DEBUG); - } - } - } - } - } - } - if (!$error) - { - $db->commit(); - $action = ''; - } else { - $db->rollback(); - } + dol_syslog("boxes.php activate box", LOG_DEBUG); + $resql = $db->query($sql); + if (!$resql) + { + setEventMessages($db->lasterror(), null, 'errors'); + $error++; + } + } else { + dol_syslog("boxes.php activate box - already exists in database", LOG_DEBUG); + } + } + } + } + } + } + if (!$error) + { + $db->commit(); + $action = ''; + } else { + $db->rollback(); + } } if ($action == 'delete') @@ -150,23 +150,23 @@ if ($action == 'delete') $resql = $db->query($sql); $obj = $db->fetch_object($resql); - if (!empty($obj->box_id)) - { - $db->begin(); + if (!empty($obj->box_id)) + { + $db->begin(); - // Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes) - // $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param"; - // $sql.= " WHERE param LIKE 'MAIN_BOXES_%'"; - // $resql = $db->query($sql); + // Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes) + // $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param"; + // $sql.= " WHERE param LIKE 'MAIN_BOXES_%'"; + // $resql = $db->query($sql); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; - $sql .= " WHERE entity = ".$conf->entity; - $sql .= " AND box_id=".$obj->box_id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; + $sql .= " WHERE entity = ".$conf->entity; + $sql .= " AND box_id=".$obj->box_id; - $resql = $db->query($sql); + $resql = $db->query($sql); - $db->commit(); - } + $db->commit(); + } } if ($action == 'switch') @@ -184,14 +184,14 @@ if ($action == 'switch') $resultupdateto = 0; if (is_object($objfrom) && is_object($objto)) { - $newfirst = $objto->box_order; + $newfirst = $objto->box_order; $newsecond = $objfrom->box_order; - if ($newfirst == $newsecond) - { - $newsecondchar = preg_replace('/[0-9]+/', '', $newsecond); - $newsecondnum = preg_replace('/[a-zA-Z]+/', '', $newsecond); - $newsecond = sprintf("%s%02d", $newsecondchar ? $newsecondchar : 'A', $newsecondnum + 1); - } + if ($newfirst == $newsecond) + { + $newsecondchar = preg_replace('/[0-9]+/', '', $newsecond); + $newsecondnum = preg_replace('/[a-zA-Z]+/', '', $newsecond); + $newsecond = sprintf("%s%02d", $newsecondchar ? $newsecondchar : 'A', $newsecondnum + 1); + } $sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$newfirst."' WHERE rowid=".$objfrom->rowid; dol_syslog($sql); $resultupdatefrom = $db->query($sql); @@ -268,7 +268,7 @@ if ($resql) if ($decalage) { - // If we have renumbered, we correct the field box_order + // If we have renumbered, we correct the field box_order // This occurs just after an insert. $sql = "SELECT box_order"; $sql .= " FROM ".MAIN_DB_PREFIX."boxes"; @@ -339,34 +339,34 @@ print "\n"; foreach ($boxtoadd as $box) { - if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg)) - { - $logo = $box->boximg; - } else { - $logo = preg_replace("/^object_/i", "", $box->boximg); - } + if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg)) + { + $logo = $box->boximg; + } else { + $logo = preg_replace("/^object_/i", "", $box->boximg); + } - print "\n".''."\n"; - print ''."\n"; - print ''.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel); - if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')'; - print ''."\n"; - print ''; - if ($box->note == '(WarningUsingThisBoxSlowDown)') - { - $langs->load("errors"); - print $langs->trans("WarningUsingThisBoxSlowDown"); - } else print ($box->note ? $box->note : ' '); - print ''."\n"; - print ''.$box->sourcefile.''."\n"; + print "\n".''."\n"; + print ''."\n"; + print ''.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel); + if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')'; + print ''."\n"; + print ''; + if ($box->note == '(WarningUsingThisBoxSlowDown)') + { + $langs->load("errors"); + print $langs->trans("WarningUsingThisBoxSlowDown"); + } else print ($box->note ? $box->note : ' '); + print ''."\n"; + print ''.$box->sourcefile.''."\n"; - // For each possible position, an activation link is displayed if the box is not already active for that position - print ''; - print $form->selectarray("boxid[".$box->box_id."][pos]", $pos_name, -1, 1, 0, 0, '', 1)."\n"; - print ''."\n"; - print ''; + // For each possible position, an activation link is displayed if the box is not already active for that position + print ''; + print $form->selectarray("boxid[".$box->box_id."][pos]", $pos_name, -1, 1, 0, 0, '', 1)."\n"; + print ''."\n"; + print ''; - print ''."\n"; + print ''."\n"; } if (!count($boxtoadd) && count($boxactivated)) { @@ -408,7 +408,7 @@ foreach ($boxactivated as $key => $box) $logo = preg_replace("/^object_/i", "", $box->boximg); } - print "\n".''."\n"; + print "\n".''."\n"; print ''; print ''.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel); if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')'; @@ -465,10 +465,10 @@ print ''; // Activate FileCache - Developement if ($conf->global->MAIN_FEATURES_LEVEL == 2 || !empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - print ''.$langs->trans("EnableFileCache").''; - print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1); - print ''; - print ''; + print ''.$langs->trans("EnableFileCache").''; + print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1); + print ''; + print ''; } print ''; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 1e6d21b6f58..febddf901c5 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -64,11 +64,11 @@ if ($action == 'updateMask') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); @@ -81,7 +81,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -119,7 +119,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity); + if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity); } } @@ -153,11 +153,11 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_ORDER_FREE_TEXT') { $freetext = GETPOST("ORDER_FREE_TEXT", 'none'); // No alpha here, we want exact string @@ -167,21 +167,21 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == "setshippableiconinlist") { - // Activate Set Shippable Icon In List - $setshippableiconinlist = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity); - if (!$res > 0) $error++; - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + // Activate Set Shippable Icon In List + $setshippableiconinlist = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity); + if (!$res > 0) $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'setribchq') { $rib = GETPOST('rib', 'alpha'); @@ -203,31 +203,31 @@ elseif ($action == 'setdoc') // Activate ask for payment bank elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER') { - $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } // Activate ask for warehouse elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') { - $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -294,13 +294,13 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering model - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering model + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; print ''; if ($conf->global->COMMANDE_ADDON == $file) @@ -321,16 +321,16 @@ foreach ($dirmodels as $reldir) $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $commande->type = 0; $nextval = $module->getNextValue($mysoc, $commande); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -389,113 +389,113 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/commande".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/commande".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Default - print ''; - if ($conf->global->COMMANDE_ADDON_PDF == $name) - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Default + print ''; + if ($conf->global->COMMANDE_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - //$htmltooltip .= '
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); - //$htmltooltip .= '
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + //$htmltooltip .= '
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); + //$htmltooltip .= '
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -636,11 +636,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans $variablename = 'ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index f2e69f81707..e5c20f647e5 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -109,7 +109,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) foreach ($arrayofimages as $varforimage) { - if ($_FILES[$varforimage]["name"] && ! preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported. + if ($_FILES[$varforimage]["name"] && !preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported. $langs->load("errors"); setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors'); break; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 19ae30d7674..4aeabd4439d 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -41,7 +41,7 @@ $type = 'contract'; if (empty($conf->global->CONTRACT_ADDON)) { - $conf->global->CONTRACT_ADDON = 'mod_contract_serpis'; + $conf->global->CONTRACT_ADDON = 'mod_contract_serpis'; } @@ -53,18 +53,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstcontract', 'alpha'); - $maskvalue = GETPOST('maskcontract', 'alpha'); - if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + $maskconst = GETPOST('maskconstcontract', 'alpha'); + $maskvalue = GETPOST('maskcontract', 'alpha'); + if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'specimen') // For contract { $modele = GETPOST('module', 'alpha'); @@ -77,7 +77,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -115,7 +115,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity); + if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity); } } @@ -149,17 +149,17 @@ elseif ($action == 'setdoc') $draft = GETPOST('CONTRACT_DRAFT_WATERMARK', 'alpha'); $res2 = dolibarr_set_const($db, "CONTRACT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - $value = GETPOST('activate_hideClosedServiceByDefault', 'alpha'); - $res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity); + $value = GETPOST('activate_hideClosedServiceByDefault', 'alpha'); + $res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity); if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -251,16 +251,16 @@ foreach ($dirmodels as $reldir) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mysoc, $contract); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -319,111 +319,111 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/contract".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/contract".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ''; - if ($conf->global->CONTRACT_ADDON_PDF == $name) - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Defaut + print ''; + if ($conf->global->CONTRACT_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'contract').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'contract').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -457,11 +457,11 @@ print '
'; $variablename = 'CONTRACT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 2f33b8445f9..94a3d698c2a 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -165,19 +165,19 @@ if (GETPOST('addoperation', 'alpha')) if ($action == 'updateoperation') { - $emailcollectoroperation = new EmailCollectorAction($db); - $emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int')); + $emailcollectoroperation = new EmailCollectorAction($db); + $emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int')); - $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'none'); + $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'none'); - $result = $emailcollectoroperation->update($user); + $result = $emailcollectoroperation->update($user); - if ($result > 0) - { - $object->fetchActions(); - } else { - setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); - } + if ($result > 0) + { + $object->fetchActions(); + } else { + setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); + } } if ($action == 'deleteoperation') { @@ -199,11 +199,11 @@ if ($action == 'confirm_collect') $res = $object->doCollectOneCollector(); if ($res > 0) { - $debuginfo = $object->debuginfo; - setEventMessages($object->lastresult, null, 'mesgs'); + $debuginfo = $object->debuginfo; + setEventMessages($object->lastresult, null, 'mesgs'); } else { - $debuginfo = $object->debuginfo; - setEventMessages($object->error, null, 'errors'); + $debuginfo = $object->debuginfo; + setEventMessages($object->error, null, 'errors'); } $action = ''; @@ -475,27 +475,27 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; $arrayoftypes = array( - 'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')), - 'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')), - 'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')), - 'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')), - 'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')), - 'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')), - // disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2 - //'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'), // HEADER key value - //'X1'=>'---', - //'notinsubject'=>array('label'=>'SubjectNotIn', 'data-placeholder'=>'SearchString'), - //'notinbody'=>array('label'=>'BodyNotIn', 'data-placeholder'=>'SearchString'), - 'X2'=>'---', - 'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1), - 'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1), - 'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1), - 'answered'=>array('label'=>'Answered', 'data-noparam'=>1), - 'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), - 'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), - 'X3'=>'---', - 'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1), - 'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1), + 'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')), + 'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')), + 'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')), + 'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')), + 'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')), + 'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')), + // disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2 + //'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'), // HEADER key value + //'X1'=>'---', + //'notinsubject'=>array('label'=>'SubjectNotIn', 'data-placeholder'=>'SearchString'), + //'notinbody'=>array('label'=>'BodyNotIn', 'data-placeholder'=>'SearchString'), + 'X2'=>'---', + 'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1), + 'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1), + 'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1), + 'answered'=>array('label'=>'Answered', 'data-noparam'=>1), + 'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), + 'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), + 'X3'=>'---', + 'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1), + 'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1), 'X4'=>'---', 'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1), 'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1) @@ -559,9 +559,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; $arrayoftypes = array( - 'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")), - 'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")), - 'recordevent'=>'RecordEvent'); + 'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")), + 'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")), + 'recordevent'=>'RecordEvent'); if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty'; if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty'; if ($conf->recruitment->enabled) $arrayoftypes['candidature'] = 'CreateCandidature'; @@ -602,7 +602,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $langs->trans($arrayoftypes[$ruleaction['type']]); if (in_array($ruleaction['type'], array('recordevent'))) { - print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked')); + print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked')); } elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) { print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp')); } @@ -610,11 +610,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if ($action == 'editoperation' && $ruleaction['id'] == $operationid) { - print '
'; - print '
'; - print ' '; + print '
'; + print '
'; + print ' '; } else { - print $ruleaction['actionparam']; + print $ruleaction['actionparam']; } print ''; // Move up/down @@ -641,7 +641,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if (!empty($conf->use_javascript_ajax)) { - $urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id; + $urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id; include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } @@ -668,7 +668,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'.$langs->trans("Edit").'
'; // Clone - print '
'.$langs->trans("ToClone").'
'; + print '
'.$langs->trans("ToClone").'
'; // Collect now if (count($object->actions) > 0) { @@ -684,7 +684,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($debuginfo)) { - print info_admin($debuginfo); + print info_admin($debuginfo); } diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 32ab8c2e277..1a0be0cb65f 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -48,7 +48,7 @@ $type = 'shipping'; if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) { - $conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor'; + $conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor'; } @@ -105,7 +105,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -143,7 +143,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity); + if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity); } } @@ -231,14 +231,14 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + else print $tmp; + print ''."\n"; print ''; if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file") @@ -258,16 +258,16 @@ foreach ($dirmodels as $reldir) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mysoc, $expedition); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -328,107 +328,107 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $dir = dol_buildpath($reldir."core/modules/expedition".$valdir); + foreach (array('', '/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/expedition".$valdir); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ''; - if ($conf->global->EXPEDITION_ADDON_PDF == $name) - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Defaut + print ''; + if ($conf->global->EXPEDITION_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'sending').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'sending').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -461,11 +461,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->tr $variablename = 'SHIPPING_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print "\n"; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index ac24f1e0404..221244bfb9d 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -53,66 +53,66 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); - $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha'); - $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); + $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); + $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha'); + $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); $maskconstdeposit = GETPOST('maskconstdeposit', 'alpha'); - $maskinvoice = GETPOST('maskinvoice', 'alpha'); - $maskreplacement = GETPOST('maskreplacement', 'alpha'); - $maskcredit = GETPOST('maskcredit', 'alpha'); + $maskinvoice = GETPOST('maskinvoice', 'alpha'); + $maskreplacement = GETPOST('maskreplacement', 'alpha'); + $maskcredit = GETPOST('maskcredit', 'alpha'); $maskdeposit = GETPOST('maskdeposit', 'alpha'); - if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); - if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity); - if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); + if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); + if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity); + if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); if ($maskconstdeposit) $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'specimen') { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $facture = new Facture($db); - $facture->initAsSpecimen(); + $facture = new Facture($db); + $facture->initAsSpecimen(); // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db); + $module = new $classname($db); - if ($module->write_file($facture, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($facture, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model elseif ($action == 'set') @@ -123,7 +123,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity); + if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity); } } // Set default model @@ -144,89 +144,89 @@ elseif ($action == 'setdoc') } } elseif ($action == 'setmod') { - // TODO Verifier si module numerotation choisi peut etre active - // par appel methode canBeActivated + // TODO Verifier si module numerotation choisi peut etre active + // par appel methode canBeActivated - dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity); } elseif ($action == 'setribchq') { $rib = GETPOST('rib', 'alpha'); $chq = GETPOST('chq', 'alpha'); $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') { $draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha'); - $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_INVOICE_FREE_TEXT') { $freetext = GETPOST('INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string - $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'setforcedate') { $forcedate = GETPOST('forcedate', 'alpha'); - $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'setDefaultPDFModulesByType') { - $invoicetypemodels = GETPOST('invoicetypemodels'); + $invoicetypemodels = GETPOST('invoicetypemodels'); - if (!empty($invoicetypemodels) && is_array($invoicetypemodels)) - { - $error = 0; + if (!empty($invoicetypemodels) && is_array($invoicetypemodels)) + { + $error = 0; - foreach ($invoicetypemodels as $type => $value) - { - $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; - } + foreach ($invoicetypemodels as $type => $value) + { + $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; + } - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } + } } @@ -267,144 +267,144 @@ clearstatcache(); foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/facture/"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) - { - $filebis = $file; - $classname = preg_replace('/\.php$/', '', $file); - // For compatibility - if (!is_file($dir.$filebis)) - { - $filebis = $file."/".$file.".modules.php"; - $classname = "mod_facture_".$file; - } - // Check if there is a filter on country - preg_match('/\-(.*)_(.*)$/', $classname, $reg); - if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/', '', $file); + // For compatibility + if (!is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_facture_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/', $classname, $reg); + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; - $classname = preg_replace('/\-.*$/', '', $classname); - if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') - { - // Charging the numbering class - require_once $dir.$filebis; + $classname = preg_replace('/\-.*$/', '', $classname); + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; - $module = new $classname($db); + $module = new $classname($db); - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - if ($module->isEnabled()) - { - print ''; - echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); - print "\n"; + if ($module->isEnabled()) + { + print ''; + echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); + print "\n"; - print $module->info(); + print $module->info(); - print ''; + print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; - print ''; - //print "> ".$conf->global->FACTURE_ADDON." - ".$file; - if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file) - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + print ''; + //print "> ".$conf->global->FACTURE_ADDON." - ".$file; + if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file) + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - $facture = new Facture($db); - $facture->initAsSpecimen(); + $facture = new Facture($db); + $facture->initAsSpecimen(); - // Example for standard invoice - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $facture->type = 0; - $nextval = $module->getNextValue($mysoc, $facture); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= $langs->trans("NextValueForInvoices").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } - // Example for remplacement - $facture->type = 1; - $nextval = $module->getNextValue($mysoc, $facture); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= $langs->trans("NextValueForReplacements").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + // Example for standard invoice + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $facture->type = 0; + $nextval = $module->getNextValue($mysoc, $facture); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= $langs->trans("NextValueForInvoices").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } + // Example for remplacement + $facture->type = 1; + $nextval = $module->getNextValue($mysoc, $facture); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= $langs->trans("NextValueForReplacements").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } - // Example for credit invoice - $facture->type = 2; - $nextval = $module->getNextValue($mysoc, $facture); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= $langs->trans("NextValueForCreditNotes").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } - // Example for deposit invoice - $facture->type = 3; - $nextval = $module->getNextValue($mysoc, $facture); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= $langs->trans("NextValueForDeposit").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval; - } else { - $htmltooltip .= $langs->trans($module->error); - } - } + // Example for credit invoice + $facture->type = 2; + $nextval = $module->getNextValue($mysoc, $facture); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= $langs->trans("NextValueForCreditNotes").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } + // Example for deposit invoice + $facture->type = 3; + $nextval = $module->getNextValue($mysoc, $facture); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= $langs->trans("NextValueForDeposit").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval; + } else { + $htmltooltip .= $langs->trans($module->error); + } + } - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); - if ($conf->global->FACTURE_ADDON.'.php' == $file) // If module is the one used, we show existing errors - { - if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); - } + if ($conf->global->FACTURE_ADDON.'.php' == $file) // If module is the one used, we show existing errors + { + if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); + } - print ''; + print ''; - print "\n"; - } - } - } - } - closedir($handle); - } - } + print "\n"; + } + } + } + } + closedir($handle); + } + } } print ''; @@ -426,16 +426,16 @@ $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { - $array = $db->fetch_array($resql); - array_push($def, $array[0]); - $i++; - } + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } } else { - dol_print_error($db); + dol_print_error($db); } print ''; @@ -454,156 +454,156 @@ $activatedModels = array(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/facture".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/facture".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; + if ($modulequalified) + { + print ''; - // Active - if (in_array($name, $def)) - { - print ''; - } else { - print '"; - } + // Active + if (in_array($name, $def)) + { + print ''; + } else { + print '"; + } - // Defaut - print ''; + // Defaut + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1); - $htmltooltip .= '
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1); + $htmltooltip .= '
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1); - print ''; + print ''; - // Preview - print ''; + // Preview + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print '
'; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print '
'; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("SetAsDefault"), 'switch_off').''; - print "'."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("SetAsDefault"), 'switch_off').''; + print "'; - if ($conf->global->FACTURE_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').''; - } - print ''; + if ($conf->global->FACTURE_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
'; if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf { - /* + /* * Document templates generators */ - print '
'; - print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', ''); - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print '
'; + print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', ''); + print ''; + print ''; + print ''; + print '
'.$langs->trans("Type").''.$langs->trans("Name").'
'; + print ''; + print ''; + print ''; + print ''; + print "\n"; - $listtype = array( - Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), - Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), - Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), - Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), - ); - if (!empty($conf->global->INVOICE_USE_SITUATION)) - { - $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); - } + $listtype = array( + Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), + Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), + Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), + Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), + ); + if (!empty($conf->global->INVOICE_USE_SITUATION)) + { + $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); + } - foreach ($listtype as $type => $trans) - { - $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; - $current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; - print ''; - print ''; - print ''; - print "\n"; - } + foreach ($listtype as $type => $trans) + { + $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; + $current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; + print ''; + print ''; + print ''; + print "\n"; + } - print '
'.$langs->trans("Type").''.$langs->trans("Name").'
'.$trans.''.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'
'.$trans.''.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'
'; - print "
"; + print ''; + print ""; } /* @@ -629,37 +629,37 @@ print "".$langs->trans("SuggestPaymentByRIBOnAccount").""; print ""; if (!empty($conf->banque->enabled)) { - $sql = "SELECT rowid, label"; - $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql .= " WHERE clos = 0"; - $sql .= " AND courant = 1"; - $sql .= " AND entity IN (".getEntity('bank_account').")"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - if ($num > 0) - { - print ''; + print ''; + while ($i < $num) + { + $row = $db->fetch_row($resql); - print ''; + print ''; - $i++; - } - print ""; - } else { - print ''.$langs->trans("NoActiveBankAccountDefined").''; - } - } + $i++; + } + print ""; + } else { + print ''.$langs->trans("NoActiveBankAccountDefined").''; + } + } } else { - print $langs->trans("BankModuleNotActive"); + print $langs->trans("BankModuleNotActive"); } print ""; @@ -679,18 +679,18 @@ $sql .= " AND entity IN (".getEntity('bank_account').")"; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($resql); + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $db->fetch_row($resql); - print ''; + print ''; - $i++; - } + $i++; + } } print ""; print ""; @@ -735,11 +735,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->tra $variablename = 'INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index c8094b99239..3886f85d330 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -43,7 +43,7 @@ $type = 'contract'; if (empty($conf->global->HOLIDAY_ADDON)) { - $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna'; + $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna'; } @@ -55,18 +55,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstholiday', 'alpha'); - $maskvalue = GETPOST('maskholiday', 'alpha'); - if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + $maskconst = GETPOST('maskconstholiday', 'alpha'); + $maskvalue = GETPOST('maskholiday', 'alpha'); + if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'specimen') // For contract { $modele = GETPOST('module', 'alpha'); @@ -79,7 +79,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -117,7 +117,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity); + if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity); } } @@ -154,11 +154,11 @@ elseif ($action == 'setdoc') if (!$res1 > 0 || !$res2 > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -251,16 +251,16 @@ foreach ($dirmodels as $reldir) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mysoc, $holiday); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -282,11 +282,11 @@ print '
'; if ($conf->global->MAIN_FEATURES_LEVEL < 2) { - dol_fiche_end(); - // End of page - llxFooter(); - $db->close(); - exit; + dol_fiche_end(); + // End of page + llxFooter(); + $db->close(); + exit; } /* @@ -304,8 +304,8 @@ $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); + $i = 0; + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -332,111 +332,111 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/holiday".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/holiday".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Default - print ''; - if ($conf->global->HOLIDAY_ADDON_PDF == $name) - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Default + print ''; + if ($conf->global->HOLIDAY_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'contract').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'contract').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -473,11 +473,11 @@ print '
'; $variablename = 'HOLIDAY_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 3414f00b5d1..ea36b25e3ce 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -113,29 +113,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { - $tmp = FormMail::getAvailableSubstitKey('formemail'); - $tmp['__(AnyTranslationKey)__'] = 'Translation'; - $helpsubstit = $langs->trans("AvailableVariables").':
'; - $helpsubstitforlines = $langs->trans("AvailableVariables").':
'; - foreach ($tmp as $key => $val) - { - $helpsubstit .= $key.' -> '.$val.'
'; - $helpsubstitforlines .= $key.' -> '.$val.'
'; - } + $tmp = FormMail::getAvailableSubstitKey('formemail'); + $tmp['__(AnyTranslationKey)__'] = 'Translation'; + $helpsubstit = $langs->trans("AvailableVariables").':
'; + $helpsubstitforlines = $langs->trans("AvailableVariables").':
'; + foreach ($tmp as $key => $val) + { + $helpsubstit .= $key.' -> '.$val.'
'; + $helpsubstitforlines .= $key.' -> '.$val.'
'; + } } else { - $tmp = FormMail::getAvailableSubstitKey('formemailwithlines'); - $tmp['__(AnyTranslationKey)__'] = 'Translation'; - $helpsubstit = $langs->trans("AvailableVariables").':
'; - $helpsubstitforlines = $langs->trans("AvailableVariables").':
'; - foreach ($tmp as $key => $val) - { - $helpsubstit .= $key.' -> '.$val.'
'; - } - $tmp = FormMail::getAvailableSubstitKey('formemailforlines'); - foreach ($tmp as $key => $val) - { - $helpsubstitforlines .= $key.' -> '.$val.'
'; - } + $tmp = FormMail::getAvailableSubstitKey('formemailwithlines'); + $tmp['__(AnyTranslationKey)__'] = 'Translation'; + $helpsubstit = $langs->trans("AvailableVariables").':
'; + $helpsubstitforlines = $langs->trans("AvailableVariables").':
'; + foreach ($tmp as $key => $val) + { + $helpsubstit .= $key.' -> '.$val.'
'; + } + $tmp = FormMail::getAvailableSubstitKey('formemailforlines'); + foreach ($tmp as $key => $val) + { + $helpsubstitforlines .= $key.' -> '.$val.'
'; + } } @@ -201,206 +201,206 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // 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 - { - $search_label = ''; - $search_type_template = ''; - $search_lang = ''; - $search_fk_user = ''; - $search_topic = ''; - $toselect = ''; - $search_array_options = array(); - } + // 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 + { + $search_label = ''; + $search_type_template = ''; + $search_lang = ''; + $search_fk_user = ''; + $search_topic = ''; + $toselect = ''; + $search_array_options = array(); + } - // Actions add or modify an entry into a dictionary - if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) - { - $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); - $listfieldinsert = explode(',', $tabfieldinsert[$id]); - $listfieldmodify = explode(',', $tabfieldinsert[$id]); - $listfieldvalue = explode(',', $tabfieldvalue[$id]); + // Actions add or modify an entry into a dictionary + if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) + { + $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); + $listfieldinsert = explode(',', $tabfieldinsert[$id]); + $listfieldmodify = explode(',', $tabfieldinsert[$id]); + $listfieldvalue = explode(',', $tabfieldvalue[$id]); - // Check that all fields are filled - $ok = 1; - foreach ($listfield as $f => $value) - { - // Not mandatory fields - if ($value == 'joinfiles') continue; - if ($value == 'content') continue; - if ($value == 'content_lines') continue; + // Check that all fields are filled + $ok = 1; + foreach ($listfield as $f => $value) + { + // Not mandatory fields + if ($value == 'joinfiles') continue; + if ($value == 'content') continue; + if ($value == 'content_lines') continue; - if (GETPOST('actionmodify', 'alpha') && $value == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid]; + if (GETPOST('actionmodify', 'alpha') && $value == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid]; - if ((!isset($_POST[$value]) || $_POST[$value] == '' || $_POST[$value] == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') - { - $ok = 0; - $fieldnamekey = $listfield[$f]; - // We take translate key of field - if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Code'; - if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; - if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; - if ($fieldnamekey == 'type_template') $fieldnamekey = 'TypeOfTemplate'; - if ($fieldnamekey == 'fk_user') $fieldnamekey = 'Owner'; - if ($fieldnamekey == 'private') $fieldnamekey = 'Private'; - if ($fieldnamekey == 'position') $fieldnamekey = 'Position'; - if ($fieldnamekey == 'topic') $fieldnamekey = 'Topic'; + if ((!isset($_POST[$value]) || $_POST[$value] == '' || $_POST[$value] == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') + { + $ok = 0; + $fieldnamekey = $listfield[$f]; + // We take translate key of field + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Code'; + if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; + if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; + if ($fieldnamekey == 'type_template') $fieldnamekey = 'TypeOfTemplate'; + if ($fieldnamekey == 'fk_user') $fieldnamekey = 'Owner'; + if ($fieldnamekey == 'private') $fieldnamekey = 'Private'; + if ($fieldnamekey == 'position') $fieldnamekey = 'Position'; + if ($fieldnamekey == 'topic') $fieldnamekey = 'Topic'; - setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); - } - } + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); + } + } - // Si verif ok et action add, on ajoute la ligne - if ($ok && GETPOST('actionadd')) - { - // Add new entry - $sql = "INSERT INTO ".$tabname[$id]." ("; - // List of fields - $sql .= $tabfieldinsert[$id]; - $sql .= ",active)"; - $sql .= " VALUES("; + // Si verif ok et action add, on ajoute la ligne + if ($ok && GETPOST('actionadd')) + { + // Add new entry + $sql = "INSERT INTO ".$tabname[$id]." ("; + // List of fields + $sql .= $tabfieldinsert[$id]; + $sql .= ",active)"; + $sql .= " VALUES("; - // List of values - $i = 0; - foreach ($listfieldinsert as $f => $value) - { - $keycode = $listfieldvalue[$i]; - if ($value == 'lang') $keycode = 'langcode'; - if (empty($keycode)) $keycode = $value; + // List of values + $i = 0; + foreach ($listfieldinsert as $f => $value) + { + $keycode = $listfieldvalue[$i]; + if ($value == 'lang') $keycode = 'langcode'; + if (empty($keycode)) $keycode = $value; - if ($value == 'entity') $_POST[$keycode] = $conf->entity; - if ($value == 'fk_user' && !($_POST[$keycode] > 0)) $_POST[$keycode] = ''; - if ($value == 'private' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '0'; - if ($value == 'position' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '1'; - //var_dump($keycode.' '.$value); + if ($value == 'entity') $_POST[$keycode] = $conf->entity; + if ($value == 'fk_user' && !($_POST[$keycode] > 0)) $_POST[$keycode] = ''; + if ($value == 'private' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '0'; + if ($value == 'position' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '1'; + //var_dump($keycode.' '.$value); - if ($i) $sql .= ", "; - if (GETPOST($keycode) == '' && $keycode != 'langcode') $sql .= "null"; // langcode must be '' if not defined so the unique key that include lang will work - elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work - elseif ($keycode == 'content') { - $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; - } elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) { - $sql .= (int) GETPOST($keycode, 'int'); - } else { - $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; - } + if ($i) $sql .= ", "; + if (GETPOST($keycode) == '' && $keycode != 'langcode') $sql .= "null"; // langcode must be '' if not defined so the unique key that include lang will work + elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work + elseif ($keycode == 'content') { + $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; + } elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) { + $sql .= (int) GETPOST($keycode, 'int'); + } else { + $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; + } - $i++; - } - $sql .= ", 1)"; + $i++; + } + $sql .= ", 1)"; - dol_syslog("actionadd", LOG_DEBUG); - $result = $db->query($sql); - if ($result) // Add is ok - { - setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST = array('id'=>$id); // Clean $_POST array, we keep only id - } else { - if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); - } else { - dol_print_error($db); - } - } - } + dol_syslog("actionadd", LOG_DEBUG); + $result = $db->query($sql); + if ($result) // Add is ok + { + setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); + $_POST = array('id'=>$id); // Clean $_POST array, we keep only id + } else { + if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); + } else { + dol_print_error($db); + } + } + } - // Si verif ok et action modify, on modifie la ligne - if ($ok && GETPOST('actionmodify')) - { - $rowidcol = "rowid"; + // Si verif ok et action modify, on modifie la ligne + if ($ok && GETPOST('actionmodify')) + { + $rowidcol = "rowid"; - // Modify entry - $sql = "UPDATE ".$tabname[$id]." SET "; - // Modifie valeur des champs - $i = 0; - foreach ($listfieldmodify as $field) - { - $keycode = $listfieldvalue[$i]; - if ($field == 'lang') $keycode = 'langcode'; - if (empty($keycode)) $keycode = $field; + // Modify entry + $sql = "UPDATE ".$tabname[$id]." SET "; + // Modifie valeur des champs + $i = 0; + foreach ($listfieldmodify as $field) + { + $keycode = $listfieldvalue[$i]; + if ($field == 'lang') $keycode = 'langcode'; + if (empty($keycode)) $keycode = $field; - if ($field == 'fk_user' && !($_POST['fk_user'] > 0)) $_POST['fk_user'] = ''; - if ($field == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid]; - if ($field == 'joinfiles') $_POST['joinfiles'] = $_POST['joinfiles-'.$rowid]; - if ($field == 'content') $_POST['content'] = $_POST['content-'.$rowid]; - if ($field == 'content_lines') $_POST['content_lines'] = $_POST['content_lines-'.$rowid]; - if ($field == 'entity') $_POST[$keycode] = $conf->entity; + if ($field == 'fk_user' && !($_POST['fk_user'] > 0)) $_POST['fk_user'] = ''; + if ($field == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid]; + if ($field == 'joinfiles') $_POST['joinfiles'] = $_POST['joinfiles-'.$rowid]; + if ($field == 'content') $_POST['content'] = $_POST['content-'.$rowid]; + if ($field == 'content_lines') $_POST['content_lines'] = $_POST['content_lines-'.$rowid]; + if ($field == 'entity') $_POST[$keycode] = $conf->entity; - if ($i) $sql .= ", "; - $sql .= $field."="; + if ($i) $sql .= ", "; + $sql .= $field."="; - if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && !GETPOST($keycode))) $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work - elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work - elseif ($keycode == 'content') { - $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; - } elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) { - $sql .= (int) GETPOST($keycode, 'int'); - } else { - $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; - } + if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && !GETPOST($keycode))) $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work + elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work + elseif ($keycode == 'content') { + $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; + } elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) { + $sql .= (int) GETPOST($keycode, 'int'); + } else { + $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; + } - $i++; - } - $sql .= " WHERE ".$rowidcol." = '".$rowid."'"; - //print $sql;exit; - dol_syslog("actionmodify", LOG_DEBUG); - //print $sql; - $resql = $db->query($sql); - if ($resql) - { - setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - } else { - setEventMessages($db->error(), null, 'errors'); - } - } - } + $i++; + } + $sql .= " WHERE ".$rowidcol." = '".$rowid."'"; + //print $sql;exit; + dol_syslog("actionmodify", LOG_DEBUG); + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); + } else { + setEventMessages($db->error(), null, 'errors'); + } + } + } - if ($action == 'confirm_delete' && $confirm == 'yes') // delete - { - $rowidcol = "rowid"; + if ($action == 'confirm_delete' && $confirm == 'yes') // delete + { + $rowidcol = "rowid"; - $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; + $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; - dol_syslog("delete", LOG_DEBUG); - $result = $db->query($sql); - if (!$result) - { - if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') - { - setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); - } else { - dol_print_error($db); - } - } - } + dol_syslog("delete", LOG_DEBUG); + $result = $db->query($sql); + if (!$result) + { + if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') + { + setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); + } else { + dol_print_error($db); + } + } + } - // activate - if ($action == $acts[0]) - { - $rowidcol = "rowid"; + // activate + if ($action == $acts[0]) + { + $rowidcol = "rowid"; - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } + } - // disable - if ($action == $acts[1]) - { - $rowidcol = "rowid"; + // disable + if ($action == $acts[1]) + { + $rowidcol = "rowid"; - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } + } } @@ -428,7 +428,7 @@ dol_fiche_head($head, 'templates', '', -1); // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } //var_dump($elementList); @@ -613,90 +613,90 @@ dol_syslog("htdocs/admin/dict", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - $param = '&id='.$id; - if ($search_label) $param .= '&search_label='.urlencode($search_label); - if ($search_lang > 0) $param .= '&search_lang='.urlencode($search_lang); - if ($search_type_template != '-1') $param .= '&search_type_template='.urlencode($search_type_template); - if ($search_fk_user > 0) $param .= '&search_fk_user='.urlencode($search_fk_user); - if ($search_topic) $param .= '&search_topic='.urlencode($search_topic); + $param = '&id='.$id; + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_lang > 0) $param .= '&search_lang='.urlencode($search_lang); + if ($search_type_template != '-1') $param .= '&search_type_template='.urlencode($search_type_template); + if ($search_fk_user > 0) $param .= '&search_fk_user='.urlencode($search_fk_user); + if ($search_topic) $param .= '&search_topic='.urlencode($search_topic); - $paramwithsearch = $param; - if ($sortorder) $paramwithsearch .= '&sortorder='.urlencode($sortorder); - if ($sortfield) $paramwithsearch .= '&sortfield='.urlencode($sortfield); - if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha')); + $paramwithsearch = $param; + if ($sortorder) $paramwithsearch .= '&sortorder='.urlencode($sortorder); + if ($sortfield) $paramwithsearch .= '&sortfield='.urlencode($sortfield); + if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha')); - // There is several pages - if ($num > $listlimit) - { - print ''; - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); - print ''; - } + // There is several pages + if ($num > $listlimit) + { + print ''; + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); + print ''; + } - // Title line with search boxes - print ''; + // Title line with search boxes + print ''; - $filterfound = 0; - foreach ($fieldlist as $field => $value) - { - if ($value == 'label') { - print ''; - } elseif ($value == 'lang') { - print ''; - print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth100'); - print ''; - } elseif ($value == 'fk_user') { - print ''; - $restrictid = array(); - if (!$user->admin) $restrictid = array($user->id); - //var_dump($restrictid); - print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, 'hierarchyme', null, 0, 0, 1, '', 0, '', 'maxwidth100'); - print ''; - } elseif ($value == 'topic') { - print ''; - } elseif ($value == 'type_template') { - print ''.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 maxwidth100onsmartphone').''; - } elseif (!in_array($value, array('content', 'content_lines'))) { - print ''; - } - } + $filterfound = 0; + foreach ($fieldlist as $field => $value) + { + if ($value == 'label') { + print ''; + } elseif ($value == 'lang') { + print ''; + print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth100'); + print ''; + } elseif ($value == 'fk_user') { + print ''; + $restrictid = array(); + if (!$user->admin) $restrictid = array($user->id); + //var_dump($restrictid); + print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, 'hierarchyme', null, 0, 0, 1, '', 0, '', 'maxwidth100'); + print ''; + } elseif ($value == 'topic') { + print ''; + } elseif ($value == 'type_template') { + print ''.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 maxwidth100onsmartphone').''; + } elseif (!in_array($value, array('content', 'content_lines'))) { + print ''; + } + } - if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print ''; + if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print ''; - // Action column - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; - print ''; + // Action column + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print ''; + print ''; - // Title of lines - print ''; - foreach ($fieldlist as $field => $value) - { - $showfield = 1; // By defaut - $align = "left"; - $sortable = 1; - $valuetoshow = ''; - $forcenowrap = 1; - /* + // Title of lines + print ''; + foreach ($fieldlist as $field => $value) + { + $showfield = 1; // By defaut + $align = "left"; + $sortable = 1; + $valuetoshow = ''; + $forcenowrap = 1; + /* $tmparray=getLabelOfField($fieldlist[$field]); $showfield=$tmp['showfield']; $valuetoshow=$tmp['valuetoshow']; $align=$tmp['align']; $sortable=$tmp['sortable']; */ - $valuetoshow = ucfirst($fieldlist[$field]); // By defaut - $valuetoshow = $langs->trans($valuetoshow); // try to translate - if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); } - if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } - if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } - if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Code"); } - if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); } + $valuetoshow = ucfirst($fieldlist[$field]); // By defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); } + if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } + if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Code"); } + if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); } if ($fieldlist[$field] == 'private') { $align = 'center'; } if ($fieldlist[$field] == 'position') { $align = 'center'; } @@ -704,99 +704,99 @@ if ($resql) if ($fieldlist[$field] == 'content') { $valuetoshow = $langs->trans("Content"); $showfield = 0; } if ($fieldlist[$field] == 'content_lines') { $valuetoshow = $langs->trans("ContentLines"); $showfield = 0; } - // Show fields - if ($showfield) - { - if (!empty($tabhelp[$id][$value])) - { - if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click - else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover - } - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder); - } - } + // Show fields + if ($showfield) + { + if (!empty($tabhelp[$id][$value])) + { + if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click + else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover + } + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder); + } + } - print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); - print getTitleFieldOfList(''); - print ''; + print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); + print getTitleFieldOfList(''); + print ''; - if ($num) - { - // Lines with values - while ($i < $num) - { - $obj = $db->fetch_object($resql); + if ($num) + { + // Lines with values + while ($i < $num) + { + $obj = $db->fetch_object($resql); - if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) - { - print ''; + if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) + { + print ''; - $tmpaction = 'edit'; - $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook = $hookmanager->executeHooks('editEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error = $hookmanager->error; $errors = $hookmanager->errors; + $tmpaction = 'edit'; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('editEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; - // Show fields - if (empty($reshook)) fieldList($fieldlist, $obj, $tabname[$id], 'edit'); + // Show fields + if (empty($reshook)) fieldList($fieldlist, $obj, $tabname[$id], 'edit'); - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print ''; + print ''; - $fieldsforcontent = array('topic', 'joinfiles', 'content'); - if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) - { - $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); - } - foreach ($fieldsforcontent as $tmpfieldlist) - { - $showfield = 1; - $align = "left"; - $valuetoshow = $obj->{$tmpfieldlist}; + $fieldsforcontent = array('topic', 'joinfiles', 'content'); + if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) + { + $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); + } + foreach ($fieldsforcontent as $tmpfieldlist) + { + $showfield = 1; + $align = "left"; + $valuetoshow = $obj->{$tmpfieldlist}; - $class = 'tddict'; - // Show value for field - if ($showfield) { + $class = 'tddict'; + // Show value for field + if ($showfield) { // Show line for topic, joinfiles and content - print ''; - print ''; - if ($tmpfieldlist == 'topic') - { - print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; - print ''; - } - if ($tmpfieldlist == 'joinfiles') - { - print ''.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; - print ''; - } - if ($tmpfieldlist == 'content') - { - print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'
'; - $okforextended = true; - if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; - $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); - print $doleditor->Create(1); - } - print ''; - print ''; - print ''; - } - } + print ''; + print ''; + if ($tmpfieldlist == 'topic') + { + print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; + print ''; + } + if ($tmpfieldlist == 'joinfiles') + { + print ''.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; + print ''; + } + if ($tmpfieldlist == 'content') + { + print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'
'; + $okforextended = true; + if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; + $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); + print $doleditor->Create(1); + } + print ''; + print ''; + print ''; + } + } - print "\n"; - } else { - $keyforobj = 'type_template'; - if (!in_array($obj->$keyforobj, array_keys($elementList))) - { - $i++; - continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled) - } + print "\n"; + } else { + $keyforobj = 'type_template'; + if (!in_array($obj->$keyforobj, array_keys($elementList))) + { + $i++; + continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled) + } // Test on 'enabled' if (!dol_eval($obj->enabled, 1)) { @@ -804,100 +804,100 @@ if ($resql) continue; // Email template not qualified } - print ''; + print ''; - $tmpaction = 'view'; - $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook = $hookmanager->executeHooks('viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $tmpaction = 'view'; + $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error = $hookmanager->error; $errors = $hookmanager->errors; + $error = $hookmanager->error; $errors = $hookmanager->errors; - if (empty($reshook)) - { - foreach ($fieldlist as $field => $value) - { - if (in_array($fieldlist[$field], array('content', 'content_lines'))) continue; - $showfield = 1; - $align = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; - if ($value == 'label' || $value == 'topic') - { - $valuetoshow = dol_escape_htmltag($valuetoshow); - } - if ($value == 'type_template') - { - $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; - } - if ($value == 'lang' && $valuetoshow) - { - $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow); - } - if ($value == 'fk_user') - { - if ($valuetoshow > 0) - { - $fuser = new User($db); - $fuser->fetch($valuetoshow); - $valuetoshow = $fuser->getNomUrl(1); - } - } - if ($value == 'private') - { - $align = "center"; - if ($valuetoshow) $valuetoshow = yn($valuetoshow); - else $valuetoshow = ''; - } - if ($value == 'position') - { - $align = "center"; - } - if ($value == 'joinfiles') - { - $align = "center"; - if ($valuetoshow) $valuetoshow = 1; - else $valuetoshow = ''; - } + if (empty($reshook)) + { + foreach ($fieldlist as $field => $value) + { + if (in_array($fieldlist[$field], array('content', 'content_lines'))) continue; + $showfield = 1; + $align = "left"; + $valuetoshow = $obj->{$fieldlist[$field]}; + if ($value == 'label' || $value == 'topic') + { + $valuetoshow = dol_escape_htmltag($valuetoshow); + } + if ($value == 'type_template') + { + $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; + } + if ($value == 'lang' && $valuetoshow) + { + $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow); + } + if ($value == 'fk_user') + { + if ($valuetoshow > 0) + { + $fuser = new User($db); + $fuser->fetch($valuetoshow); + $valuetoshow = $fuser->getNomUrl(1); + } + } + if ($value == 'private') + { + $align = "center"; + if ($valuetoshow) $valuetoshow = yn($valuetoshow); + else $valuetoshow = ''; + } + if ($value == 'position') + { + $align = "center"; + } + if ($value == 'joinfiles') + { + $align = "center"; + if ($valuetoshow) $valuetoshow = 1; + else $valuetoshow = ''; + } - $class = 'tddict'; + $class = 'tddict'; // Show value for field if ($showfield) { - print ''; - print ''.$valuetoshow.''; + print ''; + print ''.$valuetoshow.''; } - } - } + } + } - // Can an entry be erased or disabled ? - $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default - if (!$user->admin && $obj->fk_user != $user->id) - { - $iserasable = 0; - $canbedisabled = 0; - $canbemodified = 0; - } + // Can an entry be erased or disabled ? + $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default + if (!$user->admin && $obj->fk_user != $user->id) + { + $iserasable = 0; + $canbedisabled = 0; + $canbemodified = 0; + } - $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); - if ($param) $url .= '&'.$param; - $url .= '&'; + $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); + if ($param) $url .= '&'.$param; + $url .= '&'; - // Status / Active - print ''; - if ($canbedisabled) print ''.$actl[$obj->active].''; - else print ''.$actl[$obj->active].''; - print ""; + // Status / Active + print ''; + if ($canbedisabled) print ''.$actl[$obj->active].''; + else print ''.$actl[$obj->active].''; + print ""; - // Modify link / Delete link - print ''; - if ($canbemodified) print ''.img_edit().''; - if ($iserasable) - { - print ''.img_delete().''; - //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin - } - print ''; + // Modify link / Delete link + print ''; + if ($canbemodified) print ''.img_edit().''; + if ($iserasable) + { + print ''.img_delete().''; + //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin + } + print ''; - /* + /* $fieldsforcontent = array('content'); if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { @@ -925,15 +925,15 @@ if ($resql) } }*/ - print "\n"; - } + print "\n"; + } - $i++; - } - } + $i++; + } + } } else { - dol_print_error($db); + dol_print_error($db); } print ''; diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index fe4e4a05818..2ea4853e3ca 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -56,11 +56,11 @@ if ($action == 'updateMask') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); @@ -73,7 +73,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -111,7 +111,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity); + if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity); } } @@ -145,11 +145,11 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_MRP_MO_FREE_TEXT') { $freetext = GETPOST("MRP_MO_FREE_TEXT", 'none'); // No alpha here, we want exact string @@ -159,11 +159,11 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -212,7 +212,7 @@ foreach ($dirmodels as $reldir) { while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php') + if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { $file = substr($file, 0, dol_strlen($file) - 4); @@ -230,13 +230,13 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering model - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering model + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; print ''; if ($conf->global->MRP_MO_ADDON == $file) @@ -257,16 +257,16 @@ foreach ($dirmodels as $reldir) $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $mrp->type = 0; $nextval = $module->getNextValue($mysoc, $mrp); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -325,108 +325,108 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/mrp".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/mrp".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Default - print ''; - if ($conf->global->MRP_MO_ADDON_PDF == $name) - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Default + print ''; + if ($conf->global->MRP_MO_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -458,11 +458,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnMOs"), $langs->trans("A $variablename = 'MRP_MO_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index 89b16023d4c..3d0b591af10 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -45,13 +45,13 @@ $type = 'reception'; if (!empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RECEPTION)) { - // This option should always be set to on when module is on. - dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity); + // This option should always be set to on when module is on. + dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity); } if (empty($conf->global->RECEPTION_ADDON_NUMBER)) { - $conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl'; + $conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl'; } @@ -108,7 +108,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -146,7 +146,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->RECEPTION_ADDON_PDF == "$value") dolibarr_del_const($db, 'RECEPTION_ADDON_PDF', $conf->entity); + if ($conf->global->RECEPTION_ADDON_PDF == "$value") dolibarr_del_const($db, 'RECEPTION_ADDON_PDF', $conf->entity); } } @@ -236,14 +236,14 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + else print $tmp; + print ''."\n"; print ''; if ($conf->global->RECEPTION_ADDON_NUMBER == "$file") @@ -263,16 +263,16 @@ foreach ($dirmodels as $reldir) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mysoc, $reception); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -333,110 +333,110 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/reception".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/reception".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ''; - if ($conf->global->RECEPTION_ADDON_PDF == $name) - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Defaut + print ''; + if ($conf->global->RECEPTION_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'reception').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'reception').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 090a72327d8..4edff5e93b3 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -51,42 +51,42 @@ $reg = array(); if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; + $code = $reg[1]; - // If constant is for a unique choice, delete other choices - if (in_array($code, array('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE'))) { - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_BILL', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_VALIDATE_ORDER', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE', $conf->entity); - } - if (in_array($code, array('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'))) { - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_BILL', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', $conf->entity); - dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', $conf->entity); - } + // If constant is for a unique choice, delete other choices + if (in_array($code, array('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE'))) { + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_BILL', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_VALIDATE_ORDER', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE', $conf->entity); + } + if (in_array($code, array('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'))) { + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_BILL', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', $conf->entity); + dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', $conf->entity); + } - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } if ($action == 'warehouse') @@ -224,14 +224,14 @@ print ''.$langs->trans("DeStockOnBill").''; print ''; if (!empty($conf->facture->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL); + } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")); + print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")); } print "\n\n"; $found++; @@ -242,14 +242,14 @@ print ''.$langs->trans("DeStockOnValidateOrder").''; print ''; if (!empty($conf->commande->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER); + } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")); + print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")); } print "\n\n"; $found++; @@ -262,14 +262,14 @@ print ''.$langs->trans("DeStockOnShipment").''; print ''; if (!empty($conf->expedition->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT); + } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); + print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); } print "\n\n"; $found++; @@ -280,14 +280,14 @@ print ''.$langs->trans("DeStockOnShipmentOnClosing").''; print ''; if (!empty($conf->expedition->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE); + } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); + print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); } print "\n\n"; $found++; @@ -312,14 +312,14 @@ print ''.$langs->trans("ReStockOnBill").''; print ''; if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL); + } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); + print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); } print "\n\n"; $found++; @@ -331,14 +331,14 @@ print ''.$langs->trans("ReStockOnValidateOrder").''; print ''; if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER); + } } else { - print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); + print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); } print "\n\n"; $found++; @@ -347,43 +347,43 @@ if (!empty($conf->reception->enabled)) { print ''; print ''.$langs->trans("StockOnReception").''; - print ''; + print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION); + } print "\n\n"; $found++; - print ''; + print ''; print ''.$langs->trans("StockOnReceptionOnClosing").''; - print ''; + print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE); + } print "\n\n"; $found++; } else { print ''; print ''.$langs->trans("ReStockOnDispatchOrder").''; - print ''; + print ''; if (!empty($conf->fournisseur->enabled)) { - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER); + } } else { print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")); } @@ -406,10 +406,10 @@ print ''; print ''.$langs->trans("WarehouseAllowNegativeTransfer").''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER'); + print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, $conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, $conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER); } print "\n"; print "\n"; @@ -419,28 +419,28 @@ if ($conf->invoice->enabled) { print ''; print ''.$langs->trans("StockMustBeEnoughForInvoice").''; - print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE); - } - print "\n"; - print "\n"; + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE); + } + print "\n"; + print "\n"; } if ($conf->order->enabled) { print ''; print ''.$langs->trans("StockMustBeEnoughForOrder").''; - print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER); - } + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER); + } print "\n"; print "\n"; } @@ -449,13 +449,13 @@ if ($conf->expedition->enabled) { print ''; print ''.$langs->trans("StockMustBeEnoughForShipment").''; - print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT); - } + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT); + } print "\n"; print "\n"; } @@ -471,26 +471,26 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) || !empty($conf->mrp->enabled)) { - $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. + $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } if ($virtualdiffersfromphysical) { - print ''; - print ''; + print '
'; + print ''; print "\n"; - print ''."\n"; + print ''."\n"; print ''."\n"; print ''; print ''; - print '\n"; print "\n"; print '
".$langs->trans("RuleForStockReplenishment")." ".img_help('help', $langs->trans("VirtualDiffersFromPhysical"))."'.$langs->trans("Status").''.$langs->trans("Status").'
'.$langs->trans("UseVirtualStockByDefault").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_USE_VIRTUAL_STOCK'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_USE_VIRTUAL_STOCK", $arrval, $conf->global->STOCK_USE_VIRTUAL_STOCK); - } + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STOCK_USE_VIRTUAL_STOCK'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_USE_VIRTUAL_STOCK", $arrval, $conf->global->STOCK_USE_VIRTUAL_STOCK); + } print "
'; @@ -725,10 +725,10 @@ print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans( print ''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_SUPPORTS_SERVICES'); + print ajax_constantonoff('STOCK_SUPPORTS_SERVICES'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, $conf->global->STOCK_SUPPORTS_SERVICES); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, $conf->global->STOCK_SUPPORTS_SERVICES); } print "\n"; print "\n"; @@ -737,10 +737,10 @@ print ''; print ''.$langs->trans("AllowAddLimitStockByWarehouse").''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE'); + print ajax_constantonoff('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", $arrval, $conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", $arrval, $conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE); } print "\n"; print "\n"; @@ -749,10 +749,10 @@ print ''; print ''.$langs->trans("AlwaysShowFullArbo").''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_ALWAYS_SHOW_FULL_ARBO'); + print ajax_constantonoff('STOCK_ALWAYS_SHOW_FULL_ARBO'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_ALWAYS_SHOW_FULL_ARBO", $arrval, $conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STOCK_ALWAYS_SHOW_FULL_ARBO", $arrval, $conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO); } print "\n"; print "\n"; diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 0f28f65912a..079fcb608ab 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -61,7 +61,7 @@ $search_all = GETPOST("search_all", 'alpha'); $search = array(); foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } if (empty($action) && empty($id) && empty($ref)) $action = 'view'; @@ -92,18 +92,18 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - $error = 0; + $error = 0; - $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php'; + $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php'; - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/bom/bom_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); - } - } + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = dol_buildpath('/bom/bom_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + } + } - $triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record + $triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, delete or clone include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; @@ -149,39 +149,39 @@ if (empty($reshook)) } if ($object->fk_product == $idprod) { - setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors'); - $error++; + setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors'); + $error++; } if (!$error) { $lastposition = 0; - $bomline = new BOMLine($db); - $bomline->fk_bom = $id; - $bomline->fk_product = $idprod; - $bomline->qty = $qty; - $bomline->qty_frozen = (int) $qty_frozen; - $bomline->disable_stock_change = (int) $disable_stock_change; - $bomline->efficiency = $efficiency; + $bomline = new BOMLine($db); + $bomline->fk_bom = $id; + $bomline->fk_product = $idprod; + $bomline->qty = $qty; + $bomline->qty_frozen = (int) $qty_frozen; + $bomline->disable_stock_change = (int) $disable_stock_change; + $bomline->efficiency = $efficiency; - // Rang to use + // Rang to use $rangmax = $object->line_max(0); $ranktouse = $rangmax + 1; $bomline->position = ($ranktouse + 1); - $result = $bomline->create($user); - if ($result <= 0) - { - setEventMessages($bomline->error, $bomline->errors, 'errors'); - $action = ''; - } else { - unset($_POST['idprod']); - unset($_POST['qty']); - unset($_POST['qty_frozen']); - unset($_POST['disable_stock_change']); - } + $result = $bomline->create($user); + if ($result <= 0) + { + setEventMessages($bomline->error, $bomline->errors, 'errors'); + $action = ''; + } else { + unset($_POST['idprod']); + unset($_POST['qty']); + unset($_POST['qty_frozen']); + unset($_POST['disable_stock_change']); + } } } @@ -218,9 +218,9 @@ if (empty($reshook)) unset($_POST['idprod']); unset($_POST['qty']); unset($_POST['qty_frozen']); - unset($_POST['disable_stock_change']); + unset($_POST['disable_stock_change']); - $object->fetchLines(); + $object->fetchLines(); } } } @@ -290,7 +290,7 @@ if (($id || $ref) && $action == 'edit') print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes'); print '
'; - print ''; + print ''; print ''; print ''; print ''; @@ -321,7 +321,7 @@ if (($id || $ref) && $action == 'edit') // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals(); + $res = $object->fetch_optionals(); $head = bomPrepareHead($object); dol_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom'); @@ -331,7 +331,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1); } // Confirmation to delete line if ($action == 'deleteline') @@ -451,7 +451,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $text = $langs->trans('ConfirmSetToDraft', $object->ref); $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220); } // Call Hook formConfirm @@ -543,129 +543,129 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($object->table_element_line)) { - print ' + print ' '; - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + } - print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) - { - print ''; - } + print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) + { + print '
'; + } - if (!empty($object->lines)) - { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); - } + if (!empty($object->lines)) + { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); + } - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') - { - if ($action != 'editline') - { - // Add products/services form - $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') + { + if ($action != 'editline') + { + // Add products/services form + $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - } - } + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } + } - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) - { - print '
'; - } - print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) + { + print ''; + } + print ''; - print "
\n"; + print "\n"; } // Buttons for actions if ($action != 'presend' && $action != 'editline') { - print '
'."\n"; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print '
'."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) - { - // Send - //if (empty($user->socid)) { - // print '' . $langs->trans('SendMail') . ''."\n"; - //} + if (empty($reshook)) + { + // Send + //if (empty($user->socid)) { + // print '' . $langs->trans('SendMail') . ''."\n"; + //} - // Back to draft - if ($object->status == $object::STATUS_VALIDATED) - { - if ($permissiontoadd) - { - print ''.$langs->trans("SetToDraft").''; - } - } + // Back to draft + if ($object->status == $object::STATUS_VALIDATED) + { + if ($permissiontoadd) + { + print ''.$langs->trans("SetToDraft").''; + } + } - // Modify - if ($object->status == $object::STATUS_DRAFT) - { - if ($permissiontoadd) - { - print ''.$langs->trans("Modify").''."\n"; - } else { - print ''.$langs->trans('Modify').''."\n"; - } - } + // Modify + if ($object->status == $object::STATUS_DRAFT) + { + if ($permissiontoadd) + { + print ''.$langs->trans("Modify").''."\n"; + } else { + print ''.$langs->trans('Modify').''."\n"; + } + } - // Validate - if ($object->status == $object::STATUS_DRAFT) - { - if ($permissiontoadd) - { - if (is_array($object->lines) && count($object->lines) > 0) - { - print ''.$langs->trans("Validate").''; - } else { - $langs->load("errors"); - print ''.$langs->trans("Validate").''; - } - } - } + // Validate + if ($object->status == $object::STATUS_DRAFT) + { + if ($permissiontoadd) + { + if (is_array($object->lines) && count($object->lines) > 0) + { + print ''.$langs->trans("Validate").''; + } else { + $langs->load("errors"); + print ''.$langs->trans("Validate").''; + } + } + } - // Close / Cancel - if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED) - { - print ''.$langs->trans("Disable").''; - } + // Close / Cancel + if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED) + { + print ''.$langs->trans("Disable").''; + } - // Re-open - if ($permissiontoadd && $object->status == $object::STATUS_CANCELED) - { - print ''.$langs->trans("ReOpen").''; - } + // Re-open + if ($permissiontoadd && $object->status == $object::STATUS_CANCELED) + { + print ''.$langs->trans("ReOpen").''; + } - // Create MO - if ($conf->mrp->enabled) - { - if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write)) - { - print ''.$langs->trans("CreateMO").''; - } - } + // Create MO + if ($conf->mrp->enabled) + { + if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write)) + { + print ''.$langs->trans("CreateMO").''; + } + } - // Clone - if ($permissiontoadd) - { - print ''.$langs->trans("ToClone").''; - } + // Clone + if ($permissiontoadd) + { + print ''.$langs->trans("ToClone").''; + } - /* + /* if ($user->rights->bom->write) { if ($object->status == 1) @@ -679,14 +679,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } */ - if ($permissiontodelete) - { - print ''.$langs->trans('Delete').''."\n"; - } else { - print ''.$langs->trans('Delete').''."\n"; - } - } - print '
'."\n"; + if ($permissiontodelete) + { + print ''.$langs->trans('Delete').''."\n"; + } else { + print ''.$langs->trans('Delete').''."\n"; + } + } + print '
'."\n"; } @@ -697,41 +697,41 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action != 'presend') { - print '
'; - print ''; // ancre + print '
'; + print ''; // ancre - // Documents - $objref = dol_sanitizeFileName($object->ref); - $relativepath = $objref.'/'.$objref.'.pdf'; - $filedir = $conf->bom->dir_output.'/'.$objref; - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + // Documents + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->bom->dir_output.'/'.$objref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); - // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('bom')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('bom')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
'; + print '
'; - $MAXEVENT = 10; + $MAXEVENT = 10; - $morehtmlright = ''; - $morehtmlright .= $langs->trans("SeeAll"); - $morehtmlright .= ''; + $morehtmlright = ''; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= ''; - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'bom', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'bom', $socid, 1, '', $MAXEVENT, '', $morehtmlright); - print '
'; + print '
'; } //Select mail models is same action as presend - if (GETPOST('modelselected')) $action = 'presend'; + if (GETPOST('modelselected')) $action = 'presend'; // Presend form $modelmail = 'bom'; diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 74eb88393df..2a675cc60e1 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -31,8 +31,8 @@ // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { - print "Error: this template page cannot be called directly as an URL"; - exit; + print "Error: this template page cannot be called directly as an URL"; + exit; } @@ -52,34 +52,34 @@ print "\n"; $nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines); if ($nolinesbefore) { - print ''; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; - } - print ''; + print ''; + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; + } + print ''; print '
'.$langs->trans('AddNewLine').''; print ''; print ''.$langs->trans('Qty').''; if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - print ''; - print $langs->trans('Unit'); - print ''; + print ''; + print ''; + print $langs->trans('Unit'); + print ''; } print ''.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).''; print ''.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).''; print ''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).''; print ' '; - print ''; + print ''; } print ''; $coldisplay = 0; // Adds a line numbering column if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - $coldisplay++; - echo ''; + $coldisplay++; + echo ''; } $coldisplay++; @@ -111,7 +111,7 @@ print ''; if ($conf->global->PRODUCT_USE_UNITS) { - $coldisplay++; + $coldisplay++; print ''; print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units"); print ''; diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 79cc42c2874..4a84a25e5ca 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -35,727 +35,727 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/api_projects.class.php'; */ class Categories extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'label', - 'type' - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'label', + 'type' + ); - static $TYPES = array( - 0 => 'product', - 1 => 'supplier', - 2 => 'customer', - 3 => 'member', - 4 => 'contact', - 5 => 'account', - 6 => 'project', - //7 => 'user', - //8 => 'bank_line', - //9 => 'warehouse', - //10 => 'actioncomm', - ); + static $TYPES = array( + 0 => 'product', + 1 => 'supplier', + 2 => 'customer', + 3 => 'member', + 4 => 'contact', + 5 => 'account', + 6 => 'project', + //7 => 'user', + //8 => 'bank_line', + //9 => 'warehouse', + //10 => 'actioncomm', + ); - /** - * @var Categorie $category {@type Categorie} - */ - public $category; + /** + * @var Categorie $category {@type Categorie} + */ + public $category; - /** - * Constructor - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - $this->category = new Categorie($this->db); - } + /** + * Constructor + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + $this->category = new Categorie($this->db); + } - /** - * Get properties of a category object - * - * Return an array with category informations - * - * @param int $id ID of category - * @param bool $include_childs Include child categories list (true or false) - * @return array|mixed data without useless information - * - * @throws RestException - */ - public function get($id, $include_childs = false) - { - if (!DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + /** + * Get properties of a category object + * + * Return an array with category informations + * + * @param int $id ID of category + * @param bool $include_childs Include child categories list (true or false) + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id, $include_childs = false) + { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if ($include_childs) { - $cats = $this->category->get_filles(); - if (!is_array($cats)) { - throw new RestException(500, 'Error when fetching child categories', array_merge(array($this->category->error), $this->category->errors)); - } - $this->category->childs = []; - foreach ($cats as $cat) { - $this->category->childs[] = $this->_cleanObjectDatas($cat); - } - } + if ($include_childs) { + $cats = $this->category->get_filles(); + if (!is_array($cats)) { + throw new RestException(500, 'Error when fetching child categories', array_merge(array($this->category->error), $this->category->errors)); + } + $this->category->childs = []; + foreach ($cats as $cat) { + $this->category->childs[] = $this->_cleanObjectDatas($cat); + } + } - return $this->_cleanObjectDatas($this->category); - } + return $this->_cleanObjectDatas($this->category); + } - /** - * List categories - * - * Get a list of categories - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" - * @return array Array of category objects - * - * @throws RestException - */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '') - { - global $db, $conf; + /** + * List categories + * + * Get a list of categories + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of category objects + * + * @throws RestException + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } - $sql = "SELECT t.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."categorie as t"; - $sql .= ' WHERE t.entity IN ('.getEntity('category').')'; - if (!empty($type)) - { - $sql .= ' AND t.type='.array_search($type, Categories::$TYPES); - } - // Add sql filters - if ($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).")"; - } + $sql = "SELECT t.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie as t"; + $sql .= ' WHERE t.entity IN ('.getEntity('category').')'; + if (!empty($type)) + { + $sql .= ' AND t.type='.array_search($type, Categories::$TYPES); + } + // Add sql filters + if ($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).")"; + } - $sql .= $db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) - { - $page = 0; - } - $offset = $limit * $page; + $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; - $num = $db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { - $obj = $db->fetch_object($result); - $category_static = new Categorie($db); - if ($category_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($category_static); - } - $i++; - } - } - else { - throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror()); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No category found'); - } - return $obj_ret; - } + $result = $db->query($sql); + if ($result) + { + $i = 0; + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) + { + $obj = $db->fetch_object($result); + $category_static = new Categorie($db); + if ($category_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($category_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No category found'); + } + return $obj_ret; + } - /** - * Create category object - * - * @param array $request_data Request data - * @return int ID of category - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->categorie->creer) { - throw new RestException(401); - } + /** + * Create category object + * + * @param array $request_data Request data + * @return int ID of category + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->categorie->creer) { + throw new RestException(401); + } - // Check mandatory fields - $result = $this->_validate($request_data); + // Check mandatory fields + $result = $this->_validate($request_data); - foreach ($request_data as $field => $value) { - $this->category->$field = $value; - } - if ($this->category->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, 'Error when creating category', array_merge(array($this->category->error), $this->category->errors)); - } - return $this->category->id; - } + foreach ($request_data as $field => $value) { + $this->category->$field = $value; + } + if ($this->category->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, 'Error when creating category', array_merge(array($this->category->error), $this->category->errors)); + } + return $this->category->id; + } - /** - * Update category - * - * @param int $id Id of category to update - * @param array $request_data Datas - * @return int - */ - public function put($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->categorie->creer) { - throw new RestException(401); - } + /** + * Update category + * + * @param int $id Id of category to update + * @param array $request_data Datas + * @return int + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->categorie->creer) { + throw new RestException(401); + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - foreach ($request_data as $field => $value) { - if ($field == 'id') continue; - $this->category->$field = $value; - } + foreach ($request_data as $field => $value) { + if ($field == 'id') continue; + $this->category->$field = $value; + } - if ($this->category->update(DolibarrApiAccess::$user) > 0) { - return $this->get($id); + if ($this->category->update(DolibarrApiAccess::$user) > 0) { + return $this->get($id); } else { - throw new RestException(500, $this->category->error); - } - } + throw new RestException(500, $this->category->error); + } + } - /** - * Delete category - * - * @param int $id Category ID - * @return array - */ - public function delete($id) - { - if (!DolibarrApiAccess::$user->rights->categorie->supprimer) { - throw new RestException(401); - } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + /** + * Delete category + * + * @param int $id Category ID + * @return array + */ + public function delete($id) + { + if (!DolibarrApiAccess::$user->rights->categorie->supprimer) { + throw new RestException(401); + } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (!$this->category->delete(DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when delete category'); - } + if (!$this->category->delete(DolibarrApiAccess::$user)) { + throw new RestException(401, 'error when delete category'); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Category deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Category deleted' + ) + ); + } - /** - * List categories of an object - * - * Get the list of categories linked to an object - * - * @param int $id Object ID - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'project') - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @return array Array of category objects - * - * @throws RestException - * - * @url GET /object/{type}/{id} - */ - public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) - { - if (!in_array($type, [ - Categorie::TYPE_PRODUCT, - Categorie::TYPE_CONTACT, - Categorie::TYPE_CUSTOMER, - Categorie::TYPE_SUPPLIER, - Categorie::TYPE_MEMBER, - Categorie::TYPE_PROJECT - ])) { - throw new RestException(401); - } + /** + * List categories of an object + * + * Get the list of categories linked to an object + * + * @param int $id Object ID + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'project') + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @return array Array of category objects + * + * @throws RestException + * + * @url GET /object/{type}/{id} + */ + public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + { + if (!in_array($type, [ + Categorie::TYPE_PRODUCT, + Categorie::TYPE_CONTACT, + Categorie::TYPE_CUSTOMER, + Categorie::TYPE_SUPPLIER, + Categorie::TYPE_MEMBER, + Categorie::TYPE_PROJECT + ])) { + throw new RestException(401); + } - if ($type == Categorie::TYPE_PRODUCT && !(DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { - throw new RestException(401); - } elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->rights->contact->lire) { - throw new RestException(401); - } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->rights->societe->lire) { - throw new RestException(401); - } elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->rights->fournisseur->lire) { - throw new RestException(401); - } elseif ($type == Categorie::TYPE_MEMBER && !DolibarrApiAccess::$user->rights->adherent->lire) { - throw new RestException(401); - } elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->rights->projet->lire) { - throw new RestException(401); - } + if ($type == Categorie::TYPE_PRODUCT && !(DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->rights->contact->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->rights->fournisseur->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_MEMBER && !DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->rights->projet->lire) { + throw new RestException(401); + } - $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); + $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); - if (!is_array($categories)) { - if ($categories == 0) { - throw new RestException(404, 'No category found for this object'); - } - throw new RestException(600, 'Error when fetching object categories', array_merge(array($this->category->error), $this->category->errors)); - } - return $categories; - } + if (!is_array($categories)) { + if ($categories == 0) { + throw new RestException(404, 'No category found for this object'); + } + throw new RestException(600, 'Error when fetching object categories', array_merge(array($this->category->error), $this->category->errors)); + } + return $categories; + } - /** - * Link an object to a category by id - * - * @param int $id ID of category - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') - * @param int $object_id ID of object - * - * @return array - * @throws RestException - * - * @url POST {id}/objects/{type}/{object_id} - */ - public function linkObjectById($id, $type, $object_id) - { - if (empty($type) || empty($object_id)) { - throw new RestException(401); - } + /** + * Link an object to a category by id + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param int $object_id ID of object + * + * @return array + * @throws RestException + * + * @url POST {id}/objects/{type}/{object_id} + */ + public function linkObjectById($id, $type, $object_id) + { + if (empty($type) || empty($object_id)) { + throw new RestException(401); + } - if (!DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if ($type === Categorie::TYPE_PRODUCT) { - if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { - throw new RestException(401); - } - $object = new Product($this->db); - } elseif ($type === Categorie::TYPE_CUSTOMER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_SUPPLIER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_CONTACT) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); - } - $object = new Contact($this->db); - } elseif ($type === Categorie::TYPE_MEMBER) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { - throw new RestException(401); - } - $object = new Adherent($this->db); - } else { - throw new RestException(401, "this type is not recognized yet."); - } + if ($type === Categorie::TYPE_PRODUCT) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } - if (!empty($object)) { - $result = $object->fetch($object_id); - if ($result > 0) { - $result = $this->category->add_type($object, $type); - if ($result < 0) { - if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { - throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); - } - } - } else { - throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); - } + if (!empty($object)) { + $result = $object->fetch($object_id); + if ($result > 0) { + $result = $this->category->add_type($object, $type); + if ($result < 0) { + if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { + throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); + } + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Objects succefully linked to the category' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully linked to the category' + ) + ); + } - throw new RestException(401); - } + throw new RestException(401); + } - /** - * Link an object to a category by ref - * - * @param int $id ID of category - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') - * @param string $object_ref Reference of object - * - * @return array - * @throws RestException - * - * @url POST {id}/objects/{type}/ref/{object_ref} - */ - public function linkObjectByRef($id, $type, $object_ref) - { - if (empty($type) || empty($object_ref)) { - throw new RestException(401); - } + /** + * Link an object to a category by ref + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $object_ref Reference of object + * + * @return array + * @throws RestException + * + * @url POST {id}/objects/{type}/ref/{object_ref} + */ + public function linkObjectByRef($id, $type, $object_ref) + { + if (empty($type) || empty($object_ref)) { + throw new RestException(401); + } - if (!DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if ($type === Categorie::TYPE_PRODUCT) { - if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { - throw new RestException(401); - } - $object = new Product($this->db); - } elseif ($type === Categorie::TYPE_CUSTOMER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_SUPPLIER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_CONTACT) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); - } - $object = new Contact($this->db); - } elseif ($type === Categorie::TYPE_MEMBER) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { - throw new RestException(401); - } - $object = new Adherent($this->db); - } else { - throw new RestException(401, "this type is not recognized yet."); - } + if ($type === Categorie::TYPE_PRODUCT) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } - if (!empty($object)) { - $result = $object->fetch('', $object_ref); - if ($result > 0) { - $result = $this->category->add_type($object, $type); - if ($result < 0) { - if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { - throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); - } - } - } else { - throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); - } + if (!empty($object)) { + $result = $object->fetch('', $object_ref); + if ($result > 0) { + $result = $this->category->add_type($object, $type); + if ($result < 0) { + if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { + throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); + } + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Objects succefully linked to the category' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully linked to the category' + ) + ); + } - throw new RestException(401); - } + throw new RestException(401); + } - /** - * Unlink an object from a category by id - * - * @param int $id ID of category - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') - * @param int $object_id ID of the object - * - * @return array - * @throws RestException - * - * @url DELETE {id}/objects/{type}/{object_id} - */ - public function unlinkObjectById($id, $type, $object_id) - { - if (empty($type) || empty($object_id)) { - throw new RestException(401); - } + /** + * Unlink an object from a category by id + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param int $object_id ID of the object + * + * @return array + * @throws RestException + * + * @url DELETE {id}/objects/{type}/{object_id} + */ + public function unlinkObjectById($id, $type, $object_id) + { + if (empty($type) || empty($object_id)) { + throw new RestException(401); + } - if (!DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if ($type === Categorie::TYPE_PRODUCT) { - if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { - throw new RestException(401); - } - $object = new Product($this->db); - } elseif ($type === Categorie::TYPE_CUSTOMER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_SUPPLIER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_CONTACT) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); - } - $object = new Contact($this->db); - } elseif ($type === Categorie::TYPE_MEMBER) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { - throw new RestException(401); - } - $object = new Adherent($this->db); - } else { - throw new RestException(401, "this type is not recognized yet."); - } + if ($type === Categorie::TYPE_PRODUCT) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } - if (!empty($object)) { - $result = $object->fetch((int) $object_id); - if ($result > 0) { - $result = $this->category->del_type($object, $type); - if ($result < 0) { - throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); - } - } else { - throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); - } + if (!empty($object)) { + $result = $object->fetch((int) $object_id); + if ($result > 0) { + $result = $this->category->del_type($object, $type); + if ($result < 0) { + throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Objects succefully unlinked from the category' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully unlinked from the category' + ) + ); + } - throw new RestException(401); - } + throw new RestException(401); + } - /** - * Unlink an object from a category by ref - * - * @param int $id ID of category - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') - * @param string $object_ref Reference of the object - * - * @return array - * @throws RestException - * - * @url DELETE {id}/objects/{type}/ref/{object_ref} - */ - public function unlinkObjectByRef($id, $type, $object_ref) - { - if (empty($type) || empty($object_ref)) { - throw new RestException(401); - } + /** + * Unlink an object from a category by ref + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $object_ref Reference of the object + * + * @return array + * @throws RestException + * + * @url DELETE {id}/objects/{type}/ref/{object_ref} + */ + public function unlinkObjectByRef($id, $type, $object_ref) + { + if (empty($type) || empty($object_ref)) { + throw new RestException(401); + } - if (!DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } - if ($type === Categorie::TYPE_PRODUCT) { - if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { - throw new RestException(401); - } - $object = new Product($this->db); - } elseif ($type === Categorie::TYPE_CUSTOMER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_SUPPLIER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - $object = new Societe($this->db); - } elseif ($type === Categorie::TYPE_CONTACT) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); - } - $object = new Contact($this->db); - } elseif ($type === Categorie::TYPE_MEMBER) { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { - throw new RestException(401); - } - $object = new Adherent($this->db); - } else { - throw new RestException(401, "this type is not recognized yet."); - } + if ($type === Categorie::TYPE_PRODUCT) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } - if (!empty($object)) { - $result = $object->fetch('', (string) $object_ref); - if ($result > 0) { - $result = $this->category->del_type($object, $type); - if ($result < 0) { - throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); - } - } else { - throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); - } + if (!empty($object)) { + $result = $object->fetch('', (string) $object_ref); + if ($result > 0) { + $result = $this->category->del_type($object, $type); + if ($result < 0) { + throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Objects succefully unlinked from the category' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully unlinked from the category' + ) + ); + } - throw new RestException(401); - } + throw new RestException(401); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param Categorie $object Object to clean - * @return array Array of cleaned object properties - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - $object = parent::_cleanObjectDatas($object); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Categorie $object Object to clean + * @return array Array of cleaned object properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); - // Remove fields not relevent to categories - unset($object->country); - unset($object->country_id); - unset($object->country_code); - unset($object->total_ht); - unset($object->total_ht); - unset($object->total_localtax1); - unset($object->total_localtax2); - unset($object->total_ttc); - unset($object->total_tva); - unset($object->lines); - unset($object->fk_incoterms); - unset($object->label_incoterms); - unset($object->location_incoterms); - unset($object->civility_id); - unset($object->name); - unset($object->lastname); - unset($object->firstname); - unset($object->shipping_method_id); - unset($object->fk_delivery_address); - unset($object->cond_reglement); - unset($object->cond_reglement_id); - unset($object->mode_reglement_id); - unset($object->barcode_type_coder); - unset($object->barcode_type_label); - unset($object->barcode_type_code); - unset($object->barcode_type); - unset($object->canvas); - unset($object->cats); - unset($object->motherof); - unset($object->context); - unset($object->socid); - unset($object->thirdparty); - unset($object->contact); - unset($object->contact_id); - unset($object->user); - unset($object->fk_account); - unset($object->fk_project); - unset($object->note); - unset($object->statut); + // Remove fields not relevent to categories + unset($object->country); + unset($object->country_id); + unset($object->country_code); + unset($object->total_ht); + unset($object->total_ht); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->total_tva); + unset($object->lines); + unset($object->fk_incoterms); + unset($object->label_incoterms); + unset($object->location_incoterms); + unset($object->civility_id); + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->shipping_method_id); + unset($object->fk_delivery_address); + unset($object->cond_reglement); + unset($object->cond_reglement_id); + unset($object->mode_reglement_id); + unset($object->barcode_type_coder); + unset($object->barcode_type_label); + unset($object->barcode_type_code); + unset($object->barcode_type); + unset($object->canvas); + unset($object->cats); + unset($object->motherof); + unset($object->context); + unset($object->socid); + unset($object->thirdparty); + unset($object->contact); + unset($object->contact_id); + unset($object->user); + unset($object->fk_account); + unset($object->fk_project); + unset($object->note); + unset($object->statut); - return $object; - } + return $object; + } - /** - * Validate fields before create or update object - * - * @param array|null $data Data to validate - * @return array - * - * @throws RestException - */ - private function _validate($data) - { - $category = array(); - foreach (Categories::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $category[$field] = $data[$field]; - } - return $category; - } + /** + * Validate fields before create or update object + * + * @param array|null $data Data to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $category = array(); + foreach (Categories::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $category[$field] = $data[$field]; + } + return $category; + } - /** - * Get the list of objects in a category. - * - * @param int $id ID of category - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'project') - * @param int $onlyids Return only ids of objects (consume less memory) - * - * @return mixed - * - * @url GET {id}/objects - */ - public function getObjects($id, $type, $onlyids = 0) - { + /** + * Get the list of objects in a category. + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'project') + * @param int $onlyids Return only ids of objects (consume less memory) + * + * @return mixed + * + * @url GET {id}/objects + */ + public function getObjects($id, $type, $onlyids = 0) + { dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG); if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } - if (empty($type)) - { + if (empty($type)) + { throw new RestException(500, 'The "type" parameter is required.'); - } + } - $result = $this->category->fetch($id); - if (!$result) { - throw new RestException(404, 'category not found'); - } + $result = $this->category->fetch($id); + if (!$result) { + throw new RestException(404, 'category not found'); + } if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); @@ -768,8 +768,8 @@ class Categories extends DolibarrApi } $objects = $result; - $cleaned_objects = array(); - if ($type == 'member') { + $cleaned_objects = array(); + if ($type == 'member') { $objects_api = new Members(); } elseif ($type == 'customer' || $type == 'supplier') { $objects_api = new Thirdparties(); @@ -781,11 +781,11 @@ class Categories extends DolibarrApi $objects_api = new Projects(); } if (is_object($objects_api)) { - foreach ($objects as $obj) { - $cleaned_objects[] = $objects_api->_cleanObjectDatas($obj); - } + foreach ($objects as $obj) { + $cleaned_objects[] = $objects_api->_cleanObjectDatas($obj); + } } return $cleaned_objects; - } + } } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 6c27b9e82ff..f9cf55e9a8c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -52,10 +52,10 @@ class Categorie extends CommonObject const TYPE_USER = 'user'; const TYPE_PROJECT = 'project'; const TYPE_ACCOUNT = 'bank_account'; - const TYPE_BANK_LINE = 'bank_line'; - const TYPE_WAREHOUSE = 'warehouse'; - const TYPE_ACTIONCOMM = 'actioncomm'; - const TYPE_WEBSITE_PAGE = 'website_page'; + const TYPE_BANK_LINE = 'bank_line'; + const TYPE_WAREHOUSE = 'warehouse'; + const TYPE_ACTIONCOMM = 'actioncomm'; + const TYPE_WEBSITE_PAGE = 'website_page'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -73,15 +73,15 @@ class Categorie extends CommonObject 'member' => 3, 'contact' => 4, 'bank_account' => 5, - 'project' => 6, + 'project' => 6, 'user' => 7, 'bank_line' => 8, 'warehouse' => 9, - 'actioncomm' => 10, + 'actioncomm' => 10, 'website_page' => 11 ); - /** + /** * @var array Code mapping from ID * * @note This array should be removed in future, once previous constants are moved to the string value. Deprecated @@ -97,7 +97,7 @@ class Categorie extends CommonObject 7 => 'user', 8 => 'bank_line', 9 => 'warehouse', - 10 => 'actioncomm', + 10 => 'actioncomm', ); /** @@ -109,10 +109,10 @@ class Categorie extends CommonObject 'customer' => 'soc', 'supplier' => 'soc', 'contact' => 'socpeople', - 'bank_account' => 'account', - ); + 'bank_account' => 'account', + ); - /** + /** * @var array Category tables mapping from type string (llx_categorie_...) when value does not match * * @note Move to const array when PHP 5.6 will be our minimum target @@ -120,10 +120,10 @@ class Categorie extends CommonObject protected $MAP_CAT_TABLE = array( 'customer' => 'societe', 'supplier' => 'fournisseur', - 'bank_account'=> 'account', + 'bank_account'=> 'account', ); - /** + /** * @var array Object class mapping from type string * * @note Move to const array when PHP 5.6 will be our minimum target @@ -137,33 +137,33 @@ class Categorie extends CommonObject 'user' => 'User', 'account' => 'Account', // old for bank account 'bank_account' => 'Account', - 'project' => 'Project', - 'warehouse'=> 'Entrepot', - 'actioncomm' => 'ActionComm', + 'project' => 'Project', + 'warehouse'=> 'Entrepot', + 'actioncomm' => 'ActionComm', 'website_page' => 'WebsitePage' ); - /** - * @var array Title Area mapping from type string - * - * @note Move to const array when PHP 5.6 will be our minimum target - */ - public static $MAP_TYPE_TITLE_AREA = array( - 'product' => 'ProductsCategoriesArea', - 'customer' => 'CustomersCategoriesArea', - 'supplier' => 'SuppliersCategoriesArea', - 'member' => 'MembersCategoriesArea', - 'contact' => 'ContactsCategoriesArea', - 'user' => 'UsersCategoriesArea', - 'account' => 'AccountsCategoriesArea', // old for bank account - 'bank_account' => 'AccountsCategoriesArea', - 'project' => 'ProjectsCategoriesArea', - 'warehouse'=> 'StocksCategoriesArea', - 'actioncomm' => 'ActioncommCategoriesArea', - 'website_page' => 'WebsitePageCategoriesArea' - ); + /** + * @var array Title Area mapping from type string + * + * @note Move to const array when PHP 5.6 will be our minimum target + */ + public static $MAP_TYPE_TITLE_AREA = array( + 'product' => 'ProductsCategoriesArea', + 'customer' => 'CustomersCategoriesArea', + 'supplier' => 'SuppliersCategoriesArea', + 'member' => 'MembersCategoriesArea', + 'contact' => 'ContactsCategoriesArea', + 'user' => 'UsersCategoriesArea', + 'account' => 'AccountsCategoriesArea', // old for bank account + 'bank_account' => 'AccountsCategoriesArea', + 'project' => 'ProjectsCategoriesArea', + 'warehouse'=> 'StocksCategoriesArea', + 'actioncomm' => 'ActioncommCategoriesArea', + 'website_page' => 'WebsitePageCategoriesArea' + ); - /** + /** * @var array Object table mapping from type string (table llx_...) when value of key does not match table name. * * @note Move to const array when PHP 5.6 will be our minimum target @@ -175,7 +175,7 @@ class Categorie extends CommonObject 'contact' => 'socpeople', 'account' => 'bank_account', // old for bank account 'project' => 'projet', - 'warehouse'=> 'entrepot' + 'warehouse'=> 'entrepot' ); /** @@ -189,13 +189,13 @@ class Categorie extends CommonObject public $table_element = 'categorie'; /** - * @var int ID - */ + * @var int ID + */ public $fk_parent; /** - * @var string Category label - */ + * @var string Category label + */ public $label; /** @@ -225,8 +225,8 @@ class Categorie extends CommonObject * @see Categorie::TYPE_USER * @see Categorie::TYPE_PROJECT * @see Categorie::TYPE_BANK_LINE - * @see Categorie::TYPE_WAREHOUSE - * @see Categorie::TYPE_ACTIONCOMM + * @see Categorie::TYPE_WAREHOUSE + * @see Categorie::TYPE_ACTIONCOMM */ public $type; @@ -235,7 +235,7 @@ class Categorie extends CommonObject */ public $cats = array(); - /** + /** * @var array Mother of table */ public $motherof = array(); @@ -464,20 +464,20 @@ class Categorie extends CommonObject if (!$error) { - // Call trigger - $result = $this->call_trigger('CATEGORY_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CATEGORY_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers } - if (!$error) - { - $this->db->commit(); - return $id; - } else { - $this->db->rollback(); - return -3; - } + if (!$error) + { + $this->db->commit(); + return $id; + } else { + $this->db->rollback(); + return -3; + } } else { $this->db->rollback(); return -2; @@ -550,10 +550,10 @@ class Categorie extends CommonObject if (!$error) { - // Call trigger - $result = $this->call_trigger('CATEGORY_MODIFY', $user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CATEGORY_MODIFY', $user); + if ($result < 0) { $error++; $this->db->rollback(); return -1; } + // End call triggers } $this->db->commit(); @@ -570,7 +570,7 @@ class Categorie extends CommonObject * Delete a category from database * * @param User $user Object user that ask to delete - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 KO >0 OK */ public function delete($user, $notrigger = 0) @@ -579,7 +579,7 @@ class Categorie extends CommonObject $error = 0; - // Clean parameters + // Clean parameters $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); dol_syslog(get_class($this)."::remove"); @@ -588,10 +588,10 @@ class Categorie extends CommonObject if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('CATEGORY_DELETE', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('CATEGORY_DELETE', $user); + if ($result < 0) $error++; + // End call triggers } /* FIX #1317 : Check for child category and move up 1 level*/ @@ -608,26 +608,26 @@ class Categorie extends CommonObject } } - $arraydelete = array( - 'categorie_societe' => 'fk_categorie', - 'categorie_fournisseur' => 'fk_categorie', - 'categorie_product' => 'fk_categorie', - 'categorie_member' => 'fk_categorie', - 'categorie_contact' => 'fk_categorie', - 'categorie_account' => 'fk_categorie', - 'bank_class' => 'fk_categ', - 'categorie_lang' => 'fk_category', - 'categorie' => 'rowid', - ); - foreach ($arraydelete as $key => $value) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$key; - $sql .= " WHERE ".$value." = ".$this->id; - if (!$this->db->query($sql)) { - $this->errors[] = $this->db->lasterror(); - dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR); - $error++; - } - } + $arraydelete = array( + 'categorie_societe' => 'fk_categorie', + 'categorie_fournisseur' => 'fk_categorie', + 'categorie_product' => 'fk_categorie', + 'categorie_member' => 'fk_categorie', + 'categorie_contact' => 'fk_categorie', + 'categorie_account' => 'fk_categorie', + 'bank_class' => 'fk_categ', + 'categorie_lang' => 'fk_category', + 'categorie' => 'rowid', + ); + foreach ($arraydelete as $key => $value) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$key; + $sql .= " WHERE ".$value." = ".$this->id; + if (!$this->db->query($sql)) { + $this->errors[] = $this->db->lasterror(); + dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR); + $error++; + } + } // Removed extrafields if (!$error) @@ -650,7 +650,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link an object to the category * @@ -660,7 +660,7 @@ class Categorie extends CommonObject */ public function add_type($obj, $type = '') { - // phpcs:enable + // phpcs:enable global $user, $langs, $conf; $error = 0; @@ -669,9 +669,9 @@ class Categorie extends CommonObject if (empty($type)) $type = $obj->element; - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); $sql .= " (fk_categorie, fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).")"; $sql .= " VALUES (".$this->id.", ".$obj->id.")"; @@ -689,7 +689,7 @@ class Categorie extends CommonObject { if ($this->db->num_rows($resql) > 0) { - $objparent = $this->db->fetch_object($resql); + $objparent = $this->db->fetch_object($resql); if (!empty($objparent->fk_parent)) { @@ -712,29 +712,29 @@ class Categorie extends CommonObject if ($error) { - $this->db->rollback(); + $this->db->rollback(); return -1; } } - // Call trigger + // Call trigger $this->context = array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger $result = $this->call_trigger('CATEGORY_LINK', $user); - if ($result < 0) { $error++; } - // End call triggers + if ($result < 0) { $error++; } + // End call triggers if (!$error) { - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else { - $this->db->rollback(); - return -2; + $this->db->rollback(); + return -2; } } else { - $this->db->rollback(); + $this->db->rollback(); if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $this->error = $this->db->lasterrno(); @@ -746,7 +746,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete object from category * @@ -757,7 +757,7 @@ class Categorie extends CommonObject */ public function del_type($obj, $type) { - // phpcs:enable + // phpcs:enable global $user, $langs, $conf; $error = 0; @@ -771,31 +771,31 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING); } - $this->db->begin(); + $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); $sql .= " WHERE fk_categorie = ".$this->id; $sql .= " AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".$obj->id; dol_syslog(get_class($this).'::del_type', LOG_DEBUG); if ($this->db->query($sql)) { - // Call trigger + // Call trigger $this->context = array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger $result = $this->call_trigger('CATEGORY_UNLINK', $user); - if ($result < 0) { $error++; } - // End call triggers + if ($result < 0) { $error++; } + // End call triggers if (!$error) { - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else { - $this->db->rollback(); - return -2; + $this->db->rollback(); + return -2; } } else { - $this->db->rollback(); + $this->db->rollback(); $this->error = $this->db->lasterror(); return -1; } @@ -842,16 +842,16 @@ class Categorie extends CommonObject { while ($rec = $this->db->fetch_array($resql)) { - if ($onlyids) { - $objs[] = $rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]; - } else { - $classnameforobj = $this->MAP_OBJ_CLASS[$type]; + if ($onlyids) { + $objs[] = $rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]; + } else { + $classnameforobj = $this->MAP_OBJ_CLASS[$type]; - $obj = new $classnameforobj($this->db); - $obj->fetch($rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]); + $obj = new $classnameforobj($this->db); + $obj->fetch($rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]); - $objs[] = $obj; - } + $objs[] = $obj; + } } return $objs; } else { @@ -990,7 +990,7 @@ class Categorie extends CommonObject return $categories; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return direct childs id of a category into an array * @@ -998,7 +998,7 @@ class Categorie extends CommonObject */ public function get_filles() { - // phpcs:enable + // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; $sql .= " WHERE fk_parent = ".$this->id; $sql .= " AND entity IN (".getEntity('category').")"; @@ -1020,7 +1020,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the array this->motherof that is array(id_son=>id_parent, ...) * @@ -1028,8 +1028,8 @@ class Categorie extends CommonObject */ protected function load_motherof() { - // phpcs:enable - $this->motherof = array(); + // phpcs:enable + $this->motherof = array(); // Load array[child]=parent $sql = "SELECT fk_parent as id_parent, rowid as id_son"; @@ -1052,7 +1052,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Rebuilding the category tree as an array * Return an array of table('id','id_mere',...) trie selon arbre et avec: @@ -1065,17 +1065,17 @@ class Categorie extends CommonObject * * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member', ...) * @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id. - * $markafterid can be an : - * - int (id of category) - * - string (categories ids separated by comma) - * - array (list of categories ids) - * @param int $include [=0] Removed or 1=Keep only + * $markafterid can be an : + * - int (id of category) + * - string (categories ids separated by comma) + * - array (list of categories ids) + * @param int $include [=0] Removed or 1=Keep only * @return array|int Array of categories. this->cats and this->motherof are set, -1 on error */ public function get_full_arbo($type, $markafterid = 0, $include = 0) { - // phpcs:enable - global $conf, $langs; + // phpcs:enable + global $conf, $langs; if (!is_numeric($type)) $type = $this->MAP_ID[$type]; if (is_null($type)) { @@ -1083,23 +1083,23 @@ class Categorie extends CommonObject return -1; } - if (is_string($markafterid)) - { - $markafterid = explode(',', $markafterid); - } elseif (is_numeric($markafterid)) - { - if ($markafterid > 0) - { - $markafterid = array($markafterid); - } else { - $markafterid = array(); - } - } elseif (!is_array($markafterid)) - { - $markafterid = array(); - } + if (is_string($markafterid)) + { + $markafterid = explode(',', $markafterid); + } elseif (is_numeric($markafterid)) + { + if ($markafterid > 0) + { + $markafterid = array($markafterid); + } else { + $markafterid = array(); + } + } elseif (!is_array($markafterid)) + { + $markafterid = array(); + } - $this->cats = array(); + $this->cats = array(); // Init this->motherof that is array(id_son=>id_parent, ...) $this->load_motherof(); @@ -1143,27 +1143,27 @@ class Categorie extends CommonObject $this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent) } - // Include or exclude leaf including $markafterid from tree - if (count($markafterid) > 0) - { - $keyfiltercatid = '('.implode('|', $markafterid).')'; + // Include or exclude leaf including $markafterid from tree + if (count($markafterid) > 0) + { + $keyfiltercatid = '('.implode('|', $markafterid).')'; - //print "Look to discard category ".$markafterid."\n"; - $keyfilter1 = '^'.$keyfiltercatid.'$'; - $keyfilter2 = '_'.$keyfiltercatid.'$'; - $keyfilter3 = '^'.$keyfiltercatid.'_'; - $keyfilter4 = '_'.$keyfiltercatid.'_'; - foreach ($this->cats as $key => $val) - { - $test = (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath']) - || preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath'])); + //print "Look to discard category ".$markafterid."\n"; + $keyfilter1 = '^'.$keyfiltercatid.'$'; + $keyfilter2 = '_'.$keyfiltercatid.'$'; + $keyfilter3 = '^'.$keyfiltercatid.'_'; + $keyfilter4 = '_'.$keyfiltercatid.'_'; + foreach ($this->cats as $key => $val) + { + $test = (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath']) + || preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath'])); - if (($test && !$include) || (!$test && $include)) - { - unset($this->cats[$key]); - } - } - } + if (($test && !$include) || (!$test && $include)) + { + unset($this->cats[$key]); + } + } + } dol_syslog(get_class($this)."::get_full_arbo dol_sort_array", LOG_DEBUG); $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); @@ -1173,7 +1173,7 @@ class Categorie extends CommonObject return $this->cats; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * For category id_categ and its childs available in this->cats, define property fullpath and fulllabel. * It is called by get_full_arbo() @@ -1184,10 +1184,10 @@ class Categorie extends CommonObject * @return void * @see get_full_arbo() */ - public function build_path_from_id_categ($id_categ, $protection = 1000) - { - // phpcs:enable - dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); + public function build_path_from_id_categ($id_categ, $protection = 1000) + { + // phpcs:enable + dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); if (!empty($this->cats[$id_categ]['fullpath'])) { @@ -1218,10 +1218,10 @@ class Categorie extends CommonObject $nbunderscore = substr_count($this->cats[$id_categ]['fullpath'], '_'); $this->cats[$id_categ]['level'] = ($nbunderscore ? $nbunderscore : null); - return; - } + return; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Display content of $this->cats * @@ -1229,7 +1229,7 @@ class Categorie extends CommonObject */ public function debug_cats() { - // phpcs:enable + // phpcs:enable // Display $this->cats foreach ($this->cats as $key => $val) { @@ -1244,7 +1244,7 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns all categories * @@ -1254,7 +1254,7 @@ class Categorie extends CommonObject */ public function get_all_categories($type = null, $parent = false) { - // phpcs:enable + // phpcs:enable if (!is_numeric($type)) $type = $this->MAP_ID[$type]; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; @@ -1290,11 +1290,11 @@ class Categorie extends CommonObject */ public function get_main_categories($type = null) { - // phpcs:enable - return $this->get_all_categories($type, true); + // phpcs:enable + return $this->get_all_categories($type, true); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check if no category with same label already exists for this cat's parent or root and for this cat's type * @@ -1302,7 +1302,7 @@ class Categorie extends CommonObject */ public function already_exists() { - // phpcs:enable + // phpcs:enable $type = $this->type; if (!is_numeric($type)) $type = $this->MAP_ID[$type]; @@ -1344,7 +1344,7 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the path of the category, with the names of the categories * separated by $sep (" >> " by default) @@ -1357,7 +1357,7 @@ class Categorie extends CommonObject */ public function print_all_ways($sep = ' >> ', $url = '', $nocolor = 0, $addpicto = 0) { - // phpcs:enable + // phpcs:enable $ways = array(); $allways = $this->get_all_ways(); // Load array of categories @@ -1368,26 +1368,26 @@ class Categorie extends CommonObject $forced_color = ''; foreach ($way as $cat) { - $i++; + $i++; - if (empty($nocolor)) - { - $forced_color = 'toreplace'; - if ($i == count($way)) - { - // Check contrast with background and correct text color - $forced_color = 'categtextwhite'; - if ($cat->color) - { - if (colorIsLight($cat->color)) $forced_color = 'categtextblack'; - } - } - } + if (empty($nocolor)) + { + $forced_color = 'toreplace'; + if ($i == count($way)) + { + // Check contrast with background and correct text color + $forced_color = 'categtextwhite'; + if ($cat->color) + { + if (colorIsLight($cat->color)) $forced_color = 'categtextblack'; + } + } + } if ($url == '') { - $link = ''; - $linkend = ''; - $w[] = $link.($addpicto ? img_object('', 'category', 'class="paddingright"') : '').$cat->label.$linkend; + $link = ''; + $linkend = ''; + $w[] = $link.($addpicto ? img_object('', 'category', 'class="paddingright"') : '').$cat->label.$linkend; } elseif ($url == 'none') { $link = ''; $linkend = ''; @@ -1405,7 +1405,7 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an array containing the list of parent categories * @@ -1413,7 +1413,7 @@ class Categorie extends CommonObject */ public function get_meres() { - // phpcs:enable + // phpcs:enable $parents = array(); $sql = "SELECT fk_parent FROM ".MAIN_DB_PREFIX."categorie"; @@ -1439,7 +1439,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns in a table all possible paths to get to the category * starting with the major categories represented by Tables of categories @@ -1448,7 +1448,7 @@ class Categorie extends CommonObject */ public function get_all_ways() { - // phpcs:enable + // phpcs:enable $ways = array(); $parents = $this->get_meres(); @@ -1490,60 +1490,60 @@ class Categorie extends CommonObject if ($type === Categorie::TYPE_BANK_LINE) // TODO Remove this with standard category code { - // Load bank groups - $sql = "SELECT c.label, c.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c"; - $sql .= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid"; - $sql .= " ORDER BY c.label"; + // Load bank groups + $sql = "SELECT c.label, c.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c"; + $sql .= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid"; + $sql .= " ORDER BY c.label"; - $res = $this->db->query($sql); - if ($res) - { - while ($obj = $this->db->fetch_object($res)) - { - if ($mode == 'id') { - $cats[] = $obj->rowid; - } elseif ($mode == 'label') { - $cats[] = $obj->label; - } else { - $cat = new Categorie($this->db); - $cat->id = $obj->rowid; - $cat->label = $obj->label; - $cats[] = $cat; - } - } - } else { - dol_print_error($this->db); - return -1; - } + $res = $this->db->query($sql); + if ($res) + { + while ($obj = $this->db->fetch_object($res)) + { + if ($mode == 'id') { + $cats[] = $obj->rowid; + } elseif ($mode == 'label') { + $cats[] = $obj->label; + } else { + $cat = new Categorie($this->db); + $cat->id = $obj->rowid; + $cat->label = $obj->label; + $cats[] = $cat; + } + } + } else { + dol_print_error($this->db); + return -1; + } } else { - $sql = "SELECT ct.fk_categorie, c.label, c.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type])." as ct, ".MAIN_DB_PREFIX."categorie as c"; - $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".(int) $id." AND c.type = ".$this->MAP_ID[$type]; - $sql .= " AND c.entity IN (".getEntity('category').")"; + $sql = "SELECT ct.fk_categorie, c.label, c.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type])." as ct, ".MAIN_DB_PREFIX."categorie as c"; + $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".(int) $id." AND c.type = ".$this->MAP_ID[$type]; + $sql .= " AND c.entity IN (".getEntity('category').")"; - $res = $this->db->query($sql); - if ($res) - { - while ($obj = $this->db->fetch_object($res)) - { - if ($mode == 'id') { - $cats[] = $obj->rowid; - } elseif ($mode == 'label') { - $cats[] = $obj->label; - } else { - $cat = new Categorie($this->db); - $cat->fetch($obj->fk_categorie); - $cats[] = $cat; - } - } - } else { - dol_print_error($this->db); - return -1; - } - } + $res = $this->db->query($sql); + if ($res) + { + while ($obj = $this->db->fetch_object($res)) + { + if ($mode == 'id') { + $cats[] = $obj->rowid; + } elseif ($mode == 'label') { + $cats[] = $obj->label; + } else { + $cat = new Categorie($this->db); + $cat->fetch($obj->fk_categorie); + $cats[] = $cat; + } + } + } else { + dol_print_error($this->db); + return -1; + } + } - return $cats; + return $cats; } @@ -1553,7 +1553,7 @@ class Categorie extends CommonObject * * @param int $id Id * @param string $nom Name - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated. + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated. * @param boolean $exact Exact string search (true/false) * @param boolean $case Case sensitive (true/false) * @return Categorie[]|int Array of Categorie, -1 if error @@ -1567,15 +1567,15 @@ class Categorie extends CommonObject $cats = array(); - // For backward compatibility - if (is_numeric($type)) { - // We want to reverse lookup - $map_type = array_flip($this->MAP_ID); - $type = $map_type[$type]; - dol_syslog(get_class($this)."::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING); - } + // For backward compatibility + if (is_numeric($type)) { + // We want to reverse lookup + $map_type = array_flip($this->MAP_ID); + $type = $map_type[$type]; + dol_syslog(get_class($this)."::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING); + } - // Generation requete recherche + // Generation requete recherche $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; $sql .= " WHERE type = ".$this->MAP_ID[$type]; $sql .= " AND entity IN (".getEntity('category').")"; @@ -1638,14 +1638,14 @@ class Categorie extends CommonObject $picto = 'category'; - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend; return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Deplace fichier uploade sous le nom $files dans le repertoire sdir * @@ -1655,7 +1655,7 @@ class Categorie extends CommonObject */ public function add_photo($sdir, $file) { - // phpcs:enable + // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $dir = $sdir.'/'.get_exdir($this->id, 2, 0, 0, $this, 'category').$this->id."/"; @@ -1695,7 +1695,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return tableau de toutes les photos de la categorie * @@ -1705,7 +1705,7 @@ class Categorie extends CommonObject */ public function liste_photos($dir, $nbmax = 0) { - // phpcs:enable + // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $nbphoto = 0; @@ -1716,43 +1716,43 @@ class Categorie extends CommonObject if (file_exists($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) - { - $nbphoto++; - $photo = $file; + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) + { + $nbphoto++; + $photo = $file; - // On determine nom du fichier vignette - $photo_vignette = ''; - if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) - { - $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0]; - } + // On determine nom du fichier vignette + $photo_vignette = ''; + if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) + { + $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0]; + } - // Objet - $obj = array(); - $obj['photo'] = $photo; - if ($photo_vignette && is_file($dirthumb.$photo_vignette)) $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; - else $obj['photo_vignette'] = ""; + // Objet + $obj = array(); + $obj['photo'] = $photo; + if ($photo_vignette && is_file($dirthumb.$photo_vignette)) $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; + else $obj['photo_vignette'] = ""; - $tabobj[$nbphoto - 1] = $obj; + $tabobj[$nbphoto - 1] = $obj; - // On continue ou on arrete de boucler - if ($nbmax && $nbphoto >= $nbmax) break; - } - } + // On continue ou on arrete de boucler + if ($nbmax && $nbphoto >= $nbmax) break; + } + } - closedir($handle); - } + closedir($handle); + } } return $tabobj; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Efface la photo de la categorie et sa vignette * @@ -1761,10 +1761,10 @@ class Categorie extends CommonObject */ public function delete_photo($file) { - // phpcs:enable - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + // phpcs:enable + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine + $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette $filename = preg_replace('/'.preg_quote($dir, '/').'/i', '', $file); // Nom du fichier @@ -1782,7 +1782,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load size of image file * @@ -1791,7 +1791,7 @@ class Categorie extends CommonObject */ public function get_image_size($file) { - // phpcs:enable + // phpcs:enable $infoImg = getimagesize($file); // Recuperation des infos de l'image $this->imgWidth = $infoImg[0]; // Largeur de l'image $this->imgHeight = $infoImg[1]; // Hauteur de l'image @@ -1806,63 +1806,63 @@ class Categorie extends CommonObject */ public function setMultiLangs($user) { - global $langs; + global $langs; - $langs_available = $langs->get_available_languages(); - $current_lang = $langs->getDefaultLang(); + $langs_available = $langs->get_available_languages(); + $current_lang = $langs->getDefaultLang(); - foreach ($langs_available as $key => $value) - { - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; - $sql .= " WHERE fk_category=".$this->id; - $sql .= " AND lang='".$key."'"; + foreach ($langs_available as $key => $value) + { + $sql = "SELECT rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; + $sql .= " WHERE fk_category=".$this->id; + $sql .= " AND lang='".$key."'"; - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($key == $current_lang) - { - if ($this->db->num_rows($result)) // si aucune ligne dans la base - { - $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; - $sql2 .= " SET label='".$this->db->escape($this->label)."',"; - $sql2 .= " description='".$this->db->escape($this->description)."'"; - $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; - } else { - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; - $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->label); - $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; - } - dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); - if (!$this->db->query($sql2)) - { - $this->error = $this->db->lasterror(); - return -1; - } - } elseif (isset($this->multilangs["$key"])) - { - if ($this->db->num_rows($result)) // si aucune ligne dans la base - { - $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; - $sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; - $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; - $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; - } else { - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; - $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->multilangs["$key"]["label"]); - $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; - } + if ($key == $current_lang) + { + if ($this->db->num_rows($result)) // si aucune ligne dans la base + { + $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; + $sql2 .= " SET label='".$this->db->escape($this->label)."',"; + $sql2 .= " description='".$this->db->escape($this->description)."'"; + $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; + } else { + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; + $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->label); + $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; + } + dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); + if (!$this->db->query($sql2)) + { + $this->error = $this->db->lasterror(); + return -1; + } + } elseif (isset($this->multilangs["$key"])) + { + if ($this->db->num_rows($result)) // si aucune ligne dans la base + { + $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; + $sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; + $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'"; + } else { + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; + $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->multilangs["$key"]["label"]); + $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; + } - // on ne sauvegarde pas des champs vides - if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"]) - dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); - if (!$this->db->query($sql2)) - { - $this->error = $this->db->lasterror(); - return -1; - } - } - } + // on ne sauvegarde pas des champs vides + if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"]) + dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); + if (!$this->db->query($sql2)) + { + $this->error = $this->db->lasterror(); + return -1; + } + } + } // Call trigger $result = $this->call_trigger('CATEGORY_SET_MULTILANGS', $user); @@ -1872,7 +1872,7 @@ class Categorie extends CommonObject } // End call triggers - return 1; + return 1; } /** @@ -1882,33 +1882,33 @@ class Categorie extends CommonObject */ public function getMultiLangs() { - global $langs; + global $langs; - $current_lang = $langs->getDefaultLang(); + $current_lang = $langs->getDefaultLang(); - $sql = "SELECT lang, label, description"; - $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; - $sql .= " WHERE fk_category=".$this->id; + $sql = "SELECT lang, label, description"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; + $sql .= " WHERE fk_category=".$this->id; - $result = $this->db->query($sql); - if ($result) - { - while ($obj = $this->db->fetch_object($result)) - { - //print 'lang='.$obj->lang.' current='.$current_lang.'
'; - if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. - { - $this->label = $obj->label; - $this->description = $obj->description; - } - $this->multilangs["$obj->lang"]["label"] = $obj->label; - $this->multilangs["$obj->lang"]["description"] = $obj->description; - } - return 1; - } else { - $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; - return -1; - } + $result = $this->db->query($sql); + if ($result) + { + while ($obj = $this->db->fetch_object($result)) + { + //print 'lang='.$obj->lang.' current='.$current_lang.'
'; + if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. + { + $this->label = $obj->label; + $this->description = $obj->description; + } + $this->multilangs["$obj->lang"]["label"] = $obj->label; + $this->multilangs["$obj->lang"]["description"] = $obj->description; + } + return 1; + } else { + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; + return -1; + } } /** @@ -1919,47 +1919,47 @@ class Categorie extends CommonObject */ public function getLibStatut($mode) { - return ''; + return ''; } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() - { - dol_syslog(get_class($this)."::initAsSpecimen"); + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { + dol_syslog(get_class($this)."::initAsSpecimen"); - // Initialise parametres - $this->id = 0; - $this->fk_parent = 0; - $this->label = 'SPECIMEN'; - $this->specimen = 1; - $this->description = 'This is a description'; - $this->socid = 1; - $this->type = self::TYPE_PRODUCT; - } + // Initialise parametres + $this->id = 0; + $this->fk_parent = 0; + $this->label = 'SPECIMEN'; + $this->specimen = 1; + $this->description = 'This is a description'; + $this->socid = 1; + $this->type = self::TYPE_PRODUCT; + } - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'categorie_societe' - ); + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'categorie_societe' + ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); - } + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); + } /** * Return the addtional SQL JOIN query for filtering a list by a category diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 37ddf2f43ae..5514172182e 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -41,307 +41,307 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncommreminder.class.php' */ class ActionComm extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element = 'action'; + /** + * @var string ID to identify managed object + */ + public $element = 'action'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'actioncomm'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'actioncomm'; - /** - * @var string Name of id column - */ - public $table_rowid = 'id'; + /** + * @var string Name of id column + */ + public $table_rowid = 'id'; - /** - * @var string Name of icon for actioncomm object. Filename of icon is object_action.png - */ - public $picto = 'action'; + /** + * @var string Name of icon for actioncomm object. Filename of icon is object_action.png + */ + public $picto = 'action'; - /** - * @var int 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - */ - public $ismultientitymanaged = 1; + /** + * @var int 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 1; - /** - * @var integer 0=Default - * 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user - * 2=Same than 1 but accept record if fksoc is empty - */ - public $restrictiononfksoc = 2; + /** + * @var integer 0=Default + * 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user + * 2=Same than 1 but accept record if fksoc is empty + */ + public $restrictiononfksoc = 2; - /** - * @var int Id of the event - */ - public $id; + /** + * @var int Id of the event + */ + public $id; - /** - * @var int Id of the event. Use $id as possible - */ - public $ref; + /** + * @var int Id of the event. Use $id as possible + */ + public $ref; - /** - * @var int Id into parent table llx_c_actioncomm (used only if option to use type is set) - */ - public $type_id; + /** + * @var int Id into parent table llx_c_actioncomm (used only if option to use type is set) + */ + public $type_id; - /** - * @var string Code into parent table llx_c_actioncomm (used only if option to use type is set). With default setup, should be AC_OTH_AUTO or AC_OTH. - */ - public $type_code; + /** + * @var string Code into parent table llx_c_actioncomm (used only if option to use type is set). With default setup, should be AC_OTH_AUTO or AC_OTH. + */ + public $type_code; - /** - * @var string Type label - */ - public $type_label; + /** + * @var string Type label + */ + public $type_label; - /** - * @var string Label into parent table llx_c_actioncomm (used only if option to use type is set) - */ - public $type; + /** + * @var string Label into parent table llx_c_actioncomm (used only if option to use type is set) + */ + public $type; - /** - * @var string Color into parent table llx_c_actioncomm (used only if option to use type is set) - */ - public $type_color; + /** + * @var string Color into parent table llx_c_actioncomm (used only if option to use type is set) + */ + public $type_color; - /** - * @var string Free code to identify action. Ie: Agenda trigger add here AC_TRIGGERNAME ('AC_COMPANY_CREATE', 'AC_PROPAL_VALIDATE', ...) - */ - public $code; + /** + * @var string Free code to identify action. Ie: Agenda trigger add here AC_TRIGGERNAME ('AC_COMPANY_CREATE', 'AC_PROPAL_VALIDATE', ...) + */ + public $code; - /** - * @var string Agenda event label - */ - public $label; + /** + * @var string Agenda event label + */ + public $label; - /** - * @var integer Date creation record (datec) - */ - public $datec; + /** + * @var integer Date creation record (datec) + */ + public $datec; - /** - * @var integer Date end record (datef) - */ - public $datef; + /** + * @var integer Date end record (datef) + */ + public $datef; - /** - * @var integer Duration (duree) - */ - public $duree; + /** + * @var integer Duration (duree) + */ + public $duree; - /** - * @var integer Date modification record (tms) - */ - public $datem; + /** + * @var integer Date modification record (tms) + */ + public $datem; - /** - * @var User Object user that create action - * @deprecated - * @see $authorid - */ - public $author; + /** + * @var User Object user that create action + * @deprecated + * @see $authorid + */ + public $author; - /** - * @var User Object user that modified action - * @deprecated - * @see $usermodid - */ - public $usermod; + /** + * @var User Object user that modified action + * @deprecated + * @see $usermodid + */ + public $usermod; - /** - * @var int Id user that create action - */ - public $authorid; + /** + * @var int Id user that create action + */ + public $authorid; - /** - * @var int Id user that modified action - */ - public $usermodid; + /** + * @var int Id user that modified action + */ + public $usermodid; - /** - * @var integer Date action start (datep) - */ - public $datep; + /** + * @var integer Date action start (datep) + */ + public $datep; - /** - * @var integer Date action end (datep2) - */ - public $datep2; + /** + * @var integer Date action end (datep2) + */ + public $datep2; - /** - * @var int -1=Unkown duration - * @deprecated - */ - public $durationp = -1; + /** + * @var int -1=Unkown duration + * @deprecated + */ + public $durationp = -1; - /** - * @var int 1=Event on full day - */ - public $fulldayevent = 0; + /** + * @var int 1=Event on full day + */ + public $fulldayevent = 0; - /** - * @var integer Percentage - */ - public $percentage; + /** + * @var integer Percentage + */ + public $percentage; - /** - * @var string Location - */ - public $location; + /** + * @var string Location + */ + public $location; - /** - * @var int Transparency (ical standard). Used to say if people assigned to event are busy or not by event. 0=available, 1=busy, 2=busy (refused events) - */ - public $transparency; + /** + * @var int Transparency (ical standard). Used to say if people assigned to event are busy or not by event. 0=available, 1=busy, 2=busy (refused events) + */ + public $transparency; - /** - * @var int (0 By default) - */ - public $priority; + /** + * @var int (0 By default) + */ + public $priority; - /** - * @var int[] Array of user ids - */ - public $userassigned = array(); + /** + * @var int[] Array of user ids + */ + public $userassigned = array(); - /** - * @var int Id of user owner = fk_user_action into table - */ - public $userownerid; + /** + * @var int Id of user owner = fk_user_action into table + */ + public $userownerid; - /** - * @var int Id of user done (deprecated) - * @deprecated - */ - public $userdoneid; + /** + * @var int Id of user done (deprecated) + * @deprecated + */ + public $userdoneid; - /** - * @var int[] Array of contact ids - */ - public $socpeopleassigned = array(); + /** + * @var int[] Array of contact ids + */ + public $socpeopleassigned = array(); - /** - * @var int[] Array of other contact emails (not user, not contact) - */ - public $otherassigned = array(); + /** + * @var int[] Array of other contact emails (not user, not contact) + */ + public $otherassigned = array(); - /** - * @var User Object user of owner - * @deprecated - * @see $userownerid - */ - public $usertodo; + /** + * @var User Object user of owner + * @deprecated + * @see $userownerid + */ + public $usertodo; - /** - * @var User Object user that did action - * @deprecated - * @see $userdoneid - */ - public $userdone; + /** + * @var User Object user that did action + * @deprecated + * @see $userdoneid + */ + public $userdone; - /** - * @var int thirdparty id linked to action - */ - public $socid; + /** + * @var int thirdparty id linked to action + */ + public $socid; - /** - * @var int socpeople id linked to action - */ - public $contactid; + /** + * @var int socpeople id linked to action + */ + public $contactid; - /** - * @var Societe|null Company linked to action (optional) - * @deprecated - * @see $socid - */ - public $societe; + /** + * @var Societe|null Company linked to action (optional) + * @deprecated + * @see $socid + */ + public $societe; - /** - * @var Contact|null Contact linked to action (optional) - * @deprecated - * @see $contactid - */ - public $contact; + /** + * @var Contact|null Contact linked to action (optional) + * @deprecated + * @see $contactid + */ + public $contact; - // Properties for links to other objects - /** - * @var int Id of linked object - */ - public $fk_element; // Id of record + // Properties for links to other objects + /** + * @var int Id of linked object + */ + public $fk_element; // Id of record - /** - * @var int Id of record alternative for API - */ - public $elementid; + /** + * @var int Id of record alternative for API + */ + public $elementid; - /** - * @var string Type of record. This if property ->element of object linked to. - */ - public $elementtype; + /** + * @var string Type of record. This if property ->element of object linked to. + */ + public $elementtype; - /** - * @var string Ical name - */ - public $icalname; + /** + * @var string Ical name + */ + public $icalname; - /** - * @var string Ical color - */ - public $icalcolor; + /** + * @var string Ical color + */ + public $icalcolor; - /** - * @var string Extraparam - */ - public $extraparams; + /** + * @var string Extraparam + */ + public $extraparams; - /** - * @var array Actions - */ - public $actions = array(); + /** + * @var array Actions + */ + public $actions = array(); - /** - * @var string Email msgid - */ - public $email_msgid; + /** + * @var string Email msgid + */ + public $email_msgid; - /** - * @var string Email from - */ - public $email_from; + /** + * @var string Email from + */ + public $email_from; - /** - * @var string Email sender - */ - public $email_sender; + /** + * @var string Email sender + */ + public $email_sender; - /** - * @var string Email to - */ - public $email_to; + /** + * @var string Email to + */ + public $email_to; - /** - * @var string Email tocc - */ - public $email_tocc; - /** - * @var string Email tobcc - */ - public $email_tobcc; + /** + * @var string Email tocc + */ + public $email_tocc; + /** + * @var string Email tobcc + */ + public $email_tobcc; - /** - * @var string Email subject - */ - public $email_subject; + /** + * @var string Email subject + */ + public $email_subject; - /** - * @var string Email errors to - */ - public $errors_to; + /** + * @var string Email errors to + */ + public $errors_to; /** * Typical value for a event that is in a todo state @@ -358,186 +358,186 @@ class ActionComm extends CommonObject */ const EVENT_FINISHED = 100; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct(DoliDB $db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + } - /** - * Add an action/event into database. - * $this->type_id OR $this->type_code must be set. - * - * @param User $user Object user making action - * @param int $notrigger 1 = disable triggers, 0 = enable triggers - * @return int Id of created event, < 0 if KO - */ - public function create(User $user, $notrigger = 0) - { - global $langs, $conf, $hookmanager; + /** + * Add an action/event into database. + * $this->type_id OR $this->type_code must be set. + * + * @param User $user Object user making action + * @param int $notrigger 1 = disable triggers, 0 = enable triggers + * @return int Id of created event, < 0 if KO + */ + public function create(User $user, $notrigger = 0) + { + global $langs, $conf, $hookmanager; - $error = 0; - $now = dol_now(); + $error = 0; + $now = dol_now(); - // Check parameters - if (!isset($this->userownerid) || $this->userownerid === '') // $this->userownerid may be 0 (anonymous event) of > 0 - { - dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); - $this->errors[] = 'ErrorPropertyUserowneridNotDefined'; - return -1; - } + // Check parameters + if (!isset($this->userownerid) || $this->userownerid === '') // $this->userownerid may be 0 (anonymous event) of > 0 + { + dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); + $this->errors[] = 'ErrorPropertyUserowneridNotDefined'; + return -1; + } - // Clean parameters - $this->label = dol_trunc(trim($this->label), 128); - $this->location = dol_trunc(trim($this->location), 128); - $this->note_private = dol_htmlcleanlastbr(trim(empty($this->note_private) ? $this->note : $this->note_private)); - if (empty($this->percentage)) $this->percentage = 0; - if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; - if (empty($this->fulldayevent)) $this->fulldayevent = 0; - if (empty($this->transparency)) $this->transparency = 0; - if ($this->percentage > 100) $this->percentage = 100; - //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; - if (!empty($this->datep) && !empty($this->datef)) $this->durationp = ($this->datef - $this->datep); // deprecated - //if (! empty($this->date) && ! empty($this->dateend)) $this->durationa=($this->dateend - $this->date); - if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) $this->datef = $this->datep; - //if (! empty($this->date) && ! empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date; - if (!isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0; - // For backward compatibility - if ($this->elementtype == 'facture') $this->elementtype = 'invoice'; - if ($this->elementtype == 'commande') $this->elementtype = 'order'; - if ($this->elementtype == 'contrat') $this->elementtype = 'contract'; + // Clean parameters + $this->label = dol_trunc(trim($this->label), 128); + $this->location = dol_trunc(trim($this->location), 128); + $this->note_private = dol_htmlcleanlastbr(trim(empty($this->note_private) ? $this->note : $this->note_private)); + if (empty($this->percentage)) $this->percentage = 0; + if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; + if (empty($this->fulldayevent)) $this->fulldayevent = 0; + if (empty($this->transparency)) $this->transparency = 0; + if ($this->percentage > 100) $this->percentage = 100; + //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; + if (!empty($this->datep) && !empty($this->datef)) $this->durationp = ($this->datef - $this->datep); // deprecated + //if (! empty($this->date) && ! empty($this->dateend)) $this->durationa=($this->dateend - $this->date); + if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) $this->datef = $this->datep; + //if (! empty($this->date) && ! empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date; + if (!isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0; + // For backward compatibility + if ($this->elementtype == 'facture') $this->elementtype = 'invoice'; + if ($this->elementtype == 'commande') $this->elementtype = 'order'; + if ($this->elementtype == 'contrat') $this->elementtype = 'contract'; - if (!is_array($this->userassigned) && !empty($this->userassigned)) // For backward compatibility when userassigned was an int instead fo array - { - $tmpid = $this->userassigned; - $this->userassigned = array(); - $this->userassigned[$tmpid] = array('id'=>$tmpid, 'transparency'=>$this->transparency); - } + if (!is_array($this->userassigned) && !empty($this->userassigned)) // For backward compatibility when userassigned was an int instead fo array + { + $tmpid = $this->userassigned; + $this->userassigned = array(); + $this->userassigned[$tmpid] = array('id'=>$tmpid, 'transparency'=>$this->transparency); + } - $userownerid = $this->userownerid; - $userdoneid = $this->userdoneid; + $userownerid = $this->userownerid; + $userdoneid = $this->userdoneid; - // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). - if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) - $this->userassigned = array($userownerid=>array('id'=>$userownerid, 'transparency'=>$this->transparency)); + // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). + if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) + $this->userassigned = array($userownerid=>array('id'=>$userownerid, 'transparency'=>$this->transparency)); - if (!$this->type_id || !$this->type_code) - { - $key = empty($this->type_id) ? $this->type_code : $this->type_id; + if (!$this->type_id || !$this->type_code) + { + $key = empty($this->type_id) ? $this->type_code : $this->type_id; - // Get id from code - $cactioncomm = new CActionComm($this->db); - $result = $cactioncomm->fetch($key); + // Get id from code + $cactioncomm = new CActionComm($this->db); + $result = $cactioncomm->fetch($key); - if ($result > 0) - { - $this->type_id = $cactioncomm->id; - $this->type_code = $cactioncomm->code; - } elseif ($result == 0) - { - $this->error = 'Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"'; - return -1; - } else { - $this->error = $cactioncomm->error; - return -1; - } - } - $code = empty($this->code) ? $this->type_code : $this->code; + if ($result > 0) + { + $this->type_id = $cactioncomm->id; + $this->type_code = $cactioncomm->code; + } elseif ($result == 0) + { + $this->error = 'Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"'; + return -1; + } else { + $this->error = $cactioncomm->error; + return -1; + } + } + $code = empty($this->code) ? $this->type_code : $this->code; - // Check parameters - if (!$this->type_id) - { - $this->error = "ErrorWrongParameters"; - return -1; - } + // Check parameters + if (!$this->type_id) + { + $this->error = "ErrorWrongParameters"; + return -1; + } - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm"; - $sql .= "(datec,"; - $sql .= "datep,"; - $sql .= "datep2,"; - $sql .= "durationp,"; // deprecated - $sql .= "fk_action,"; - $sql .= "code,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm"; + $sql .= "(datec,"; + $sql .= "datep,"; + $sql .= "datep2,"; + $sql .= "durationp,"; // deprecated + $sql .= "fk_action,"; + $sql .= "code,"; $sql .= "ref_ext,"; - $sql .= "fk_soc,"; - $sql .= "fk_project,"; - $sql .= "note,"; - $sql .= "fk_contact,"; - $sql .= "fk_user_author,"; - $sql .= "fk_user_action,"; - $sql .= "fk_user_done,"; - $sql .= "label,percent,priority,fulldayevent,location,"; - $sql .= "transparency,"; - $sql .= "fk_element,"; - $sql .= "elementtype,"; - $sql .= "entity,"; - $sql .= "extraparams,"; + $sql .= "fk_soc,"; + $sql .= "fk_project,"; + $sql .= "note,"; + $sql .= "fk_contact,"; + $sql .= "fk_user_author,"; + $sql .= "fk_user_action,"; + $sql .= "fk_user_done,"; + $sql .= "label,percent,priority,fulldayevent,location,"; + $sql .= "transparency,"; + $sql .= "fk_element,"; + $sql .= "elementtype,"; + $sql .= "entity,"; + $sql .= "extraparams,"; // Fields emails - $sql .= "email_msgid,"; - $sql .= "email_from,"; - $sql .= "email_sender,"; - $sql .= "email_to,"; - $sql .= "email_tocc,"; - $sql .= "email_tobcc,"; - $sql .= "email_subject,"; - $sql .= "errors_to"; - $sql .= ") VALUES ("; - $sql .= "'".$this->db->idate($now)."', "; - $sql .= (strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : "null").", "; - $sql .= (strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : "null").", "; - $sql .= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '') ? "'".$this->db->escape($this->durationp)."'" : "null").", "; // deprecated - $sql .= (isset($this->type_id) ? $this->type_id : "null").","; - $sql .= ($code ? ("'".$this->db->escape($code)."'") : "null").", "; - $sql .= ($this->ref_ext ? ("'".$this->db->idate($this->ref_ext)."'") : "null").", "; - $sql .= ((isset($this->socid) && $this->socid > 0) ? $this->socid : "null").", "; - $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : "null").", "; - $sql .= " '".$this->db->escape($this->note_private)."', "; - $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? $this->contact_id : "null").", "; // deprecated, use ->socpeopleassigned - $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; - $sql .= ($userownerid > 0 ? $userownerid : "null").", "; - $sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; - $sql .= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."', "; - $sql .= "'".$this->db->escape($this->transparency)."', "; - $sql .= (!empty($this->fk_element) ? $this->fk_element : "null").", "; - $sql .= (!empty($this->elementtype) ? "'".$this->db->escape($this->elementtype)."'" : "null").", "; - $sql .= $conf->entity.","; - $sql .= (!empty($this->extraparams) ? "'".$this->db->escape($this->extraparams)."'" : "null").", "; - // Fields emails - $sql .= (!empty($this->email_msgid) ? "'".$this->db->escape($this->email_msgid)."'" : "null").", "; - $sql .= (!empty($this->email_from) ? "'".$this->db->escape($this->email_from)."'" : "null").", "; - $sql .= (!empty($this->email_sender) ? "'".$this->db->escape($this->email_sender)."'" : "null").", "; - $sql .= (!empty($this->email_to) ? "'".$this->db->escape($this->email_to)."'" : "null").", "; - $sql .= (!empty($this->email_tocc) ? "'".$this->db->escape($this->email_tocc)."'" : "null").", "; - $sql .= (!empty($this->email_tobcc) ? "'".$this->db->escape($this->email_tobcc)."'" : "null").", "; - $sql .= (!empty($this->email_subject) ? "'".$this->db->escape($this->email_subject)."'" : "null").", "; - $sql .= (!empty($this->errors_to) ? "'".$this->db->escape($this->errors_to)."'" : "null"); - $sql .= ")"; + $sql .= "email_msgid,"; + $sql .= "email_from,"; + $sql .= "email_sender,"; + $sql .= "email_to,"; + $sql .= "email_tocc,"; + $sql .= "email_tobcc,"; + $sql .= "email_subject,"; + $sql .= "errors_to"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($now)."', "; + $sql .= (strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : "null").", "; + $sql .= (strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : "null").", "; + $sql .= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '') ? "'".$this->db->escape($this->durationp)."'" : "null").", "; // deprecated + $sql .= (isset($this->type_id) ? $this->type_id : "null").","; + $sql .= ($code ? ("'".$this->db->escape($code)."'") : "null").", "; + $sql .= ($this->ref_ext ? ("'".$this->db->idate($this->ref_ext)."'") : "null").", "; + $sql .= ((isset($this->socid) && $this->socid > 0) ? $this->socid : "null").", "; + $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : "null").", "; + $sql .= " '".$this->db->escape($this->note_private)."', "; + $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? $this->contact_id : "null").", "; // deprecated, use ->socpeopleassigned + $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; + $sql .= ($userownerid > 0 ? $userownerid : "null").", "; + $sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; + $sql .= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."', "; + $sql .= "'".$this->db->escape($this->transparency)."', "; + $sql .= (!empty($this->fk_element) ? $this->fk_element : "null").", "; + $sql .= (!empty($this->elementtype) ? "'".$this->db->escape($this->elementtype)."'" : "null").", "; + $sql .= $conf->entity.","; + $sql .= (!empty($this->extraparams) ? "'".$this->db->escape($this->extraparams)."'" : "null").", "; + // Fields emails + $sql .= (!empty($this->email_msgid) ? "'".$this->db->escape($this->email_msgid)."'" : "null").", "; + $sql .= (!empty($this->email_from) ? "'".$this->db->escape($this->email_from)."'" : "null").", "; + $sql .= (!empty($this->email_sender) ? "'".$this->db->escape($this->email_sender)."'" : "null").", "; + $sql .= (!empty($this->email_to) ? "'".$this->db->escape($this->email_to)."'" : "null").", "; + $sql .= (!empty($this->email_tocc) ? "'".$this->db->escape($this->email_tocc)."'" : "null").", "; + $sql .= (!empty($this->email_tobcc) ? "'".$this->db->escape($this->email_tobcc)."'" : "null").", "; + $sql .= (!empty($this->email_subject) ? "'".$this->db->escape($this->email_subject)."'" : "null").", "; + $sql .= (!empty($this->errors_to) ? "'".$this->db->escape($this->errors_to)."'" : "null"); + $sql .= ")"; - dol_syslog(get_class($this)."::add", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); + dol_syslog(get_class($this)."::add", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); - // Now insert assigned users + // Now insert assigned users if (!$error) { //dol_syslog(var_export($this->userassigned, true)); foreach ($this->userassigned as $key => $val) { - if (!is_array($val)) // For backward compatibility when val=id - { - $val = array('id'=>$val); - } + if (!is_array($val)) // For backward compatibility when val=id + { + $val = array('id'=>$val); + } - if ($val['id'] > 0) - { + if ($val['id'] > 0) + { $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; @@ -546,10 +546,10 @@ class ActionComm extends CommonObject { $error++; dol_syslog('Error to process userassigned: '.$this->db->lasterror(), LOG_ERR); - $this->errors[] = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } //var_dump($sql);exit; - } + } } } @@ -573,54 +573,54 @@ class ActionComm extends CommonObject } } - if (!$error) - { - // Actions on extra fields - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + if (!$error) + { + // Actions on extra fields + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('ACTION_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('ACTION_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return $this->id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - return -1; - } - } + if (!$error) + { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + return -1; + } + } else { + $this->db->rollback(); + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Load an object from its id and create a new one in database - * - * @param User $fuser Object user making action + /** + * Load an object from its id and create a new one in database + * + * @param User $fuser Object user making action * @param int $socid Id of thirdparty - * @return int New id of clone - */ - public function createFromClone(User $fuser, $socid) - { - global $db, $conf, $hookmanager; + * @return int New id of clone + */ + public function createFromClone(User $fuser, $socid) + { + global $db, $conf, $hookmanager; - $error = 0; - $now = dol_now(); + $error = 0; + $now = dol_now(); - $this->db->begin(); + $this->db->begin(); // Load source object $objFrom = clone $this; @@ -723,7 +723,7 @@ class ActionComm extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->id; - $this->entity = $obj->entity; + $this->entity = $obj->entity; $this->ref = $obj->ref; $this->ref_ext = $obj->ref_ext; @@ -767,7 +767,7 @@ class ActionComm extends CommonObject $this->transparency = $obj->transparency; $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working - $this->contact_id = $obj->fk_contact; // To have fetch_contact method working + $this->contact_id = $obj->fk_contact; // To have fetch_contact method working $this->fk_project = $obj->fk_project; // To have fetch_projet method working //$this->societe->id = $obj->fk_soc; // deprecated @@ -808,9 +808,9 @@ class ActionComm extends CommonObject // If owner is known, we must but id first into list if ($this->userownerid > 0) $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); // Set first so will be first into list. - while ($obj = $this->db->fetch_object($resql)) - { - if ($obj->fk_element > 0) + while ($obj = $this->db->fetch_object($resql)) + { + if ($obj->fk_element > 0) { switch ($obj->element_type) { case 'user': @@ -822,86 +822,86 @@ class ActionComm extends CommonObject break; } } - } + } - return 1; + return 1; } else { dol_print_error($this->db); return -1; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Initialize this->userassigned array with list of id of user assigned to event - * - * @param bool $override Override $this->userownerid when empty. TODO This should be false by default. True is here to fix corrupted data. - * @return int <0 if KO, >0 if OK - */ - public function fetch_userassigned($override = true) - { - // phpcs:enable - $sql = "SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency"; - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm_resources"; - $sql .= " WHERE element_type = 'user' AND fk_actioncomm = ".$this->id; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Initialize this->userassigned array with list of id of user assigned to event + * + * @param bool $override Override $this->userownerid when empty. TODO This should be false by default. True is here to fix corrupted data. + * @return int <0 if KO, >0 if OK + */ + public function fetch_userassigned($override = true) + { + // phpcs:enable + $sql = "SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm_resources"; + $sql .= " WHERE element_type = 'user' AND fk_actioncomm = ".$this->id; - $resql2 = $this->db->query($sql); - if ($resql2) - { - $this->userassigned = array(); + $resql2 = $this->db->query($sql); + if ($resql2) + { + $this->userassigned = array(); - // If owner is known, we must but id first into list - if ($this->userownerid > 0) - { - // Set first so will be first into list. - $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); - } + // If owner is known, we must but id first into list + if ($this->userownerid > 0) + { + // Set first so will be first into list. + $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); + } - while ($obj = $this->db->fetch_object($resql2)) - { - if ($obj->fk_element > 0) - { - $this->userassigned[$obj->fk_element] = array('id'=>$obj->fk_element, - 'mandatory'=>$obj->mandatory, - 'answer_status'=>$obj->answer_status, - 'transparency'=>$obj->transparency); - } + while ($obj = $this->db->fetch_object($resql2)) + { + if ($obj->fk_element > 0) + { + $this->userassigned[$obj->fk_element] = array('id'=>$obj->fk_element, + 'mandatory'=>$obj->mandatory, + 'answer_status'=>$obj->answer_status, + 'transparency'=>$obj->transparency); + } - if ($override === true) - { - // If not defined (should not happened, we fix this) - if (empty($this->userownerid)) - { - $this->userownerid = $obj->fk_element; - } - } - } + if ($override === true) + { + // If not defined (should not happened, we fix this) + if (empty($this->userownerid)) + { + $this->userownerid = $obj->fk_element; + } + } + } - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Delete event from database - * - * @param int $notrigger 1 = disable triggers, 0 = enable triggers - * @return int <0 if KO, >0 if OK - */ - public function delete($notrigger = 0) - { - global $user; + /** + * Delete event from database + * + * @param int $notrigger 1 = disable triggers, 0 = enable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete($notrigger = 0) + { + global $user; - $error = 0; + $error = 0; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); + dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $this->db->begin(); + $this->db->begin(); - // remove categorie association - if (!$error) { + // remove categorie association + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_actioncomm"; $sql .= " WHERE fk_actioncomm=".$this->id; @@ -910,148 +910,148 @@ class ActionComm extends CommonObject $this->error = $this->db->lasterror(); $error++; } - } + } - // remove actioncomm_resources - if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources"; - $sql .= " WHERE fk_actioncomm=".$this->id; + // remove actioncomm_resources + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources"; + $sql .= " WHERE fk_actioncomm=".$this->id; - $res = $this->db->query($sql); - if (!$res) { - $this->error = $this->db->lasterror(); - $error++; - } - } + $res = $this->db->query($sql); + if (!$res) { + $this->error = $this->db->lasterror(); + $error++; + } + } - // Removed extrafields - if (!$error) { - $result = $this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); - } - } + // Removed extrafields + if (!$error) { + $result = $this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); + } + } - // remove actioncomm - if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm"; - $sql .= " WHERE id=".$this->id; + // remove actioncomm + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm"; + $sql .= " WHERE id=".$this->id; - $res = $this->db->query($sql); - if (!$res) { - $this->error = $this->db->lasterror(); - $error++; - } - } + $res = $this->db->query($sql); + if (!$res) { + $this->error = $this->db->lasterror(); + $error++; + } + } - if (!$error) - { - if (!$notrigger) - { - // Call trigger - $result = $this->call_trigger('ACTION_DELETE', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (!$error) + { + if (!$notrigger) + { + // Call trigger + $result = $this->call_trigger('ACTION_DELETE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -2; - } - } else { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - return -1; - } - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -2; + } + } else { + $this->db->rollback(); + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Update action into database - * If percentage = 100, on met a jour date 100% - * - * @param User $user Object user making change - * @param int $notrigger 1 = disable triggers, 0 = enable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user, $notrigger = 0) - { - global $langs, $conf, $hookmanager; + /** + * Update action into database + * If percentage = 100, on met a jour date 100% + * + * @param User $user Object user making change + * @param int $notrigger 1 = disable triggers, 0 = enable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + global $langs, $conf, $hookmanager; - $error = 0; + $error = 0; - // Clean parameters - $this->label = trim($this->label); - $this->note_private = dol_htmlcleanlastbr(trim(empty($this->note_private) ? $this->note : $this->note_private)); - if (empty($this->percentage)) $this->percentage = 0; - if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; - if (empty($this->transparency)) $this->transparency = 0; - if (empty($this->fulldayevent)) $this->fulldayevent = 0; - if ($this->percentage > 100) $this->percentage = 100; - //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; - if ($this->datep && $this->datef) $this->durationp = ($this->datef - $this->datep); // deprecated - //if ($this->date && $this->dateend) $this->durationa=($this->dateend - $this->date); - if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef = $this->datep; - //if ($this->date && $this->dateend && $this->date > $this->dateend) $this->dateend=$this->date; - if ($this->fk_project < 0) $this->fk_project = 0; + // Clean parameters + $this->label = trim($this->label); + $this->note_private = dol_htmlcleanlastbr(trim(empty($this->note_private) ? $this->note : $this->note_private)); + if (empty($this->percentage)) $this->percentage = 0; + if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; + if (empty($this->transparency)) $this->transparency = 0; + if (empty($this->fulldayevent)) $this->fulldayevent = 0; + if ($this->percentage > 100) $this->percentage = 100; + //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; + if ($this->datep && $this->datef) $this->durationp = ($this->datef - $this->datep); // deprecated + //if ($this->date && $this->dateend) $this->durationa=($this->dateend - $this->date); + if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef = $this->datep; + //if ($this->date && $this->dateend && $this->date > $this->dateend) $this->dateend=$this->date; + if ($this->fk_project < 0) $this->fk_project = 0; - // Check parameters - if ($this->percentage == 0 && $this->userdoneid > 0) - { - $this->error = "ErrorCantSaveADoneUserWithZeroPercentage"; - return -1; - } + // Check parameters + if ($this->percentage == 0 && $this->userdoneid > 0) + { + $this->error = "ErrorCantSaveADoneUserWithZeroPercentage"; + return -1; + } - $socid = (($this->socid > 0) ? $this->socid : 0); - $contactid = (($this->contact_id > 0) ? $this->contact_id : 0); + $socid = (($this->socid > 0) ? $this->socid : 0); + $contactid = (($this->contact_id > 0) ? $this->contact_id : 0); $userownerid = ($this->userownerid ? $this->userownerid : 0); $userdoneid = ($this->userdoneid ? $this->userdoneid : 0); - $this->db->begin(); + $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; - $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; - if ($this->type_id > 0) $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; - $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); - $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); - $sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null'); - $sql .= ", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '' ? "'".$this->db->escape($this->durationp)."'" : "null"); // deprecated - $sql .= ", note = '".$this->db->escape($this->note_private)."'"; - $sql .= ", fk_project =".($this->fk_project > 0 ? $this->fk_project : "null"); - $sql .= ", fk_soc =".($socid > 0 ? $socid : "null"); - $sql .= ", fk_contact =".($contactid > 0 ? $contactid : "null"); - $sql .= ", priority = '".$this->db->escape($this->priority)."'"; - $sql .= ", fulldayevent = '".$this->db->escape($this->fulldayevent)."'"; - $sql .= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'" : "null"); - $sql .= ", transparency = '".$this->db->escape($this->transparency)."'"; - $sql .= ", fk_user_mod = ".$user->id; - $sql .= ", fk_user_action=".($userownerid > 0 ? "'".$userownerid."'" : "null"); - $sql .= ", fk_user_done=".($userdoneid > 0 ? "'".$userdoneid."'" : "null"); - if (!empty($this->fk_element)) $sql .= ", fk_element=".($this->fk_element ? $this->db->escape($this->fk_element) : "null"); - if (!empty($this->elementtype)) $sql .= ", elementtype=".($this->elementtype ? "'".$this->db->escape($this->elementtype)."'" : "null"); - $sql .= " WHERE id=".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; + $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; + if ($this->type_id > 0) $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; + $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); + $sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null'); + $sql .= ", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '' ? "'".$this->db->escape($this->durationp)."'" : "null"); // deprecated + $sql .= ", note = '".$this->db->escape($this->note_private)."'"; + $sql .= ", fk_project =".($this->fk_project > 0 ? $this->fk_project : "null"); + $sql .= ", fk_soc =".($socid > 0 ? $socid : "null"); + $sql .= ", fk_contact =".($contactid > 0 ? $contactid : "null"); + $sql .= ", priority = '".$this->db->escape($this->priority)."'"; + $sql .= ", fulldayevent = '".$this->db->escape($this->fulldayevent)."'"; + $sql .= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'" : "null"); + $sql .= ", transparency = '".$this->db->escape($this->transparency)."'"; + $sql .= ", fk_user_mod = ".$user->id; + $sql .= ", fk_user_action=".($userownerid > 0 ? "'".$userownerid."'" : "null"); + $sql .= ", fk_user_done=".($userdoneid > 0 ? "'".$userdoneid."'" : "null"); + if (!empty($this->fk_element)) $sql .= ", fk_element=".($this->fk_element ? $this->db->escape($this->fk_element) : "null"); + if (!empty($this->elementtype)) $sql .= ", elementtype=".($this->elementtype ? "'".$this->db->escape($this->elementtype)."'" : "null"); + $sql .= " WHERE id=".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - if ($this->db->query($sql)) - { + dol_syslog(get_class($this)."::update", LOG_DEBUG); + if ($this->db->query($sql)) + { $action = 'update'; - // Actions on extra fields - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + // Actions on extra fields + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - // Now insert assignedusers + // Now insert assignedusers if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'user'"; @@ -1059,10 +1059,10 @@ class ActionComm extends CommonObject foreach ($this->userassigned as $key => $val) { - if (!is_array($val)) // For backward compatibility when val=id - { - $val = array('id'=>$val); - } + if (!is_array($val)) // For backward compatibility when val=id + { + $val = array('id'=>$val); + } $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; @@ -1070,7 +1070,7 @@ class ActionComm extends CommonObject if (!$resql) { $error++; - $this->errors[] = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } //var_dump($sql);exit; } @@ -1098,272 +1098,272 @@ class ActionComm extends CommonObject } } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('ACTION_MODIFY', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('ACTION_MODIFY', $user); + if ($result < 0) { $error++; } + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - dol_syslog(get_class($this)."::update ".join(',', $this->errors), LOG_ERR); - return -2; - } - } else { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - return -1; - } - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + dol_syslog(get_class($this)."::update ".join(',', $this->errors), LOG_ERR); + return -2; + } + } else { + $this->db->rollback(); + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Load all objects with filters. - * @todo WARNING: This make a fetch on all records instead of making one request with a join. - * - * @param DoliDb $db Database handler - * @param int $socid Filter by thirdparty - * @param int $fk_element Id of element action is linked to - * @param string $elementtype Type of element action is linked to - * @param string $filter Other filter - * @param string $sortfield Sort on this field - * @param string $sortorder ASC or DESC - * @param string $limit Limit number of answers - * @return array|string Error string if KO, array with actions if OK - */ - public static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0) - { - global $conf, $langs; + /** + * Load all objects with filters. + * @todo WARNING: This make a fetch on all records instead of making one request with a join. + * + * @param DoliDb $db Database handler + * @param int $socid Filter by thirdparty + * @param int $fk_element Id of element action is linked to + * @param string $elementtype Type of element action is linked to + * @param string $filter Other filter + * @param string $sortfield Sort on this field + * @param string $sortorder ASC or DESC + * @param string $limit Limit number of answers + * @return array|string Error string if KO, array with actions if OK + */ + public static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0) + { + global $conf, $langs; - $resarray = array(); + $resarray = array(); - dol_syslog(get_class()."::getActions", LOG_DEBUG); + dol_syslog(get_class()."::getActions", LOG_DEBUG); - $sql = "SELECT a.id"; - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; - if (!empty($socid)) $sql .= " AND a.fk_soc = ".$socid; - if (!empty($elementtype)) - { - if ($elementtype == 'project') { - $sql .= ' AND a.fk_project = '.$fk_element; - } - elseif ($elementtype == 'contact') { - $sql .= ' AND a.id IN'; - $sql .= " (SELECT fk_actioncomm FROM ".MAIN_DB_PREFIX."actioncomm_resources WHERE"; - $sql .= " element_type = 'socpeople' AND fk_element = ".$fk_element.')'; - } - else { - $sql .= " AND a.fk_element = ".(int) $fk_element." AND a.elementtype = '".$elementtype."'"; - } - } - if (!empty($filter)) $sql .= $filter; + $sql = "SELECT a.id"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; + if (!empty($socid)) $sql .= " AND a.fk_soc = ".$socid; + if (!empty($elementtype)) + { + if ($elementtype == 'project') { + $sql .= ' AND a.fk_project = '.$fk_element; + } + elseif ($elementtype == 'contact') { + $sql .= ' AND a.id IN'; + $sql .= " (SELECT fk_actioncomm FROM ".MAIN_DB_PREFIX."actioncomm_resources WHERE"; + $sql .= " element_type = 'socpeople' AND fk_element = ".$fk_element.')'; + } + else { + $sql .= " AND a.fk_element = ".(int) $fk_element." AND a.elementtype = '".$elementtype."'"; + } + } + if (!empty($filter)) $sql .= $filter; if ($sortorder && $sortfield) $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit, 0); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); - if ($num) - { - for ($i = 0; $i < $num; $i++) - { - $obj = $db->fetch_object($resql); - $actioncommstatic = new ActionComm($db); - $actioncommstatic->fetch($obj->id); - $resarray[$i] = $actioncommstatic; - } - } - $db->free($resql); - return $resarray; - } else { - return $db->lasterror(); - } - } + if ($num) + { + for ($i = 0; $i < $num; $i++) + { + $obj = $db->fetch_object($resql); + $actioncommstatic = new ActionComm($db); + $actioncommstatic->fetch($obj->id); + $resarray[$i] = $actioncommstatic; + } + } + $db->free($resql); + return $resarray; + } else { + return $db->lasterror(); + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load indicators for dashboard (this->nbtodo and this->nbtodolate) - * - * @param User $user Objet user - * @param int $load_state_board Charge indicateurs this->nb de tableau de bord - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK - */ - public function load_board($user, $load_state_board = 0) - { - // phpcs:enable - global $conf, $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @param User $user Objet user + * @param int $load_state_board Charge indicateurs this->nb de tableau de bord + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + */ + public function load_board($user, $load_state_board = 0) + { + // phpcs:enable + global $conf, $langs; - if (empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp"; - else { - $this->nb = array(); - $sql = "SELECT count(a.id) as nb"; - } - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; - $sql .= " WHERE 1 = 1"; - if (empty($load_state_board)) $sql .= " AND a.percent >= 0 AND a.percent < 100"; - $sql .= " AND a.entity IN (".getEntity('agenda').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; - if ($user->socid) $sql .= " AND a.fk_soc = ".$user->socid; - if (!$user->rights->agenda->allactions->read) $sql .= " AND (a.fk_user_author = ".$user->id." OR a.fk_user_action = ".$user->id." OR a.fk_user_done = ".$user->id.")"; + if (empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp"; + else { + $this->nb = array(); + $sql = "SELECT count(a.id) as nb"; + } + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; + $sql .= " WHERE 1 = 1"; + if (empty($load_state_board)) $sql .= " AND a.percent >= 0 AND a.percent < 100"; + $sql .= " AND a.entity IN (".getEntity('agenda').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; + if ($user->socid) $sql .= " AND a.fk_soc = ".$user->socid; + if (!$user->rights->agenda->allactions->read) $sql .= " AND (a.fk_user_author = ".$user->id." OR a.fk_user_action = ".$user->id." OR a.fk_user_done = ".$user->id.")"; - $resql = $this->db->query($sql); - if ($resql) - { - if (empty($load_state_board)) { - $agenda_static = new ActionComm($this->db); - $response = new WorkboardResponse(); - $response->warning_delay = $conf->agenda->warning_delay / 60 / 60 / 24; - $response->label = $langs->trans("ActionsToDo"); - $response->labelShort = $langs->trans("ActionsToDoShort"); - $response->url = DOL_URL_ROOT.'/comm/action/list.php?action=show_list&actioncode=0&status=todo&mainmenu=agenda'; - if ($user->rights->agenda->allactions->read) $response->url .= '&filtert=-1'; - $response->img = img_object('', "action", 'class="inline-block valigntextmiddle"'); - } - // This assignment in condition is not a bug. It allows walking the results. - while ($obj = $this->db->fetch_object($resql)) - { - if (empty($load_state_board)) { - $response->nbtodo++; - $agenda_static->datep = $this->db->jdate($obj->dp); - if ($agenda_static->hasDelay()) $response->nbtodolate++; - } else $this->nb["actionscomm"] = $obj->nb; - } + $resql = $this->db->query($sql); + if ($resql) + { + if (empty($load_state_board)) { + $agenda_static = new ActionComm($this->db); + $response = new WorkboardResponse(); + $response->warning_delay = $conf->agenda->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("ActionsToDo"); + $response->labelShort = $langs->trans("ActionsToDoShort"); + $response->url = DOL_URL_ROOT.'/comm/action/list.php?action=show_list&actioncode=0&status=todo&mainmenu=agenda'; + if ($user->rights->agenda->allactions->read) $response->url .= '&filtert=-1'; + $response->img = img_object('', "action", 'class="inline-block valigntextmiddle"'); + } + // This assignment in condition is not a bug. It allows walking the results. + while ($obj = $this->db->fetch_object($resql)) + { + if (empty($load_state_board)) { + $response->nbtodo++; + $agenda_static->datep = $this->db->jdate($obj->dp); + if ($agenda_static->hasDelay()) $response->nbtodolate++; + } else $this->nb["actionscomm"] = $obj->nb; + } - $this->db->free($resql); - if (empty($load_state_board)) return $response; - else return 1; - } else { - dol_print_error($this->db); - $this->error = $this->db->error(); - return -1; - } - } + $this->db->free($resql); + if (empty($load_state_board)) return $response; + else return 1; + } else { + dol_print_error($this->db); + $this->error = $this->db->error(); + return -1; + } + } - /** - * Charge les informations d'ordre info dans l'objet facture - * - * @param int $id Id de la facture a charger - * @return void - */ - public function info($id) - { - $sql = 'SELECT '; - $sql .= ' a.id,'; - $sql .= ' datec,'; - $sql .= ' tms as datem,'; - $sql .= ' fk_user_author,'; - $sql .= ' fk_user_mod'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; - $sql .= ' WHERE a.id = '.$id; + /** + * Charge les informations d'ordre info dans l'objet facture + * + * @param int $id Id de la facture a charger + * @return void + */ + public function info($id) + { + $sql = 'SELECT '; + $sql .= ' a.id,'; + $sql .= ' datec,'; + $sql .= ' tms as datem,'; + $sql .= ' fk_user_author,'; + $sql .= ' fk_user_mod'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; + $sql .= ' WHERE a.id = '.$id; - dol_syslog(get_class($this)."::info", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->id = $obj->id; - if ($obj->fk_user_author) - { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - if ($obj->fk_user_mod) - { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_mod); - $this->user_modification = $muser; - } + dol_syslog(get_class($this)."::info", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->id; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + if ($obj->fk_user_mod) + { + $muser = new User($this->db); + $muser->fetch($obj->fk_user_mod); + $this->user_modification = $muser; + } - $this->date_creation = $this->db->jdate($obj->datec); - if (!empty($obj->fk_user_mod)) $this->date_modification = $this->db->jdate($obj->datem); - } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } + $this->date_creation = $this->db->jdate($obj->datec); + if (!empty($obj->fk_user_mod)) $this->date_modification = $this->db->jdate($obj->datem); + } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } - /** - * Return label of status - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @param int $hidenastatus 1=Show nothing if status is "Not applicable" - * @return string String with status - */ - public function getLibStatut($mode, $hidenastatus = 0) - { - return $this->LibStatut($this->percentage, $mode, $hidenastatus, $this->datep); - } + /** + * Return label of status + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $hidenastatus 1=Show nothing if status is "Not applicable" + * @return string String with status + */ + public function getLibStatut($mode, $hidenastatus = 0) + { + return $this->LibStatut($this->percentage, $mode, $hidenastatus, $this->datep); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return label of action status - * - * @param int $percent Percent - * @param int $mode 0=Long label, 1=Short label, 2=Picto+Short label, 3=Picto, 4=Picto+Short label, 5=Short label+Picto, 6=Picto+Long label, 7=Very short label+Picto - * @param int $hidenastatus 1=Show nothing if status is "Not applicable" - * @param int $datestart Date start of event - * @return string Label - */ - public function LibStatut($percent, $mode, $hidenastatus = 0, $datestart = '') - { - // phpcs:enable - global $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return label of action status + * + * @param int $percent Percent + * @param int $mode 0=Long label, 1=Short label, 2=Picto+Short label, 3=Picto, 4=Picto+Short label, 5=Short label+Picto, 6=Picto+Long label, 7=Very short label+Picto + * @param int $hidenastatus 1=Show nothing if status is "Not applicable" + * @param int $datestart Date start of event + * @return string Label + */ + public function LibStatut($percent, $mode, $hidenastatus = 0, $datestart = '') + { + // phpcs:enable + global $langs; - $labelStatus = $langs->trans('StatusNotApplicable'); - if ($percent == -1 && !$hidenastatus) $labelStatus = $langs->trans('StatusNotApplicable'); - elseif ($percent == 0) $labelStatus = $langs->trans('StatusActionToDo').' (0%)'; - elseif ($percent > 0 && $percent < 100) $labelStatus = $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; - elseif ($percent >= 100) $labelStatus = $langs->trans('StatusActionDone').' (100%)'; + $labelStatus = $langs->trans('StatusNotApplicable'); + if ($percent == -1 && !$hidenastatus) $labelStatus = $langs->trans('StatusNotApplicable'); + elseif ($percent == 0) $labelStatus = $langs->trans('StatusActionToDo').' (0%)'; + elseif ($percent > 0 && $percent < 100) $labelStatus = $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; + elseif ($percent >= 100) $labelStatus = $langs->trans('StatusActionDone').' (100%)'; - $labelStatusShort = $langs->trans('StatusNotApplicable'); - if ($percent == -1 && !$hidenastatus) $labelStatusShort = $langs->trans('NA'); - elseif ($percent == 0) $labelStatusShort = '0%'; - elseif ($percent > 0 && $percent < 100) $labelStatusShort = $percent.'%'; - elseif ($percent >= 100) $labelStatusShort = '100%'; + $labelStatusShort = $langs->trans('StatusNotApplicable'); + if ($percent == -1 && !$hidenastatus) $labelStatusShort = $langs->trans('NA'); + elseif ($percent == 0) $labelStatusShort = '0%'; + elseif ($percent > 0 && $percent < 100) $labelStatusShort = $percent.'%'; + elseif ($percent >= 100) $labelStatusShort = '100%'; - $statusType = 'status9'; - if ($percent == -1 && !$hidenastatus) $statusType = 'status9'; - if ($percent == 0) $statusType = 'status1'; - if ($percent > 0 && $percent < 100) $statusType = 'status3'; - if ($percent >= 100) $statusType = 'status6'; + $statusType = 'status9'; + if ($percent == -1 && !$hidenastatus) $statusType = 'status9'; + if ($percent == 0) $statusType = 'status1'; + if ($percent > 0 && $percent < 100) $statusType = 'status3'; + if ($percent >= 100) $statusType = 'status6'; - return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); - } + return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); + } - /** - * Return URL of event - * Use $this->id, $this->type_code, $this->label and $this->type_label - * - * @param int $withpicto 0 = No picto, 1 = Include picto into link, 2 = Only picto - * @param int $maxlength Max number of charaters into label. If negative, use the ref as label. - * @param string $classname Force style class on a link - * @param string $option '' = Link to action, 'birthday'= Link to contact, 'holiday' = Link to leave - * @param int $overwritepicto 1 = Overwrite picto - * @param int $notooltip 1 = Disable tooltip - * @param int $save_lastsearch_value -1 = Auto, 0 = No save of lastsearch_values when clicking, 1 = Save lastsearch_values whenclicking - * @return string Chaine avec URL - */ - public function getNomUrl($withpicto = 0, $maxlength = 0, $classname = '', $option = '', $overwritepicto = 0, $notooltip = 0, $save_lastsearch_value = -1) - { - global $conf, $langs, $user, $hookmanager, $action; + /** + * Return URL of event + * Use $this->id, $this->type_code, $this->label and $this->type_label + * + * @param int $withpicto 0 = No picto, 1 = Include picto into link, 2 = Only picto + * @param int $maxlength Max number of charaters into label. If negative, use the ref as label. + * @param string $classname Force style class on a link + * @param string $option '' = Link to action, 'birthday'= Link to contact, 'holiday' = Link to leave + * @param int $overwritepicto 1 = Overwrite picto + * @param int $notooltip 1 = Disable tooltip + * @param int $save_lastsearch_value -1 = Auto, 0 = No save of lastsearch_values when clicking, 1 = Save lastsearch_values whenclicking + * @return string Chaine avec URL + */ + public function getNomUrl($withpicto = 0, $maxlength = 0, $classname = '', $option = '', $overwritepicto = 0, $notooltip = 0, $save_lastsearch_value = -1) + { + global $conf, $langs, $user, $hookmanager, $action; - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $canread = 0; if ($user->rights->agenda->myactions->read && $this->authorid == $user->id) $canread = 1; // Can read my event @@ -1371,10 +1371,10 @@ class ActionComm extends CommonObject if ($user->rights->agenda->allactions->read) $canread = 1; // Can read all event of other if (!$canread) { - $option = 'nolink'; + $option = 'nolink'; } - $label = $this->label; + $label = $this->label; if (empty($label)) $label = $this->libelle; // For backward compatibility $result = ''; @@ -1387,7 +1387,7 @@ class ActionComm extends CommonObject } if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL'); + if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL'); } $tooltip = ''.$langs->trans('Action').''; @@ -1402,22 +1402,22 @@ class ActionComm extends CommonObject if (isset($this->transparency)) $tooltip .= '
'.$langs->trans('Busy').': '.yn($this->transparency); if (!empty($this->note_private)) - $tooltip .= '
'.$langs->trans('Note').': '.(dol_textishtml($this->note_private) ? str_replace(array("\r", "\n"), "", $this->note_private) : str_replace(array("\r", "\n"), '
', $this->note_private)); + $tooltip .= '
'.$langs->trans('Note').': '.(dol_textishtml($this->note_private) ? str_replace(array("\r", "\n"), "", $this->note_private) : str_replace(array("\r", "\n"), '
', $this->note_private)); $linkclose = ''; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) $linkclose = ' style="background-color:#'.$this->type_color.'"'; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowAction"); - $linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1).'"'; - $linkclose .= ' class="'.$classname.' classfortooltip"'; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowAction"); + $linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1).'"'; + $linkclose .= ' class="'.$classname.' classfortooltip"'; - /* + /* $hookmanager->initHooks(array('actiondao')); $parameters=array('id'=>$this->id); $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -1429,7 +1429,7 @@ class ActionComm extends CommonObject if ($option == 'birthday') $url = DOL_URL_ROOT.'/contact/perso.php?id='.$this->id; elseif ($option == 'holiday') - $url = DOL_URL_ROOT.'/holiday/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/holiday/card.php?id='.$this->id; else $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id; if ($option !== 'nolink') { @@ -1448,170 +1448,170 @@ class ActionComm extends CommonObject $linkend = ''; } - if ($withpicto == 2) - { - $libelle = $label; - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle = $labeltype; - $libelleshort = ''; - } else { - $libelle = (empty($this->libelle) ? $label : $this->libelle.(($label && $label != $this->libelle) ? ' '.$label : '')); - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle = $labeltype; - if ($maxlength < 0) $libelleshort = $this->ref; - else $libelleshort = dol_trunc($libelle, $maxlength); - } + if ($withpicto == 2) + { + $libelle = $label; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle = $labeltype; + $libelleshort = ''; + } else { + $libelle = (empty($this->libelle) ? $label : $this->libelle.(($label && $label != $this->libelle) ? ' '.$label : '')); + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle = $labeltype; + if ($maxlength < 0) $libelleshort = $this->ref; + else $libelleshort = dol_trunc($libelle, $maxlength); + } - if ($withpicto) - { - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into () - { - if ($labeltype) - { - $libelle .= (preg_match('/'.preg_quote($labeltype, '/').'/', $libelle) ? '' : ' ('.$langs->transnoentities("Action".$this->type_code).')'); - } - } - } + if ($withpicto) + { + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into () + { + if ($labeltype) + { + $libelle .= (preg_match('/'.preg_quote($labeltype, '/').'/', $libelle) ? '' : ' ('.$langs->transnoentities("Action".$this->type_code).')'); + } + } + } - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$libelle), ($overwritepicto ? $overwritepicto : 'action'), ($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"' : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - $result .= $libelleshort; - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$libelle), ($overwritepicto ? $overwritepicto : 'action'), ($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"' : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= $libelleshort; + $result .= $linkend; - global $action; - $hookmanager->initHooks(array('actiondao')); - $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 $result .= $hookmanager->resPrint; + global $action; + $hookmanager->initHooks(array('actiondao')); + $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 $result .= $hookmanager->resPrint; - return $result; - } + return $result; + } - /** - * Sets object to supplied categories. - * - * Deletes object from existing categories not supplied. - * Adds it to non existing supplied categories. - * Existing categories are left untouch. - * - * @param int[]|int $categories Category or categories IDs - * @return void - */ - public function setCategories($categories) - { - // Handle single category - if (!is_array($categories)) { - $categories = array($categories); - } + /** + * Sets object to supplied categories. + * + * Deletes object from existing categories not supplied. + * Adds it to non existing supplied categories. + * Existing categories are left untouch. + * + * @param int[]|int $categories Category or categories IDs + * @return void + */ + public function setCategories($categories) + { + // Handle single category + if (!is_array($categories)) { + $categories = array($categories); + } - // Get current categories - include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $c = new Categorie($this->db); - $existing = $c->containing($this->id, Categorie::TYPE_ACTIONCOMM, 'id'); + // Get current categories + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $c = new Categorie($this->db); + $existing = $c->containing($this->id, Categorie::TYPE_ACTIONCOMM, 'id'); - // Diff - if (is_array($existing)) { - $to_del = array_diff($existing, $categories); - $to_add = array_diff($categories, $existing); - } else { - $to_del = array(); // Nothing to delete - $to_add = $categories; - } + // Diff + if (is_array($existing)) { + $to_del = array_diff($existing, $categories); + $to_add = array_diff($categories, $existing); + } else { + $to_del = array(); // Nothing to delete + $to_add = $categories; + } - // Process - foreach ($to_del as $del) { - if ($c->fetch($del) > 0) { - $c->del_type($this, Categorie::TYPE_ACTIONCOMM); - } - } - foreach ($to_add as $add) { - if ($c->fetch($add) > 0) { - $c->add_type($this, Categorie::TYPE_ACTIONCOMM); - } - } - return; - } + // Process + foreach ($to_del as $del) { + if ($c->fetch($del) > 0) { + $c->del_type($this, Categorie::TYPE_ACTIONCOMM); + } + } + foreach ($to_add as $add) { + if ($c->fetch($add) > 0) { + $c->add_type($this, Categorie::TYPE_ACTIONCOMM); + } + } + return; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Export events from database into a cal file. - * - * @param string $format The format of the export 'vcal', 'ical/ics' or 'rss' - * @param string $type The type of the export 'event' or 'journal' - * @param integer $cachedelay Do not rebuild file if date older than cachedelay seconds - * @param string $filename The name for the exported file. - * @param array $filters Array of filters. Example array('notolderthan'=>99, 'year'=>..., 'idfrom'=>..., 'notactiontype'=>'systemauto', 'project'=>123, ...) - * @param integer $exportholiday 0 = don't integrate holidays into the export, 1 = integrate holidays into the export - * @return integer -1 = error on build export file, 0 = export okay - */ - public function build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholiday = 0) - { - global $hookmanager; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Export events from database into a cal file. + * + * @param string $format The format of the export 'vcal', 'ical/ics' or 'rss' + * @param string $type The type of the export 'event' or 'journal' + * @param integer $cachedelay Do not rebuild file if date older than cachedelay seconds + * @param string $filename The name for the exported file. + * @param array $filters Array of filters. Example array('notolderthan'=>99, 'year'=>..., 'idfrom'=>..., 'notactiontype'=>'systemauto', 'project'=>123, ...) + * @param integer $exportholiday 0 = don't integrate holidays into the export, 1 = integrate holidays into the export + * @return integer -1 = error on build export file, 0 = export okay + */ + public function build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholiday = 0) + { + global $hookmanager; - // phpcs:enable - global $conf, $langs, $dolibarr_main_url_root, $mysoc; + // phpcs:enable + global $conf, $langs, $dolibarr_main_url_root, $mysoc; - require_once DOL_DOCUMENT_ROOT."/core/lib/xcal.lib.php"; - require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; - require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/xcal.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; - dol_syslog(get_class($this)."::build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG); + dol_syslog(get_class($this)."::build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG); - // Check parameters - if (empty($format)) return -1; + // Check parameters + if (empty($format)) return -1; - // Clean parameters - if (!$filename) - { - $extension = 'vcs'; - if ($format == 'ical') $extension = 'ics'; - $filename = $format.'.'.$extension; - } + // Clean parameters + if (!$filename) + { + $extension = 'vcs'; + if ($format == 'ical') $extension = 'ics'; + $filename = $format.'.'.$extension; + } - // Create dir and define output file (definitive and temporary) - $result = dol_mkdir($conf->agenda->dir_temp); - $outputfile = $conf->agenda->dir_temp.'/'.$filename; + // Create dir and define output file (definitive and temporary) + $result = dol_mkdir($conf->agenda->dir_temp); + $outputfile = $conf->agenda->dir_temp.'/'.$filename; - $result = 0; + $result = 0; - $buildfile = true; - $login = ''; $logina = ''; $logind = ''; $logint = ''; + $buildfile = true; + $login = ''; $logina = ''; $logind = ''; $logint = ''; - $now = dol_now(); + $now = dol_now(); - if ($cachedelay) - { - $nowgmt = dol_now(); - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (dol_filemtime($outputfile) > ($nowgmt - $cachedelay)) - { - dol_syslog(get_class($this)."::build_exportfile file ".$outputfile." is not older than now - cachedelay (".$nowgmt." - ".$cachedelay."). Build is canceled"); - $buildfile = false; - } - } + if ($cachedelay) + { + $nowgmt = dol_now(); + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + if (dol_filemtime($outputfile) > ($nowgmt - $cachedelay)) + { + dol_syslog(get_class($this)."::build_exportfile file ".$outputfile." is not older than now - cachedelay (".$nowgmt." - ".$cachedelay."). Build is canceled"); + $buildfile = false; + } + } - if ($buildfile) - { - // Build event array - $eventarray = array(); + if ($buildfile) + { + // Build event array + $eventarray = array(); - $sql = "SELECT a.id,"; - $sql .= " a.datep,"; // Start - $sql .= " a.datep2,"; // End - $sql .= " a.durationp,"; // deprecated - $sql .= " a.datec, a.tms as datem,"; - $sql .= " a.label, a.code, a.note, a.fk_action as type_id,"; - $sql .= " a.fk_soc,"; - $sql .= " a.fk_user_author, a.fk_user_mod,"; - $sql .= " a.fk_user_action,"; - $sql .= " a.fk_contact, a.percent as percentage,"; - $sql .= " a.fk_element, a.elementtype,"; - $sql .= " a.priority, a.fulldayevent, a.location, a.transparency,"; - $sql .= " u.firstname, u.lastname, u.email,"; - $sql .= " s.nom as socname,"; - $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label"; - $sql .= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; + $sql = "SELECT a.id,"; + $sql .= " a.datep,"; // Start + $sql .= " a.datep2,"; // End + $sql .= " a.durationp,"; // deprecated + $sql .= " a.datec, a.tms as datem,"; + $sql .= " a.label, a.code, a.note, a.fk_action as type_id,"; + $sql .= " a.fk_soc,"; + $sql .= " a.fk_user_author, a.fk_user_mod,"; + $sql .= " a.fk_user_action,"; + $sql .= " a.fk_contact, a.percent as percentage,"; + $sql .= " a.fk_element, a.elementtype,"; + $sql .= " a.priority, a.fulldayevent, a.location, a.transparency,"; + $sql .= " u.firstname, u.lastname, u.email,"; + $sql .= " s.nom as socname,"; + $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label"; + $sql .= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; $parameters = array('filters' => $filters); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook @@ -1620,129 +1620,129 @@ class ActionComm extends CommonObject // We must filter on assignement table if ($filters['logint']) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; $sql .= " WHERE a.fk_action=c.id"; - $sql .= " AND a.entity IN (".getEntity('agenda').")"; - foreach ($filters as $key => $value) - { - if ($key == 'notolderthan' && $value != '') $sql .= " AND a.datep >= '".$this->db->idate($now - ($value * 24 * 60 * 60))."'"; - if ($key == 'year') $sql .= " AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($value, 1))."' AND '".$this->db->idate(dol_get_last_day($value, 12))."'"; - if ($key == 'id') $sql .= " AND a.id=".(is_numeric($value) ? $value : 0); - if ($key == 'idfrom') $sql .= " AND a.id >= ".(is_numeric($value) ? $value : 0); - if ($key == 'idto') $sql .= " AND a.id <= ".(is_numeric($value) ? $value : 0); - if ($key == 'project') $sql .= " AND a.fk_project=".(is_numeric($value) ? $value : 0); - if ($key == 'actiontype') $sql .= " AND c.type = '".$this->db->escape($value)."'"; - if ($key == 'notactiontype') $sql .= " AND c.type <> '".$this->db->escape($value)."'"; - // We must filter on assignement table + $sql .= " AND a.entity IN (".getEntity('agenda').")"; + foreach ($filters as $key => $value) + { + if ($key == 'notolderthan' && $value != '') $sql .= " AND a.datep >= '".$this->db->idate($now - ($value * 24 * 60 * 60))."'"; + if ($key == 'year') $sql .= " AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($value, 1))."' AND '".$this->db->idate(dol_get_last_day($value, 12))."'"; + if ($key == 'id') $sql .= " AND a.id=".(is_numeric($value) ? $value : 0); + if ($key == 'idfrom') $sql .= " AND a.id >= ".(is_numeric($value) ? $value : 0); + if ($key == 'idto') $sql .= " AND a.id <= ".(is_numeric($value) ? $value : 0); + if ($key == 'project') $sql .= " AND a.fk_project=".(is_numeric($value) ? $value : 0); + if ($key == 'actiontype') $sql .= " AND c.type = '".$this->db->escape($value)."'"; + if ($key == 'notactiontype') $sql .= " AND c.type <> '".$this->db->escape($value)."'"; + // We must filter on assignement table if ($key == 'logint') $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; - if ($key == 'logina') - { - $logina = $value; - $condition = '='; - if (preg_match('/^!/', $logina)) - { - $logina = preg_replace('/^!/', '', $logina); - $condition = '<>'; - } - $userforfilter = new User($this->db); - $result = $userforfilter->fetch('', $logina); - if ($result > 0) $sql .= " AND a.fk_user_author ".$condition." ".$userforfilter->id; - elseif ($result < 0 || $condition == '=') $sql .= " AND a.fk_user_author = 0"; - } - if ($key == 'logint') - { - $logint = $value; - $condition = '='; - if (preg_match('/^!/', $logint)) - { - $logint = preg_replace('/^!/', '', $logint); - $condition = '<>'; - } - $userforfilter = new User($this->db); - $result = $userforfilter->fetch('', $logint); - if ($result > 0) $sql .= " AND ar.fk_element = ".$userforfilter->id; - elseif ($result < 0 || $condition == '=') $sql .= " AND ar.fk_element = 0"; - } - } + if ($key == 'logina') + { + $logina = $value; + $condition = '='; + if (preg_match('/^!/', $logina)) + { + $logina = preg_replace('/^!/', '', $logina); + $condition = '<>'; + } + $userforfilter = new User($this->db); + $result = $userforfilter->fetch('', $logina); + if ($result > 0) $sql .= " AND a.fk_user_author ".$condition." ".$userforfilter->id; + elseif ($result < 0 || $condition == '=') $sql .= " AND a.fk_user_author = 0"; + } + if ($key == 'logint') + { + $logint = $value; + $condition = '='; + if (preg_match('/^!/', $logint)) + { + $logint = preg_replace('/^!/', '', $logint); + $condition = '<>'; + } + $userforfilter = new User($this->db); + $result = $userforfilter->fetch('', $logint); + if ($result > 0) $sql .= " AND ar.fk_element = ".$userforfilter->id; + elseif ($result < 0 || $condition == '=') $sql .= " AND ar.fk_element = 0"; + } + } - $sql .= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import + $sql .= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import $parameters = array('filters' => $filters); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; - $sql .= " ORDER by datep"; - //print $sql;exit; + $sql .= " ORDER by datep"; + //print $sql;exit; - dol_syslog(get_class($this)."::build_exportfile select events", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - // Note: Output of sql request is encoded in $conf->file->character_set_client - // This assignment in condition is not a bug. It allows walking the results. + dol_syslog(get_class($this)."::build_exportfile select events", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + // Note: Output of sql request is encoded in $conf->file->character_set_client + // This assignment in condition is not a bug. It allows walking the results. $diff = 0; - while ($obj = $this->db->fetch_object($resql)) - { - $qualified = true; + while ($obj = $this->db->fetch_object($resql)) + { + $qualified = true; - // 'eid','startdate','duration','enddate','title','summary','category','email','url','desc','author' - $event = array(); - $event['uid'] = 'dolibarragenda-'.$this->db->database_name.'-'.$obj->id."@".$_SERVER["SERVER_NAME"]; - $event['type'] = $type; - $datestart = $this->db->jdate($obj->datep) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); + // 'eid','startdate','duration','enddate','title','summary','category','email','url','desc','author' + $event = array(); + $event['uid'] = 'dolibarragenda-'.$this->db->database_name.'-'.$obj->id."@".$_SERVER["SERVER_NAME"]; + $event['type'] = $type; + $datestart = $this->db->jdate($obj->datep) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); - // fix for -> Warning: A non-numeric value encountered - if (is_numeric($this->db->jdate($obj->datep2))) - { - $dateend = $this->db->jdate($obj->datep2) - - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); - } else { - // use start date as fall-back to avoid import erros on empty end date - $dateend = $datestart; - } + // fix for -> Warning: A non-numeric value encountered + if (is_numeric($this->db->jdate($obj->datep2))) + { + $dateend = $this->db->jdate($obj->datep2) + - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); + } else { + // use start date as fall-back to avoid import erros on empty end date + $dateend = $datestart; + } - $duration = ($datestart && $dateend) ? ($dateend - $datestart) : 0; - $event['summary'] = $obj->label.($obj->socname ? " (".$obj->socname.")" : ""); - $event['desc'] = $obj->note; - $event['startdate'] = $datestart; - $event['enddate'] = $dateend; // Not required with type 'journal' - $event['duration'] = $duration; // Not required with type 'journal' - $event['author'] = dolGetFirstLastname($obj->firstname, $obj->lastname); - $event['priority'] = $obj->priority; - $event['fulldayevent'] = $obj->fulldayevent; - $event['location'] = $obj->location; - $event['transparency'] = (($obj->transparency > 0) ? 'OPAQUE' : 'TRANSPARENT'); // OPAQUE (busy) or TRANSPARENT (not busy) - $event['category'] = $obj->type_label; - $event['email'] = $obj->email; + $duration = ($datestart && $dateend) ? ($dateend - $datestart) : 0; + $event['summary'] = $obj->label.($obj->socname ? " (".$obj->socname.")" : ""); + $event['desc'] = $obj->note; + $event['startdate'] = $datestart; + $event['enddate'] = $dateend; // Not required with type 'journal' + $event['duration'] = $duration; // Not required with type 'journal' + $event['author'] = dolGetFirstLastname($obj->firstname, $obj->lastname); + $event['priority'] = $obj->priority; + $event['fulldayevent'] = $obj->fulldayevent; + $event['location'] = $obj->location; + $event['transparency'] = (($obj->transparency > 0) ? 'OPAQUE' : 'TRANSPARENT'); // OPAQUE (busy) or TRANSPARENT (not busy) + $event['category'] = $obj->type_label; + $event['email'] = $obj->email; // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $url = $urlwithroot.'/comm/action/card.php?id='.$obj->id; - $event['url'] = $url; - $event['created'] = $this->db->jdate($obj->datec) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); - $event['modified'] = $this->db->jdate($obj->datem) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); + $url = $urlwithroot.'/comm/action/card.php?id='.$obj->id; + $event['url'] = $url; + $event['created'] = $this->db->jdate($obj->datec) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); + $event['modified'] = $this->db->jdate($obj->datem) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); - // TODO: find a way to call "$this->fetch_userassigned();" without override "$this" properties - $this->id = $obj->id; - $this->fetch_userassigned(false); + // TODO: find a way to call "$this->fetch_userassigned();" without override "$this" properties + $this->id = $obj->id; + $this->fetch_userassigned(false); - $assignedUserArray = array(); + $assignedUserArray = array(); - foreach ($this->userassigned as $key => $value) - { - $assignedUser = new User($this->db); - $assignedUser->fetch($value['id']); + foreach ($this->userassigned as $key => $value) + { + $assignedUser = new User($this->db); + $assignedUser->fetch($value['id']); - $assignedUserArray[$key] = $assignedUser; - } + $assignedUserArray[$key] = $assignedUser; + } - $event['assignedUsers'] = $assignedUserArray; + $event['assignedUsers'] = $assignedUserArray; - if ($qualified && $datestart) - { - $eventarray[] = $event; - } - $diff++; - } + if ($qualified && $datestart) + { + $eventarray[] = $event; + } + $diff++; + } $parameters = array('filters' => $filters, 'eventarray' => &$eventarray); $reshook = $hookmanager->executeHooks('addMoreEventsExport', $parameters); // Note that $action and $object may have been modified by hook @@ -1750,175 +1750,175 @@ class ActionComm extends CommonObject { $eventarray = $hookmanager->resArray; } - } else { - $this->error = $this->db->lasterror(); - return -1; - } + } else { + $this->error = $this->db->lasterror(); + return -1; + } if ($exportholiday == 1) - { - $langs->load("holidays"); - $title = $langs->trans("Holidays"); + { + $langs->load("holidays"); + $title = $langs->trans("Holidays"); - $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.email, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status"; - $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE u.rowid = x.fk_user"; - $sql .= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user) - $sql .= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved) + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.email, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.rowid = x.fk_user"; + $sql .= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user) + $sql .= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved) - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $event = array(); + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $event = array(); - if ($obj->halfday == -1) - { - $event['fulldayevent'] = false; + if ($obj->halfday == -1) + { + $event['fulldayevent'] = false; - $timestampStart = dol_stringtotime($obj->date_start." 00:00:00", 0); - $timestampEnd = dol_stringtotime($obj->date_end." 12:00:00", 0); - } elseif ($obj->halfday == 1) - { - $event['fulldayevent'] = false; + $timestampStart = dol_stringtotime($obj->date_start." 00:00:00", 0); + $timestampEnd = dol_stringtotime($obj->date_end." 12:00:00", 0); + } elseif ($obj->halfday == 1) + { + $event['fulldayevent'] = false; - $timestampStart = dol_stringtotime($obj->date_start." 12:00:00", 0); - $timestampEnd = dol_stringtotime($obj->date_end." 23:59:59", 0); - } else { - $event['fulldayevent'] = true; + $timestampStart = dol_stringtotime($obj->date_start." 12:00:00", 0); + $timestampEnd = dol_stringtotime($obj->date_end." 23:59:59", 0); + } else { + $event['fulldayevent'] = true; - $timestampStart = dol_stringtotime($obj->date_start." 00:00:00", 0); - $timestampEnd = dol_stringtotime($obj->date_end." 23:59:59", 0); - } + $timestampStart = dol_stringtotime($obj->date_start." 00:00:00", 0); + $timestampEnd = dol_stringtotime($obj->date_end." 23:59:59", 0); + } - if (!empty($conf->global->AGENDA_EXPORT_FIX_TZ)) - { - $timestampStart = - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600); - $timestampEnd = - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600); - } + if (!empty($conf->global->AGENDA_EXPORT_FIX_TZ)) + { + $timestampStart = - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600); + $timestampEnd = - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600); + } - $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; - $url = $urlwithroot.'/holiday/card.php?id='.$obj->rowid; + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; + $url = $urlwithroot.'/holiday/card.php?id='.$obj->rowid; - $event['uid'] = 'dolibarrholiday-'.$this->db->database_name.'-'.$obj->rowid."@".$_SERVER["SERVER_NAME"]; - $event['author'] = dolGetFirstLastname($obj->firstname, $obj->lastname); - $event['type'] = 'event'; - $event['category'] = "Holiday"; - $event['transparency'] = 'OPAQUE'; - $event['email'] = $obj->email; - $event['created'] = $timestampStart; - $event['modified'] = $timestampStart; - $event['startdate'] = $timestampStart; - $event['enddate'] = $timestampEnd; - $event['duration'] = $timestampEnd - $timestampStart; - $event['url'] = $url; + $event['uid'] = 'dolibarrholiday-'.$this->db->database_name.'-'.$obj->rowid."@".$_SERVER["SERVER_NAME"]; + $event['author'] = dolGetFirstLastname($obj->firstname, $obj->lastname); + $event['type'] = 'event'; + $event['category'] = "Holiday"; + $event['transparency'] = 'OPAQUE'; + $event['email'] = $obj->email; + $event['created'] = $timestampStart; + $event['modified'] = $timestampStart; + $event['startdate'] = $timestampStart; + $event['enddate'] = $timestampEnd; + $event['duration'] = $timestampEnd - $timestampStart; + $event['url'] = $url; - if ($obj->status == 2) - { - // 2 = leave wait for approval - $event['summary'] = $title." - ".$obj->lastname." (wait for approval)"; - } else { - // 3 = leave approved - $event['summary'] = $title." - ".$obj->lastname; - } + if ($obj->status == 2) + { + // 2 = leave wait for approval + $event['summary'] = $title." - ".$obj->lastname." (wait for approval)"; + } else { + // 3 = leave approved + $event['summary'] = $title." - ".$obj->lastname; + } - $eventarray[] = $event; + $eventarray[] = $event; - $i++; - } - } - } + $i++; + } + } + } - $langs->load("agenda"); + $langs->load("agenda"); - // Define title and desc - $more = ''; - if ($login) $more = $langs->transnoentities("User").' '.$login; - if ($logina) $more = $langs->transnoentities("ActionsAskedBy").' '.$logina; - if ($logint) $more = $langs->transnoentities("ActionsToDoBy").' '.$logint; - if ($logind) $more = $langs->transnoentities("ActionsDoneBy").' '.$logind; - if ($more) - { - $title = 'Dolibarr actions '.$mysoc->name.' - '.$more; - $desc = $more; - $desc .= ' ('.$mysoc->name.' - built by Dolibarr)'; - } else { - $title = 'Dolibarr actions '.$mysoc->name; - $desc = $langs->transnoentities('ListOfActions'); - $desc .= ' ('.$mysoc->name.' - built by Dolibarr)'; - } + // Define title and desc + $more = ''; + if ($login) $more = $langs->transnoentities("User").' '.$login; + if ($logina) $more = $langs->transnoentities("ActionsAskedBy").' '.$logina; + if ($logint) $more = $langs->transnoentities("ActionsToDoBy").' '.$logint; + if ($logind) $more = $langs->transnoentities("ActionsDoneBy").' '.$logind; + if ($more) + { + $title = 'Dolibarr actions '.$mysoc->name.' - '.$more; + $desc = $more; + $desc .= ' ('.$mysoc->name.' - built by Dolibarr)'; + } else { + $title = 'Dolibarr actions '.$mysoc->name; + $desc = $langs->transnoentities('ListOfActions'); + $desc .= ' ('.$mysoc->name.' - built by Dolibarr)'; + } - // Create temp file - $outputfiletmp = tempnam($conf->agenda->dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + // Create temp file + $outputfiletmp = tempnam($conf->agenda->dir_temp, 'tmp'); // Temporary file (allow call of function by different threads + @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); - // Write file - if ($format == 'vcal') $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); - elseif ($format == 'ical') $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); - elseif ($format == 'rss') $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp); + // Write file + if ($format == 'vcal') $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); + elseif ($format == 'ical') $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); + elseif ($format == 'rss') $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp); - if ($result >= 0) - { - if (dol_move($outputfiletmp, $outputfile, 0, 1)) $result = 1; - else { - $this->error = 'Failed to rename '.$outputfiletmp.' into '.$outputfile; - dol_syslog(get_class($this)."::build_exportfile ".$this->error, LOG_ERR); - dol_delete_file($outputfiletmp, 0, 1); - $result = -1; - } - } else { - dol_syslog(get_class($this)."::build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR); - dol_delete_file($outputfiletmp, 0, 1); - $langs->load("errors"); - $this->error = $langs->trans("ErrorFailToCreateFile", $outputfile); - } - } + if ($result >= 0) + { + if (dol_move($outputfiletmp, $outputfile, 0, 1)) $result = 1; + else { + $this->error = 'Failed to rename '.$outputfiletmp.' into '.$outputfile; + dol_syslog(get_class($this)."::build_exportfile ".$this->error, LOG_ERR); + dol_delete_file($outputfiletmp, 0, 1); + $result = -1; + } + } else { + dol_syslog(get_class($this)."::build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR); + dol_delete_file($outputfiletmp, 0, 1); + $langs->load("errors"); + $this->error = $langs->trans("ErrorFailToCreateFile", $outputfile); + } + } - return $result; - } + return $result; + } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return int >0 if ok - */ - public function initAsSpecimen() - { - global $user; + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return int >0 if ok + */ + public function initAsSpecimen() + { + global $user; - $now = dol_now(); + $now = dol_now(); - // Initialise parametres - $this->id = 0; - $this->specimen = 1; + // Initialise parametres + $this->id = 0; + $this->specimen = 1; - $this->type_code = 'AC_OTH'; - $this->code = 'AC_SPECIMEN_CODE'; - $this->label = 'Label of event Specimen'; - $this->datec = $now; - $this->datem = $now; - $this->datep = $now; - $this->datef = $now; - $this->fulldayevent = 0; - $this->percentage = 0; - $this->location = 'Location'; - $this->transparency = 1; // 1 means opaque - $this->priority = 1; - //$this->note_public = "This is a 'public' note."; + $this->type_code = 'AC_OTH'; + $this->code = 'AC_SPECIMEN_CODE'; + $this->label = 'Label of event Specimen'; + $this->datec = $now; + $this->datem = $now; + $this->datep = $now; + $this->datef = $now; + $this->fulldayevent = 0; + $this->percentage = 0; + $this->location = 'Location'; + $this->transparency = 1; // 1 means opaque + $this->priority = 1; + //$this->note_public = "This is a 'public' note."; $this->note_private = "This is a 'private' note."; - $this->userownerid = $user->id; - $this->userassigned[$user->id] = array('id'=>$user->id, 'transparency'=> 1); - return 1; - } + $this->userownerid = $user->id; + $this->userassigned[$user->id] = array('id'=>$user->id, 'transparency'=> 1); + return 1; + } /** * Function used to replace a thirdparty id with another one. diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index b2c38b3e13e..64c24c9c8e8 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -76,7 +76,7 @@ if (!$user->rights->agenda->myactions->read) accessforbidden(); if (!$user->rights->agenda->allactions->read) $canedit = 0; if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me { - $filtert = $user->id; + $filtert = $user->id; } $action = GETPOST('action', 'alpha'); @@ -91,19 +91,19 @@ $type = GETPOST("search_type", 'aZ09') ?GETPOST("search_type", 'aZ09') : GETPOST $maxprint = (isset($_GET["maxprint"]) ?GETPOST("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); +$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); if ($dateselect > 0) { - $day=GETPOST('dateselectday', 'int'); - $month=GETPOST('dateselectmonth', 'int'); - $year=GETPOST('dateselectyear', 'int'); + $day = GETPOST('dateselectday', 'int'); + $month = GETPOST('dateselectmonth', 'int'); + $year = GETPOST('dateselectyear', 'int'); } // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } @@ -119,13 +119,13 @@ if ($action == 'default') // When action is default, we want a calendar view and $action = (($defaultview != 'show_list') ? $defaultview : 'show_month'); } if (GETPOST('viewcal', 'none') && GETPOST('action', 'alpha') != 'show_day' && GETPOST('action', 'alpha') != 'show_week') { - $action = 'show_month'; $day = ''; + $action = 'show_month'; $day = ''; } // View by month if (GETPOST('viewweek', 'none') || GETPOST('action', 'alpha') == 'show_week') { - $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); + $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); } // View by week if (GETPOST('viewday', 'none') || GETPOST('action', 'alpha') == 'show_day') { - $action = 'show_day'; $day = ($day ? $day : date("d")); + $action = 'show_day'; $day = ($day ? $day : date("d")); } // View by day // Load translation files required by the page @@ -141,46 +141,46 @@ $hookmanager->initHooks(array('agenda')); if (GETPOST("viewlist", 'alpha') || $action == 'show_list') { - $param = ''; - if (is_array($_POST)) - { - foreach ($_POST as $key => $val) - { - if ($key == 'token') continue; - $param .= '&'.$key.'='.urlencode($val); - } - } - if (! preg_match('/action=/', $param)) $param .= ($param ? '&' : '').'action=show_list'; - //print $param; - header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param); - exit; + $param = ''; + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + if ($key == 'token') continue; + $param .= '&'.$key.'='.urlencode($val); + } + } + if (! preg_match('/action=/', $param)) $param .= ($param ? '&' : '').'action=show_list'; + //print $param; + header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param); + exit; } if (GETPOST("viewperuser", 'alpha') || $action == 'show_peruser') { - $param = ''; - if (is_array($_POST)) - { - foreach ($_POST as $key => $val) - { - if ($key == 'token') continue; - $param .= '&'.$key.'='.urlencode($val); - } - } - //print $param; - header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param); - exit; + $param = ''; + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + if ($key == 'token') continue; + $param .= '&'.$key.'='.urlencode($val); + } + } + //print $param; + header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param); + exit; } if ($action == 'delete_action') { - $event = new ActionComm($db); - $event->fetch($actionid); - $event->fetch_optionals(); - $event->fetch_userassigned(); - $event->oldcopy = clone $event; + $event = new ActionComm($db); + $event->fetch($actionid); + $event->fetch_optionals(); + $event->fetch_userassigned(); + $event->oldcopy = clone $event; - $result = $event->delete(); + $result = $event->delete(); } @@ -226,21 +226,21 @@ $listofextcals = array(); // Define list of external calendars (global admin setup) if (empty($conf->global->AGENDA_DISABLE_EXT)) { - $i = 0; - while ($i < $MAXAGENDA) - { - $i++; - $source = 'AGENDA_EXT_SRC'.$i; - $name = 'AGENDA_EXT_NAME'.$i; - $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i; - $color = 'AGENDA_EXT_COLOR'.$i; - $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i; - if (!empty($conf->global->$source) && !empty($conf->global->$name)) - { - // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' - $listofextcals[] = array('src'=>$conf->global->$source, 'name'=>$conf->global->$name, 'offsettz'=>$conf->global->$offsettz, 'color'=>$conf->global->$color, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0)); - } - } + $i = 0; + while ($i < $MAXAGENDA) + { + $i++; + $source = 'AGENDA_EXT_SRC'.$i; + $name = 'AGENDA_EXT_NAME'.$i; + $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i; + $color = 'AGENDA_EXT_COLOR'.$i; + $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i; + if (!empty($conf->global->$source) && !empty($conf->global->$name)) + { + // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' + $listofextcals[] = array('src'=>$conf->global->$source, 'name'=>$conf->global->$name, 'offsettz'=>$conf->global->$offsettz, 'color'=>$conf->global->$color, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0)); + } + } } // Define list of external calendars (user setup) if (empty($user->conf->AGENDA_DISABLE_EXT)) @@ -251,7 +251,7 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) $i++; $source = 'AGENDA_EXT_SRC_'.$user->id.'_'.$i; $name = 'AGENDA_EXT_NAME_'.$user->id.'_'.$i; - $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; + $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; $color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i; $enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i; $buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i; @@ -265,65 +265,65 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) if (empty($action) || $action == 'show_month') { - $prev = dol_get_prev_month($month, $year); - $prev_year = $prev['year']; - $prev_month = $prev['month']; - $next = dol_get_next_month($month, $year); - $next_year = $next['year']; - $next_month = $next['month']; + $prev = dol_get_prev_month($month, $year); + $prev_year = $prev['year']; + $prev_month = $prev['month']; + $next = dol_get_next_month($month, $year); + $next_year = $next['year']; + $next_month = $next['month']; - $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month - $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month - // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) - $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday - $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1); - if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. - // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year); - $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7; - if ($next_day < 6) $next_day += 7; - $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); + $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month + $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month + // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) + $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday + $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1); + if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. + // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) + $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year); + $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7; + if ($next_day < 6) $next_day += 7; + $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); } if ($action == 'show_week') { - $prev = dol_get_first_day_week($day, $month, $year); - $prev_year = $prev['prev_year']; - $prev_month = $prev['prev_month']; - $prev_day = $prev['prev_day']; - $first_day = $prev['first_day']; - $first_month = $prev['first_month']; - $first_year = $prev['first_year']; + $prev = dol_get_first_day_week($day, $month, $year); + $prev_year = $prev['prev_year']; + $prev_month = $prev['prev_month']; + $prev_day = $prev['prev_day']; + $first_day = $prev['first_day']; + $first_month = $prev['first_month']; + $first_year = $prev['first_year']; - $week = $prev['week']; + $week = $prev['week']; - $day = (int) $day; - $next = dol_get_next_week($first_day, $week, $first_month, $first_year); - $next_year = $next['year']; - $next_month = $next['month']; - $next_day = $next['day']; + $day = (int) $day; + $next = dol_get_next_week($first_day, $week, $first_month, $first_year); + $next_year = $next['year']; + $next_month = $next['month']; + $next_day = $next['day']; - // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); + // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) + $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); - $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); + $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); - $tmpday = $first_day; + $tmpday = $first_day; } if ($action == 'show_day') { - $prev = dol_get_prev_day($day, $month, $year); - $prev_year = $prev['year']; - $prev_month = $prev['month']; - $prev_day = $prev['day']; - $next = dol_get_next_day($day, $month, $year); - $next_year = $next['year']; - $next_month = $next['month']; - $next_day = $next['day']; + $prev = dol_get_prev_day($day, $month, $year); + $prev_year = $prev['year']; + $prev_month = $prev['month']; + $prev_day = $prev['day']; + $next = dol_get_next_day($day, $month, $year); + $next_year = $next['year']; + $next_month = $next['month']; + $next_day = $next['day']; - // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year); - $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); + // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) + $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year); + $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); } //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day; //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; @@ -356,30 +356,30 @@ $param .= "&maxprint=".urlencode($maxprint); // Show navigation bar if (empty($action) || $action == 'show_month') { - $nav = "  \n"; - $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y"); - $nav .= " \n"; - $nav .= "   \n"; - $nav .= "   ".$langs->trans("Today")." "; - $picto = 'calendar'; + $nav = "  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y"); + $nav .= " \n"; + $nav .= "   \n"; + $nav .= "   ".$langs->trans("Today")." "; + $picto = 'calendar'; } if ($action == 'show_week') { - $nav = "trans("Previous"))."\">  \n"; - $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week; - $nav .= " \n"; - $nav .= "   trans("Next"))."\">\n"; - $nav .= "   ".$langs->trans("Today")." "; - $picto = 'calendarweek'; + $nav = "trans("Previous"))."\">  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week; + $nav .= " \n"; + $nav .= "   trans("Next"))."\">\n"; + $nav .= "   ".$langs->trans("Today")." "; + $picto = 'calendarweek'; } if ($action == 'show_day') { - $nav = "  \n"; - $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort"); - $nav .= " \n"; - $nav .= "   \n"; - $nav .= "   ".$langs->trans("Today")." "; - $picto = 'calendarday'; + $nav = "  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort"); + $nav .= " \n"; + $nav .= "   \n"; + $nav .= "   ".$langs->trans("Today")." "; + $picto = 'calendarday'; } $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); @@ -471,21 +471,21 @@ if (!empty($conf->use_javascript_ajax)) // If javascript on $s .= 'jQuery(".family_birthday").toggle();'."\n"; if ($action == "show_week" || $action == "show_month" || empty($action)) { - // Code to enable drag and drop + // Code to enable drag and drop $s .= 'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'."\n"; - // Code to submit form + // Code to submit form $s .= 'console.log("submit form to record new event");'."\n"; - //$s.='console.log(event.target);'; + //$s.='console.log(event.target);'; $s .= 'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'."\n"; $s .= 'console.log("found parent div.dayevent with id = "+newval);'."\n"; $s .= 'var frm=jQuery("#searchFormList");'."\n"; $s .= 'var newurl = ui.item.find("a.cal_event").attr("href");'."\n"; $s .= 'console.log(newurl);'."\n"; $s .= 'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'."\n"; - $s .= '});'."\n"; - } - $s .= '});'."\n"; - $s .= ''."\n"; + $s .= '});'."\n"; + } + $s .= '});'."\n"; + $s .= ''."\n"; // Local calendar $s .= '
'.$langs->trans("LocalAgenda").'  
'; @@ -513,26 +513,26 @@ if (!empty($conf->use_javascript_ajax)) // If javascript on $s .= '
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) - { - $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) + if (empty($reshook)) { - $s = $hookmanager->resPrint; - } + $s .= $hookmanager->resPrint; + } elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } } else // If javascript off { $newparam = $param; // newparam is for birthday links - $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam); - if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1'; - $link = ''; - if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents"); - else $link .= $langs->trans("AgendaHideBirthdayEvents"); - $link .= ''; + $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam); + if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1'; + $link = ''; + if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents"); + else $link .= $langs->trans("AgendaHideBirthdayEvents"); + $link .= ''; } // Load events from database into $eventarray @@ -561,26 +561,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode if (!empty($actioncode)) { - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; - } - } else { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if (is_array($actioncode)) - { - $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; - } else { - $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; - } - } - } + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else { + if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; + } + } else { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else { + if (is_array($actioncode)) + { + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; + } else { + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + } + } + } } if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); @@ -590,28 +590,28 @@ if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($action == 'show_day') { - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= ')'; + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= ')'; } else { - // To limit array - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31 - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; - $sql .= ')'; + // To limit array + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31 + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; + $sql .= ')'; } if ($type) $sql .= " AND ca.id = ".$type; if ($status == '0') { $sql .= " AND a.percent = 0"; } @@ -622,10 +622,10 @@ if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; - $sql .= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // Sort on date $sql .= ' ORDER BY datep'; @@ -1090,8 +1090,8 @@ if (count($listofextcals)) // Transparency (see https://www.kanzaki.com/docs/ical/transp.html) if ($icalevent['TRANSP']) { - if ($icalevent['TRANSP'] == "TRANSPARENT") $event->transparency = 0; // 0 = available / free - if ($icalevent['TRANSP'] == "OPAQUE") $event->transparency = 1; // 1 = busy + if ($icalevent['TRANSP'] == "TRANSPARENT") $event->transparency = 0; // 0 = available / free + if ($icalevent['TRANSP'] == "OPAQUE") $event->transparency = 1; // 1 = busy // TODO: MS outlook states // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:TRANSPARENT => Available / Free @@ -1156,12 +1156,12 @@ if (count($listofextcals)) $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('getCalendarEvents', $parameters, $object, $action); if (!empty($hookmanager->resArray['eventarray'])) { - foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) { - if (!isset($eventarray[$keyDate])) { - $eventarray[$keyDate] = array(); - } - $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events); - } + foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) { + if (!isset($eventarray[$keyDate])) { + $eventarray[$keyDate] = array(); + } + $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events); + } } // Sort events @@ -1180,7 +1180,7 @@ $cacheusers = array(); $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; if (is_readable($color_file)) { - include_once $color_file; + include_once $color_file; } if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); @@ -1384,39 +1384,39 @@ if (empty($action) || $action == 'show_month') // View by month echo " \n"; */ - echo ''; + echo ''; print ''; - /* WIP View per hour */ - $useviewhour = 0; - if ($useviewhour) - { - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + /* WIP View per hour */ + $useviewhour = 0; + if ($useviewhour) + { + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - $maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file + $maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file - echo '
'; + echo '
'; echo '
'; - $maxnbofchar = 80; + $maxnbofchar = 80; - $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS); - $minhour = round($tmp[0], 0); - $maxhour = round($tmp[1], 0); - if ($minhour > 23) $minhour = 23; - if ($maxhour < 1) $maxhour = 1; - if ($maxhour <= $minhour) { $maxhour = $minhour + 1; } + $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS); + $minhour = round($tmp[0], 0); + $maxhour = round($tmp[1], 0); + if ($minhour > 23) $minhour = 23; + if ($maxhour < 1) $maxhour = 1; + if ($maxhour <= $minhour) { $maxhour = $minhour + 1; } - $i = 0; - $j = 0; + $i = 0; + $j = 0; while ($i < 24) { - echo '
'."\n"; - echo '
'.dol_print_date($i * 3600, 'hour', 'gmt').'
'; - echo '
'."\n"; - echo '
'."\n"; - $i++; - $j++; + echo '
'."\n"; + echo '
'.dol_print_date($i * 3600, 'hour', 'gmt').'
'; + echo '
'."\n"; + echo '
'."\n"; + $i++; + $j++; } echo '
'; @@ -1424,13 +1424,13 @@ if (empty($action) || $action == 'show_month') // View by month show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1); print '
'; - } else { - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + } else { + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0); + show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0); - print '
'; - } + print '
'; + } } print "\n".''; @@ -1871,11 +1871,11 @@ function dol_color_minus($color, $minus, $minusunit = 16) $newcolor = $color; if ($minusunit == 16) { - $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0)); - $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0)); - $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0)); + $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0)); + $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0)); + $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0)); } else { - // Not yet implemented + // Not yet implemented } return $newcolor; } @@ -1890,39 +1890,39 @@ function dol_color_minus($color, $minus, $minusunit = 16) function sort_events_by_date($a, $b) { // Sort holidays at first - if ($a->type_code === 'HOLIDAY') - { - return -1; - } + if ($a->type_code === 'HOLIDAY') + { + return -1; + } - if ($b->type_code === 'HOLIDAY') - { - return 1; - } + if ($b->type_code === 'HOLIDAY') + { + return 1; + } - // datep => Event start time - // datef => Event end time + // datep => Event start time + // datef => Event end time - // Events have different start time - if ($a->datep !== $b->datep) - { - return $a->datep - $b->datep; - } + // Events have different start time + if ($a->datep !== $b->datep) + { + return $a->datep - $b->datep; + } - // Events have same start time and no end time - if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) - { - return sort_events_by_percentage($a, $b); - } + // Events have same start time and no end time + if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) + { + return sort_events_by_percentage($a, $b); + } - // Events have the same start time and same end time - if ($b->datef === $a->datef) - { - return sort_events_by_percentage($a, $b); - } + // Events have the same start time and same end time + if ($b->datef === $a->datef) + { + return sort_events_by_percentage($a, $b); + } - // Events have the same start time, but have different end time -> longest event first - return $b->datef - $a->datef; + // Events have the same start time, but have different end time -> longest event first + return $b->datef - $a->datef; } /** @@ -1934,18 +1934,18 @@ function sort_events_by_date($a, $b) */ function sort_events_by_percentage($a, $b) { - // Sort events with no percentage before each other - // (usefull to sort holidays, sick days or similar on the top) + // Sort events with no percentage before each other + // (usefull to sort holidays, sick days or similar on the top) - if ($a->percentage < 0) - { - return -1; - } + if ($a->percentage < 0) + { + return -1; + } - if ($b->percentage < 0) - { - return 1; - } + if ($b->percentage < 0) + { + return 1; + } - return $b->percentage - $a->percentage; + return $b->percentage - $a->percentage; } diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 31274bee5fd..20ba2928de1 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -160,7 +160,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); if (GETPOST('cancel', 'alpha')) { - $action='list'; $massaction=''; + $action = 'list'; $massaction = ''; } if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) @@ -708,7 +708,7 @@ if ($resql) $labeltype = $langs->trans("Message"); } else { if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; - if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code + if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code } print dol_trunc($labeltype, 28); print ''; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index a313f47cc13..eb11950304f 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -159,8 +159,8 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters); $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, "; - $sql.= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, "; + $sql .= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; // Add Group from hooks $parameters = array(); diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 4ec2b5d3443..6349660c59c 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -81,38 +81,38 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($action == 'confirm_delete') - { - $res = $object->delete($user); - if ($res > 0) - { - if ($object->type == 'bank-transfer') { - header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php'); - } else { - header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php'); - } - exit; - } - } + if ($action == 'confirm_delete') + { + $res = $object->delete($user); + if ($res > 0) + { + if ($object->type == 'bank-transfer') { + header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php'); + } else { + header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php'); + } + exit; + } + } - // Seems to no be used and replaced with $action == 'infocredit' - if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes') - { - $res = $object->set_credite(); - if ($res >= 0) - { - header("Location: card.php?id=".$id); - exit; - } - } + // Seems to no be used and replaced with $action == 'infocredit' + if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes') + { + $res = $object->set_credite(); + if ($res >= 0) + { + header("Location: card.php?id=".$id); + exit; + } + } - if ($action == 'infotrans' && $user->rights->prelevement->bons->send) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + if ($action == 'infotrans' && $user->rights->prelevement->bons->send) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - /* + /* if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref) { $dir = $conf->prelevement->dir_output.'/receipts'; @@ -133,24 +133,24 @@ if (empty($reshook)) $error = $object->set_infotrans($user, $dt, GETPOST('methode', 'alpha')); - if ($error) - { - header("Location: card.php?id=".$id."&error=$error"); - exit; - } - } + if ($error) + { + header("Location: card.php?id=".$id."&error=$error"); + exit; + } + } // Set direct debit order to credited, create payment and close invoices if ($action == 'infocredit' && $user->rights->prelevement->bons->credit) { $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $error = $object->set_infocredit($user, $dt); - if ($error) - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + $error = $object->set_infocredit($user, $dt); + if ($error) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 1bea234abfc..567a1ab8951 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -318,7 +318,7 @@ class BonPrelevement extends CommonObject $this->type = $obj->type; $this->status = $obj->status; - $this->statut = $obj->status; // For backward compatibility + $this->statut = $obj->status; // For backward compatibility $this->fetched = 1; @@ -510,7 +510,7 @@ class BonPrelevement extends CommonObject $paiement->num_paiement = $this->ref; // For backward compatibility $paiement->id_prelevement = $this->id; - $paiement_id = $paiement->create($user); // This use ->paiementid, that is ID of payment mode + $paiement_id = $paiement->create($user); // This use ->paiementid, that is ID of payment mode if ($paiement_id < 0) { $error++; @@ -540,7 +540,7 @@ class BonPrelevement extends CommonObject // Update withdrawal line // TODO: Translate to ligneprelevement.class.php - if (! $error) { + if (!$error) { $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes"; $sql .= " SET statut = 2"; $sql .= " WHERE fk_prelevement_bons = ".$this->id; @@ -884,7 +884,7 @@ class BonPrelevement extends CommonObject $sql .= " AND f.rowid = pfd.fk_facture_fourn"; } $sql .= " AND s.rowid = f.fk_soc"; - $sql .= " AND f.fk_statut = 1"; // Invoice validated + $sql .= " AND f.fk_statut = 1"; // Invoice validated $sql .= " AND f.paye = 0"; $sql .= " AND pfd.traite = 0"; $sql .= " AND f.total_ttc > 0"; @@ -1179,7 +1179,7 @@ class BonPrelevement extends CommonObject /* * Update total defined after generation of file */ - if (! $error) { + if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; $sql .= " SET amount = ".price2num($this->total); $sql .= " WHERE rowid = ".$this->id; @@ -1542,7 +1542,7 @@ class BonPrelevement extends CommonObject { $obj = $this->db->fetch_object($resql); - if (! empty($cachearraytotestduplicate[$obj->idfac])) { + if (!empty($cachearraytotestduplicate[$obj->idfac])) { $this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid); $this->invoice_in_error[$obj->idfac] = $this->error; $result = -2; @@ -1657,7 +1657,7 @@ class BonPrelevement extends CommonObject { $obj = $this->db->fetch_object($resql); - if (! empty($cachearraytotestduplicate[$obj->idfac])) { + if (!empty($cachearraytotestduplicate[$obj->idfac])) { $this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid); $this->invoice_in_error[$obj->idfac] = $this->error; $result = -2; @@ -2192,7 +2192,7 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ - $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV + $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2254,7 +2254,7 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ - $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV + $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV /*$XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index f8d67de48c2..842b8b169f5 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -84,10 +84,10 @@ if (empty($reshook)) $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS; } $bprev = new BonPrelevement($db); - $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int')); + $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int')); - // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore) - $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type); + // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore) + $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type); if ($result < 0) { setEventMessages($bprev->error, $bprev->errors, 'errors'); } elseif ($result == 0) { @@ -188,30 +188,30 @@ print '
'; print ''; print ''; if ($nb) { - if ($pricetowithdraw) { - print $langs->trans('ExecutionDate').' '; - $datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - print $form->selectDate($datere, 're'); + if ($pricetowithdraw) { + print $langs->trans('ExecutionDate').' '; + $datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + print $form->selectDate($datere, 're'); - if ($mysoc->isInEEC()) { - $title = $langs->trans("CreateForSepa"); - if ($type == 'bank-transfer') { - $title = $langs->trans("CreateSepaFileForPaymentByBankTransfer"); - } + if ($mysoc->isInEEC()) { + $title = $langs->trans("CreateForSepa"); + if ($type == 'bank-transfer') { + $title = $langs->trans("CreateSepaFileForPaymentByBankTransfer"); + } - if ($type != 'bank-transfer') { - print ''; - } - print ''; - } else { - $title = $langs->trans("CreateAll"); - if ($type == 'bank-transfer') { - $title = $langs->trans("CreateFileForPaymentByBankTransfer"); - } - print ''.$title."\n"; + if ($type != 'bank-transfer') { + print ''; + } + print ''; + } else { + $title = $langs->trans("CreateAll"); + if ($type == 'bank-transfer') { + $title = $langs->trans("CreateFileForPaymentByBankTransfer"); + } + print ''.$title."\n"; } } else { if ($mysoc->isInEEC()) @@ -301,12 +301,12 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - $param = ''; + $param = ''; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($socid) $param .= '&socid='.urlencode($socid); - if ($option) $param .= "&option=".urlencode($option); + if ($option) $param .= "&option=".urlencode($option); - print ''; + print ''; print ''; print ''; if (!empty($limit)) { @@ -317,12 +317,12 @@ if ($resql) if ($type == 'bank-transfer') { $title = $langs->trans("InvoiceWaitingPaymentByBankTransfer"); } - print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit); + print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit); - $tradinvoice = "Invoice"; - if ($type == 'bank-transfer') { - $tradinvoice = "SupplierInvoice"; - } + $tradinvoice = "Invoice"; + if ($type == 'bank-transfer') { + $tradinvoice = "SupplierInvoice"; + } print ''; print ''; diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index fcdb2f01404..c4cb6f0c7c4 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -82,8 +82,8 @@ llxHeader('', $langs->trans("WithdrawalsReceipts")); if ($id > 0 || $ref) { if ($object->fetch($id, $ref) >= 0) - { - $head = prelevement_prepare_head($object); + { + $head = prelevement_prepare_head($object); dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); $linkback = ''.$langs->trans("BackToList").''; @@ -151,9 +151,9 @@ if ($id > 0 || $ref) print ''; dol_fiche_end(); - } else { - dol_print_error($db); - } + } else { + dol_print_error($db); + } } @@ -191,13 +191,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -212,13 +212,13 @@ if ($resql) // Lines of title fields print ''; - if ($optioncss != '') print ''; + if ($optioncss != '') print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -245,38 +245,38 @@ if ($resql) $invoicetmpsupplier = new FactureFournisseur($db); while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($resql); + { + $obj = $db->fetch_object($resql); - if ($obj->type == 'bank-transfer') { - $invoicetmp = $invoicetmpsupplier; - } else { - $invoicetmp = $invoicetmpcustomer; - } - $invoicetmp->fetch($obj->facid); + if ($obj->type == 'bank-transfer') { + $invoicetmp = $invoicetmpsupplier; + } else { + $invoicetmp = $invoicetmpcustomer; + } + $invoicetmp->fetch($obj->facid); - $thirdpartytmp->fetch($obj->socid); + $thirdpartytmp->fetch($obj->socid); - print ''; + print ''; - print "\n"; + print "\n"; - print '\n"; + print '\n"; - // Amount of invoice - print '\n"; + // Amount of invoice + print '\n"; - // Amount requested - print '\n"; + // Amount requested + print '\n"; - // Status of requests - print '"; + print ""; - print ""; + print ""; - print "\n"; + print "\n"; - $totalinvoices += $obj->total_ttc; - $totalamount_requested += $obj->amount_requested; + $totalinvoices += $obj->total_ttc; + $totalamount_requested += $obj->amount_requested; - $i++; - } + $i++; + } if ($num > 0) - { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print '\n"; - print '\n"; - print ''; - print ''; - print "\n"; - } + print "\n"; + print ''; + print ''; + print "\n"; + } print "
"; - print $invoicetmp->getNomUrl(1); - print ""; + print $invoicetmp->getNomUrl(1); + print "'; - print $thirdpartytmp->getNomUrl(1); - print "'; + print $thirdpartytmp->getNomUrl(1); + print "'.price($obj->total_ttc)."'.price($obj->total_ttc)."'.price($obj->amount_requested)."'.price($obj->amount_requested)."'; + // Status of requests + print ''; - if ($obj->statut == 0) { + if ($obj->statut == 0) { print '-'; } elseif ($obj->statut == 2) { if ($obj->type == 'bank-transfer') { @@ -288,34 +288,34 @@ if ($resql) print ''.$langs->trans("StatusRefused").''; } - print "
'.$langs->trans("Total").' '; + { + print '
'.$langs->trans("Total").' '; //if ($totalinvoices != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); // It is normal to have total that differs. For an amount of invoice of 100, request to pay may be 50 only. - if ($totalamount_requested != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); + if ($totalamount_requested != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); print "'; + print ''; print price($totalamount_requested); - print "  
  
"; print '
'; diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index bddebaedda5..2cfc40bb30c 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -76,8 +76,8 @@ llxHeader('', $langs->trans("WithdrawalsReceipts")); if ($prev_id > 0 || $ref) { if ($object->fetch($prev_id, $ref) >= 0) - { - $head = prelevement_prepare_head($object); + { + $head = prelevement_prepare_head($object); dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); $linkback = ''.$langs->trans("BackToList").''; @@ -145,9 +145,9 @@ if ($prev_id > 0 || $ref) print '
'; dol_fiche_end(); - } else { - dol_print_error($db); - } + } else { + dol_print_error($db); + } } @@ -205,44 +205,44 @@ if ($resql) if ($num > 0) { - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); - print ''; + print ''; - print ''; - print img_picto('', 'statut'.$obj->statut).' '; - print substr('000000'.$obj->rowid, -6); - print ''; - print ''.$obj->name."\n"; + print ''; + print img_picto('', 'statut'.$obj->statut).' '; + print substr('000000'.$obj->rowid, -6); + print ''; + print ''.$obj->name."\n"; - print ''.price($obj->amount)."\n"; - print ''.$rej->motifs[$obj->motif].''; + print ''.price($obj->amount)."\n"; + print ''.$rej->motifs[$obj->motif].''; - print ''.yn($obj->afacturer).''; - print ''.$obj->fk_facture.''; - print "\n"; + print ''.yn($obj->afacturer).''; + print ''.$obj->fk_facture.''; + print "\n"; - $total += $obj->amount; + $total += $obj->amount; - $i++; - } + $i++; + } } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } if ($num > 0) - { - print ' '; - print ''.$langs->trans("Total").''; - print ''.price($total)."\n"; - print ' '; - print "\n"; - } - print "\n"; - print ''; + { + print ' '; + print ''.$langs->trans("Total").''; + print ''.price($total)."\n"; + print ' '; + print "\n"; + } + print "\n"; + print ''; $db->free($resql); } else { diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 97ae42c3122..0331861ea03 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -71,9 +71,9 @@ $objcanvas = null; $canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas")); if (!empty($canvas)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db, $action); - $objcanvas->getCanvas('contact', 'contactcard', $canvas); + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('contact', 'contactcard', $canvas); } // Security check @@ -102,45 +102,45 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } // Creation utilisateur depuis contact - if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) - { - // Recuperation contact actuel - $result = $object->fetch($id); + if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) + { + // Recuperation contact actuel + $result = $object->fetch($id); - if ($result > 0) - { - $db->begin(); + if ($result > 0) + { + $db->begin(); - // Creation user - $nuser = new User($db); - $result = $nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha) + // Creation user + $nuser = new User($db); + $result = $nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha) - if ($result > 0) - { - $result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha) - if ($result2) - { - $db->commit(); - } else { - $error = $nuser->error; $errors = $nuser->errors; - $db->rollback(); - } - } else { - $error = $nuser->error; $errors = $nuser->errors; - $db->rollback(); - } - } else { - $error = $object->error; $errors = $object->errors; - } - } + if ($result > 0) + { + $result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha) + if ($result2) + { + $db->commit(); + } else { + $error = $nuser->error; $errors = $nuser->errors; + $db->rollback(); + } + } else { + $error = $nuser->error; $errors = $nuser->errors; + $db->rollback(); + } + } else { + $error = $object->error; $errors = $object->errors; + } + } // Confirmation desactivation @@ -174,50 +174,50 @@ if (empty($reshook)) { $db->begin(); - if ($canvas) $object->canvas = $canvas; + if ($canvas) $object->canvas = $canvas; - $object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity); - $object->socid = GETPOST("socid", 'int'); - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); + $object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity); + $object->socid = GETPOST("socid", 'int'); + $object->lastname = GETPOST("lastname", 'alpha'); + $object->firstname = GETPOST("firstname", 'alpha'); $object->civility_code = GETPOST("civility_code", 'alpha'); - $object->poste = GETPOST("poste", 'alpha'); - $object->address = GETPOST("address", 'alpha'); - $object->zip = GETPOST("zipcode", 'alpha'); - $object->town = GETPOST("town", 'alpha'); - $object->country_id = GETPOST("country_id", 'int'); - $object->state_id = GETPOST("state_id", 'int'); - //$object->jabberid = GETPOST("jabberid", 'alpha'); - //$object->skype = GETPOST("skype", 'alpha'); - //$object->twitter = GETPOST("twitter", 'alpha'); - //$object->facebook = GETPOST("facebook", 'alpha'); - //$object->linkedin = GETPOST("linkedin", 'alpha'); - $object->socialnetworks = array(); - if (!empty($conf->socialnetworks->enabled)) { - foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { - $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); - } - } - } - $object->email = GETPOST("email", 'alpha'); - $object->no_email = GETPOST("no_email", "int"); - $object->phone_pro = GETPOST("phone_pro", 'alpha'); - $object->phone_perso = GETPOST("phone_perso", 'alpha'); - $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); - $object->fax = GETPOST("fax", 'alpha'); - $object->priv = GETPOST("priv", 'int'); - $object->note_public = GETPOST("note_public", 'none'); - $object->note_private = GETPOST("note_private", 'none'); - $object->roles = GETPOST("roles", 'array'); + $object->poste = GETPOST("poste", 'alpha'); + $object->address = GETPOST("address", 'alpha'); + $object->zip = GETPOST("zipcode", 'alpha'); + $object->town = GETPOST("town", 'alpha'); + $object->country_id = GETPOST("country_id", 'int'); + $object->state_id = GETPOST("state_id", 'int'); + //$object->jabberid = GETPOST("jabberid", 'alpha'); + //$object->skype = GETPOST("skype", 'alpha'); + //$object->twitter = GETPOST("twitter", 'alpha'); + //$object->facebook = GETPOST("facebook", 'alpha'); + //$object->linkedin = GETPOST("linkedin", 'alpha'); + $object->socialnetworks = array(); + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } + } + $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); + $object->phone_pro = GETPOST("phone_pro", 'alpha'); + $object->phone_perso = GETPOST("phone_perso", 'alpha'); + $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); + $object->fax = GETPOST("fax", 'alpha'); + $object->priv = GETPOST("priv", 'int'); + $object->note_public = GETPOST("note_public", 'none'); + $object->note_private = GETPOST("note_private", 'none'); + $object->roles = GETPOST("roles", 'array'); - $object->statut = 1; //Defult status to Actif + $object->statut = 1; //Defult status to Actif - // Note: Correct date should be completed with location to have exact GM time of birth. - $object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth", 'int'), GETPOST("birthdayday", 'int'), GETPOST("birthdayyear", 'int')); - $object->birthday_alert = GETPOST("birthday_alert", 'alpha'); + // Note: Correct date should be completed with location to have exact GM time of birth. + $object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth", 'int'), GETPOST("birthdayday", 'int'), GETPOST("birthdayyear", 'int')); + $object->birthday_alert = GETPOST("birthday_alert", 'alpha'); - // Fill array 'array_options' with data from add form + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { @@ -225,19 +225,19 @@ if (empty($reshook)) $action = 'create'; } - if (!GETPOST("lastname")) - { - $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); - $action = 'create'; - } + if (!GETPOST("lastname")) + { + $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); + $action = 'create'; + } - if (!$error) - { - $id = $object->create($user); - if ($id <= 0) - { - $error++; $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); - $action = 'create'; + if (!$error) + { + $id = $object->create($user); + if ($id <= 0) + { + $error++; $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); + $action = 'create'; } else { // Categories association $contcats = GETPOST('contcats', 'array'); @@ -259,51 +259,51 @@ if (empty($reshook)) } } } - } + } - if (!$error && $id > 0) - { - $db->commit(); - if (!empty($backtopage)) $url = $backtopage; - else $url = 'card.php?id='.$id; - header("Location: ".$url); - exit; - } else { - $db->rollback(); - } - } + if (!$error && $id > 0) + { + $db->commit(); + if (!empty($backtopage)) $url = $backtopage; + else $url = 'card.php?id='.$id; + header("Location: ".$url); + exit; + } else { + $db->rollback(); + } + } - if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer) - { - $result = $object->fetch($id); + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer) + { + $result = $object->fetch($id); $object->oldcopy = clone $object; - $object->old_lastname = GETPOST("old_lastname"); - $object->old_firstname = GETPOST("old_firstname"); + $object->old_lastname = GETPOST("old_lastname"); + $object->old_firstname = GETPOST("old_firstname"); - $result = $object->delete(); - if ($result > 0) - { - if ($backtopage) - { - header("Location: ".$backtopage); - exit; - } else { - header("Location: ".DOL_URL_ROOT.'/contact/list.php'); - exit; - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + $result = $object->delete(); + if ($result > 0) + { + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } else { + header("Location: ".DOL_URL_ROOT.'/contact/list.php'); + exit; + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } - if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) - { - if (empty($_POST["lastname"])) - { - $error++; $errors = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); - $action = 'edit'; - } + if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) + { + if (empty($_POST["lastname"])) + { + $error++; $errors = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); + $action = 'edit'; + } if (!$error) { @@ -312,155 +312,155 @@ if (empty($reshook)) // Photo save $dir = $conf->societe->multidir_output[$object->entity]."/contact/".$object->id."/photos"; - $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); - if (GETPOST('deletephoto') && $object->photo) - { - $fileimg = $dir.'/'.$object->photo; - $dirthumbs = $dir.'/thumbs'; - dol_delete_file($fileimg); - dol_delete_dir_recursive($dirthumbs); - $object->photo = ''; - } - if ($file_OK) - { - if (image_format_supported($_FILES['photo']['name']) > 0) - { - dol_mkdir($dir); + $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); + if (GETPOST('deletephoto') && $object->photo) + { + $fileimg = $dir.'/'.$object->photo; + $dirthumbs = $dir.'/thumbs'; + dol_delete_file($fileimg); + dol_delete_dir_recursive($dirthumbs); + $object->photo = ''; + } + if ($file_OK) + { + if (image_format_supported($_FILES['photo']['name']) > 0) + { + dol_mkdir($dir); - if (@is_dir($dir)) - { - $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); + if (@is_dir($dir)) + { + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); - if (!$result > 0) - { - $errors[] = "ErrorFailedToSaveFile"; - } else { - $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); + if (!$result > 0) + { + $errors[] = "ErrorFailedToSaveFile"; + } else { + $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); - // Create thumbs - $object->addThumbs($newfile); - } - } - } else { - $errors[] = "ErrorBadImageFormat"; - } - } else { - switch ($_FILES['photo']['error']) - { - case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini - case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form - $errors[] = "ErrorFileSizeTooLarge"; - break; - case 3: //uploaded file was only partially uploaded - $errors[] = "ErrorFilePartiallyUploaded"; - break; - } - } + // Create thumbs + $object->addThumbs($newfile); + } + } + } else { + $errors[] = "ErrorBadImageFormat"; + } + } else { + switch ($_FILES['photo']['error']) + { + case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini + case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form + $errors[] = "ErrorFileSizeTooLarge"; + break; + case 3: //uploaded file was only partially uploaded + $errors[] = "ErrorFilePartiallyUploaded"; + break; + } + } $object->oldcopy = clone $object; $object->old_lastname = GETPOST("old_lastname", 'alpha'); $object->old_firstname = GETPOST("old_firstname", 'alpha'); - $object->socid = GETPOST("socid", 'int'); - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); - $object->civility_code = GETPOST("civility_code", 'alpha'); - $object->poste = GETPOST("poste", 'alpha'); + $object->socid = GETPOST("socid", 'int'); + $object->lastname = GETPOST("lastname", 'alpha'); + $object->firstname = GETPOST("firstname", 'alpha'); + $object->civility_code = GETPOST("civility_code", 'alpha'); + $object->poste = GETPOST("poste", 'alpha'); - $object->address = GETPOST("address", 'alpha'); - $object->zip = GETPOST("zipcode", 'alpha'); - $object->town = GETPOST("town", 'alpha'); - $object->state_id = GETPOST("state_id", 'int'); - $object->country_id = GETPOST("country_id", 'int'); + $object->address = GETPOST("address", 'alpha'); + $object->zip = GETPOST("zipcode", 'alpha'); + $object->town = GETPOST("town", 'alpha'); + $object->state_id = GETPOST("state_id", 'int'); + $object->country_id = GETPOST("country_id", 'int'); - $object->email = GETPOST("email", 'alpha'); - $object->no_email = GETPOST("no_email", "int"); - //$object->jabberid = GETPOST("jabberid", 'alpha'); - //$object->skype = GETPOST("skype", 'alpha'); - //$object->twitter = GETPOST("twitter", 'alpha'); - //$object->facebook = GETPOST("facebook", 'alpha'); - //$object->linkedin = GETPOST("linkedin", 'alpha'); + $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); + //$object->jabberid = GETPOST("jabberid", 'alpha'); + //$object->skype = GETPOST("skype", 'alpha'); + //$object->twitter = GETPOST("twitter", 'alpha'); + //$object->facebook = GETPOST("facebook", 'alpha'); + //$object->linkedin = GETPOST("linkedin", 'alpha'); $object->socialnetworks = array(); - if (!empty($conf->socialnetworks->enabled)) { - foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { - $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); - } - } - } - $object->phone_pro = GETPOST("phone_pro", 'alpha'); - $object->phone_perso = GETPOST("phone_perso", 'alpha'); - $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); - $object->fax = GETPOST("fax", 'alpha'); - $object->priv = GETPOST("priv", 'int'); - $object->note_public = GETPOST("note_public", 'none'); - $object->note_private = GETPOST("note_private", 'none'); - $object->roles = GETPOST("roles", 'array'); + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } + } + $object->phone_pro = GETPOST("phone_pro", 'alpha'); + $object->phone_perso = GETPOST("phone_perso", 'alpha'); + $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); + $object->fax = GETPOST("fax", 'alpha'); + $object->priv = GETPOST("priv", 'int'); + $object->note_public = GETPOST("note_public", 'none'); + $object->note_private = GETPOST("note_private", 'none'); + $object->roles = GETPOST("roles", 'array'); - // Fill array 'array_options' with data from add form + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; if (!$error) { - $result = $object->update($contactid, $user); + $result = $object->update($contactid, $user); - if ($result > 0) { - // Categories association - $categories = GETPOST('contcats', 'array'); - $object->setCategories($categories); + if ($result > 0) { + // Categories association + $categories = GETPOST('contcats', 'array'); + $object->setCategories($categories); - $no_email = GETPOST('no_email', 'int'); + $no_email = GETPOST('no_email', 'int'); - // Update mass emailing flag into table mailing_unsubscribe - if (GETPOSTISSET('no_email') && $object->email) - { - if ($no_email) - { - $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - $noemail = $obj->nb; - if (empty($noemail)) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; - $resql = $db->query($sql); - } - } - } else { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$db->escape($object->email)."' AND entity = ".$db->escape(getEntity('mailing', 0)); - $resql = $db->query($sql); - } + // Update mass emailing flag into table mailing_unsubscribe + if (GETPOSTISSET('no_email') && $object->email) + { + if ($no_email) + { + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $noemail = $obj->nb; + if (empty($noemail)) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; + $resql = $db->query($sql); + } + } + } else { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$db->escape($object->email)."' AND entity = ".$db->escape(getEntity('mailing', 0)); + $resql = $db->query($sql); + } - $object->no_email = $no_email; - } + $object->no_email = $no_email; + } - $object->old_lastname = ''; - $object->old_firstname = ''; - $action = 'view'; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit'; - } + $object->old_lastname = ''; + $object->old_firstname = ''; + $action = 'view'; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit'; + } } - } + } - if (!$error && empty($errors)) - { - if (!empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } - } - } + if (!$error && empty($errors)) + { + if (!empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + } + } - if ($action == 'setprospectcontactlevel' && $user->rights->societe->contact->creer) - { + if ($action == 'setprospectcontactlevel' && $user->rights->societe->contact->creer) + { $object->fetch($id); $object->fk_prospectlevel = GETPOST('prospect_contact_level_id', 'alpha'); $result = $object->update($object->id, $user); @@ -476,7 +476,7 @@ if (empty($reshook)) if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - // Actions to send emails + // Actions to send emails $triggersendname = 'CONTACT_SENTBYMAIL'; $paramname = 'id'; $mode = 'emailfromcontact'; @@ -501,87 +501,87 @@ $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans(" if ($socid > 0) { - $objsoc = new Societe($db); - $objsoc->fetch($socid); + $objsoc = new Societe($db); + $objsoc->fetch($socid); } if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { - // ----------------------------------------- - // When used with CANVAS - // ----------------------------------------- - if (empty($object->error) && $id) + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- + if (empty($object->error) && $id) { $object = new Contact($db); $result = $object->fetch($id); if ($result <= 0) dol_print_error('', $object->error); } $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template + $objcanvas->display_canvas($action); // Show template } else { - // ----------------------------------------- - // When used in standard mode - // ----------------------------------------- + // ----------------------------------------- + // When used in standard mode + // ----------------------------------------- - // Confirm deleting contact - if ($user->rights->societe->contact->supprimer) - { - if ($action == 'delete') - { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); - } - } + // Confirm deleting contact + if ($user->rights->societe->contact->supprimer) + { + if ($action == 'delete') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); + } + } - /* + /* * Onglets */ - $head = array(); - if ($id > 0) - { - // Si edition contact deja existant - $object = new Contact($db); - $res = $object->fetch($id, $user); - if ($res < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + $head = array(); + if ($id > 0) + { + // Si edition contact deja existant + $object = new Contact($db); + $res = $object->fetch($id, $user); + if ($res < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } - $object->fetchRoles(); + $object->fetchRoles(); - // Show tabs - $head = contact_prepare_head($object); + // Show tabs + $head = contact_prepare_head($object); - $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); - } + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); + } - if ($user->rights->societe->contact->creer) - { - if ($action == 'create') - { - /* + if ($user->rights->societe->contact->creer) + { + if ($action == 'create') + { + /* * Fiche en mode creation */ - $object->canvas = $canvas; + $object->canvas = $canvas; - $object->state_id = GETPOST("state_id"); + $object->state_id = GETPOST("state_id"); - // We set country_id, country_code and label for the selected country - $object->country_id = $_POST["country_id"] ?GETPOST("country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id); - if ($object->country_id) - { - $tmparray = getCountry($object->country_id, 'all'); - $object->country_code = $tmparray['code']; - $object->country = $tmparray['label']; - } + // We set country_id, country_code and label for the selected country + $object->country_id = $_POST["country_id"] ?GETPOST("country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id); + if ($object->country_id) + { + $tmparray = getCountry($object->country_id, 'all'); + $object->country_code = $tmparray['code']; + $object->country = $tmparray['label']; + } - $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); - $linkback = ''; - print load_fiche_titre($title, $linkback, 'address'); + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + $linkback = ''; + print load_fiche_titre($title, $linkback, 'address'); - // Show errors - dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); + // Show errors + dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) + { print "\n".''."\n"; - } + } - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; if (!empty($objsoc)) { print ''; - } + } - dol_fiche_head($head, 'card', '', 0, ''); + dol_fiche_head($head, 'card', '', 0, ''); - print ''; + print '
'; - // Name - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - - // Company - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - if ($socid > 0) - { - print ''; - print ''; - print ''; - print ''; - } else { - print ''; - } - } - - // Civility - print ''; - - print ''; - print ''; - - $colspan = 3; - if ($conf->use_javascript_ajax && $socid > 0) $colspan = 2; - - // Address - if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party - print ''; - print ''; - - if ($conf->use_javascript_ajax && $socid > 0) - { - $rowspan = 3; - if (empty($conf->global->SOCIETE_DISABLE_STATE)) $rowspan++; - - print ''; - } - print ''; - - // Zip / Town - if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party - if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party - print ''; - - // Country - print ''; - - // State - if (empty($conf->global->SOCIETE_DISABLE_STATE)) - { - if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) - { - print ''; - } - - if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->phone_pro)) == 0) $object->phone_pro = $objsoc->phone; // Predefined with third party - if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->fax)) == 0) $object->fax = $objsoc->fax; // Predefined with third party - - // Phone / Fax - print ''; - print ''; - if ($conf->browser->layout == 'phone') print ''; - print ''; - print ''; - - print ''; - print ''; - if ($conf->browser->layout == 'phone') print ''; - print ''; - print ''; - print ''; - - if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party - - // Email - print ''; - print ''; + // Name + print ''; + print ''; print ''; - if (!empty($conf->mailing->enabled)) - { - $noemail = ''; - if (empty($noemail) && !empty($object->email)) - { - $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; - //print $sql; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - $noemail = $obj->nb; - } - } + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''; - } - print ''; + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + if ($socid > 0) + { + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + } + } - if (!empty($conf->socialnetworks->enabled)) { - foreach ($socialnetworks as $key => $value) { - if ($value['active']) { - print ''; - print ''; - print ''; - print ''; - } elseif (!empty($object->socialnetworks[$key])) { - print ''; - } - } - } - // if (! empty($conf->socialnetworks->enabled)) - // { - // // Jabber - // if (! empty($conf->global->SOCIALNETWORKS_JABBER)) - // { - // print ''; - // print ''; - // } - // // Skype - // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) - // { - // print ''; - // print ''; - // } - // // Twitter - // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) - // { - // print ''; - // print ''; - // } - // // Facebook - // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - // { - // print ''; - // print ''; - // } - // // LinkedIn - // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) - // { - // print ''; - // print ''; - // } - // } + // Civility + print ''; - // Visibility - print ''; + print ''; + print ''; + + $colspan = 3; + if ($conf->use_javascript_ajax && $socid > 0) $colspan = 2; + + // Address + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party + print ''; + print ''; + + if ($conf->use_javascript_ajax && $socid > 0) + { + $rowspan = 3; + if (empty($conf->global->SOCIETE_DISABLE_STATE)) $rowspan++; + + print ''; + } + print ''; + + // Zip / Town + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party + print ''; + + // Country + print ''; + + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) + { + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + { + print ''; + } + + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->phone_pro)) == 0) $object->phone_pro = $objsoc->phone; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->fax)) == 0) $object->fax = $objsoc->fax; // Predefined with third party + + // Phone / Fax + print ''; + print ''; + if ($conf->browser->layout == 'phone') print ''; + print ''; + print ''; + + print ''; + print ''; + if ($conf->browser->layout == 'phone') print ''; + print ''; + print ''; + print ''; + + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party + + // Email + print ''; + print ''; + print ''; + + if (!empty($conf->mailing->enabled)) + { + $noemail = ''; + if (empty($noemail) && !empty($object->email)) + { + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $noemail = $obj->nb; + } + } + + print ''; + print ''; + print ''; + print ''; + } + print ''; + + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + print ''; + print ''; + print ''; + print ''; + } elseif (!empty($object->socialnetworks[$key])) { + print ''; + } + } + } + // if (! empty($conf->socialnetworks->enabled)) + // { + // // Jabber + // if (! empty($conf->global->SOCIALNETWORKS_JABBER)) + // { + // print ''; + // print ''; + // } + // // Skype + // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + // { + // print ''; + // print ''; + // } + // // Twitter + // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + // { + // print ''; + // print ''; + // } + // // Facebook + // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + // { + // print ''; + // print ''; + // } + // // LinkedIn + // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + // { + // print ''; + // print ''; + // } + // } + + // Visibility + print ''; // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { @@ -823,84 +823,84 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ""; } - // Contact by default - if (!empty($socid)) { - print ''; - print ''; - } + // Contact by default + if (!empty($socid)) { + print ''; + print ''; + } - // Other attributes - $parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit', $parameters); - } + // Other attributes + $parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) + { + print $object->showOptionals($extrafields, 'edit', $parameters); + } - print "
lastname).'" autofocus="autofocus">
firstname).'">
'; - print $objsoc->getNomUrl(1, 'contact'); - print '
'; - print $form->select_company($socid, 'socid', '', 'SelectThirdParty'); - print '
'; - print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", 'alpha') : $object->civility_code, 'civility_code'); - print '
poste).'">
'; - print ''.$langs->trans('CopyAddressFromSoc').''; - print '
/ '; - print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha') ? GETPOST("zipcode", 'alpha') : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; - print $formcompany->select_ziptown((GETPOST("town", 'alpha') ? GETPOST("town", 'alpha') : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); - print '
'; - print img_picto('', 'globe-americas', 'class="paddingrightonly"'); - print $form->select_country((GETPOST("country_id", 'alpha') ? GETPOST("country_id", 'alpha') : $object->country_id), 'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - print '
'; - } else { - print '
'; - } - - if ($object->country_id) - { - print $formcompany->select_state(GETPOST("state_id", 'alpha') ? GETPOST("state_id", 'alpha') : $object->state_id, $object->country_code, 'state_id'); - } else { - print $countrynotdefined; - } - print '
'.$form->editfieldkey('PhonePro', 'phone_pro', '', $object, 0).''; - print img_picto('', 'object_phoning'); - print '
'.$form->editfieldkey('PhonePerso', 'phone_perso', '', $object, 0).''; - print img_picto('', 'object_phoning'); - print '
'.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).''; - print img_picto('', 'object_phoning_mobile'); - print '
'.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; - print img_picto('', 'object_phoning_fax'); - print '
'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '').''; - print img_picto('', 'object_email'); - print '
lastname).'" autofocus="autofocus">
firstname).'">
'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'alpha') : $noemail), 1).'
'; + print $objsoc->getNomUrl(1, 'contact'); + print '
'; + print $form->select_company($socid, 'socid', '', 'SelectThirdParty'); + print '
'; - print ''; - print '
jabberid).'">
skype).'">
twitter).'">
facebook).'">
linkedin).'">
'; + print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", 'alpha') : $object->civility_code, 'civility_code'); + print '
'; - $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); - print $form->selectarray('priv', $selectarray, (GETPOST("priv", 'alpha') ?GETPOST("priv", 'alpha') : $object->priv), 0); - print '
poste).'">
'; + print ''.$langs->trans('CopyAddressFromSoc').''; + print '
/ '; + print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha') ? GETPOST("zipcode", 'alpha') : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; + print $formcompany->select_ziptown((GETPOST("town", 'alpha') ? GETPOST("town", 'alpha') : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print '
'; + print img_picto('', 'globe-americas', 'class="paddingrightonly"'); + print $form->select_country((GETPOST("country_id", 'alpha') ? GETPOST("country_id", 'alpha') : $object->country_id), 'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print '
'; + } else { + print '
'; + } + + if ($object->country_id) + { + print $formcompany->select_state(GETPOST("state_id", 'alpha') ? GETPOST("state_id", 'alpha') : $object->state_id, $object->country_code, 'state_id'); + } else { + print $countrynotdefined; + } + print '
'.$form->editfieldkey('PhonePro', 'phone_pro', '', $object, 0).''; + print img_picto('', 'object_phoning'); + print '
'.$form->editfieldkey('PhonePerso', 'phone_perso', '', $object, 0).''; + print img_picto('', 'object_phoning'); + print '
'.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).''; + print img_picto('', 'object_phoning_mobile'); + print '
'.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; + print img_picto('', 'object_phoning_fax'); + print '
'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '').''; + print img_picto('', 'object_email'); + print '
'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'alpha') : $noemail), 1).'
'; + print ''; + print '
jabberid).'">
skype).'">
twitter).'">
facebook).'">
linkedin).'">
'; + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); + print $form->selectarray('priv', $selectarray, (GETPOST("priv", 'alpha') ?GETPOST("priv", 'alpha') : $object->priv), 0); + print '
'.$langs->trans("ContactByDefaultFor").''; - $contactType = $object->listeTypeContacts('external', '', 1); - print $form->multiselectarray('roles', $contactType); - print '
'.$langs->trans("ContactByDefaultFor").''; + $contactType = $object->listeTypeContacts('external', '', 1); + print $form->multiselectarray('roles', $contactType); + print '

"; + print "
"; print '
'; - // Add personnal information - print load_fiche_titre('
'.$langs->trans("PersonalInformations").'
', '', ''); + // Add personnal information + print load_fiche_titre('
'.$langs->trans("PersonalInformations").'
', '', ''); - print ''; + print '
'; - // Date To Birth - print ''; + // Date To Birth + print ''; - print ''; - print ''; + print ''; + print ''; - print "
'; - $form = new Form($db); - if ($object->birthday) - { - print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0); - } else { - print $form->selectDate('', 'birthday', 0, 0, 1, "perso", 1, 0); - } - print '
'; + $form = new Form($db); + if ($object->birthday) + { + print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0); + } else { + print $form->selectDate('', 'birthday', 0, 0, 1, "perso", 1, 0); + } + print ': '; - if ($object->birthday_alert) - { - print ''; - } else { - print ''; - } - print '
: '; + if ($object->birthday_alert) + { + print ''; + } else { + print ''; + } + print '
"; + print ""; - dol_fiche_end(); + dol_fiche_end(); - print '
'; - print ''; - if (!empty($backtopage)) - { - print '     '; - print ''; - } else { - print '     '; - print ''; - } - print '
'; + print '
'; + print ''; + if (!empty($backtopage)) + { + print '     '; + print ''; + } else { + print '     '; + print ''; + } + print '
'; - print ""; - } elseif ($action == 'edit' && !empty($id)) - { - /* + print ""; + } elseif ($action == 'edit' && !empty($id)) + { + /* * Fiche en mode edition */ - // We set country_id, and country_code label of the chosen country - if (isset($_POST["country_id"]) || $object->country_id) - { - $tmparray = getCountry($object->country_id, 'all'); - $object->country_code = $tmparray['code']; - $object->country = $tmparray['label']; - } + // We set country_id, and country_code label of the chosen country + if (isset($_POST["country_id"]) || $object->country_id) + { + $tmparray = getCountry($object->country_id, 'all'); + $object->country_code = $tmparray['code']; + $object->country = $tmparray['label']; + } $objsoc = new Societe($db); $objsoc->fetch($object->socid); @@ -908,8 +908,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Show errors dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) + { print "\n".''."\n"; - } + } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (!empty($backtopage)) print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (!empty($backtopage)) print ''; - dol_fiche_head($head, 'card', $title, 0, 'contact'); + dol_fiche_head($head, 'card', $title, 0, 'contact'); - print ''; + print '
'; - // Ref/ID - if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) - { - print ''; - } + // Ref/ID + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) + { + print ''; + } - // Lastname - print ''; - print ''; - print ''; - print ''; - // Firstname - print ''; - print ''; - print ''; + // Lastname + print ''; + print ''; + print ''; + print ''; + // Firstname + print ''; + print ''; + print ''; - // Company - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - print ''; - print ''; - print ''; - } + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + print ''; + print ''; + print ''; + } - // Civility - print ''; + // Civility + print ''; - print ''; - print ''; + print ''; + print ''; - // Address - print ''; - print ''; + // Address + print ''; + print ''; - // Zip / Town - print ''; + // Zip / Town + print ''; - // Country - print ''; + // Country + print ''; - // State - if (empty($conf->global->SOCIETE_DISABLE_STATE)) - { - if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) - { - print ''; - } + print $formcompany->select_state(GETPOSTISSET('state_id') ? GETPOST('state_id', 'alpha') : $object->state_id, $object->country_code, 'state_id'); + print ''; + } - // Phone - print ''; - print ''; - print ''; - print ''; + // Phone + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - // EMail - print ''; - print ''; - if (!empty($conf->mailing->enabled)) - { - $langs->load("mails"); - print ''; - print ''; - } else { - print ''; - } - print ''; - - // Unsubscribe - print ''; - if (!empty($conf->mailing->enabled)) - { - $noemail = ''; - if (empty($noemail) && !empty($object->email)) - { - $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; - //print $sql; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - $noemail = $obj->nb; - } - } - - print ''; - print ''; - } else { + // EMail + print ''; + print ''; + if (!empty($conf->mailing->enabled)) + { + $langs->load("mails"); + print ''; + print ''; + } else { print ''; } - print ''; + print ''; - if (!empty($conf->socialnetworks->enabled)) { - foreach ($socialnetworks as $key => $value) { - if ($value['active']) { - print ''; - print ''; - print ''; - print ''; - } elseif (!empty($object->socialnetworks[$key])) { - print ''; - } - } - } - // if (! empty($conf->socialnetworks->enabled)) - // { - // // Jabber ID - // if (! empty($conf->global->SOCIALNETWORKS_JABBER)) - // { - // print ''; - // print ''; - // } - // // Skype - // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) - // { - // print ''; - // print ''; - // } - // // Twitter - // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) - // { - // print ''; - // print ''; - // } - // // Facebook - // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - // { - // print ''; - // print ''; - // } - // // LinkedIn - // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) - // { - // print ''; - // print ''; - // } - // } + // Unsubscribe + print ''; + if (!empty($conf->mailing->enabled)) + { + $noemail = ''; + if (empty($noemail) && !empty($object->email)) + { + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $noemail = $obj->nb; + } + } - // Visibility - print ''; + print ''; + print ''; + } else { + print ''; + } + print ''; - // Note Public - print ''; + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + print ''; + print ''; + print ''; + print ''; + } elseif (!empty($object->socialnetworks[$key])) { + print ''; + } + } + } + // if (! empty($conf->socialnetworks->enabled)) + // { + // // Jabber ID + // if (! empty($conf->global->SOCIALNETWORKS_JABBER)) + // { + // print ''; + // print ''; + // } + // // Skype + // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + // { + // print ''; + // print ''; + // } + // // Twitter + // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + // { + // print ''; + // print ''; + // } + // // Facebook + // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + // { + // print ''; + // print ''; + // } + // // LinkedIn + // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + // { + // print ''; + // print ''; + // } + // } - // Note Private - print ''; + // Visibility + print ''; - // Status - print ''; - print ''; + // Note Public + print ''; + + // Note Private + print ''; + + // Status + print ''; + print ''; // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { @@ -1162,196 +1162,196 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Contact by default - if (!empty($object->socid)) { - print ''; - print ''; - } + if (!empty($object->socid)) { + print ''; + print ''; + } - // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols'=> '3'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit', $parameters); - } + // Other attributes + $parameters = array('colspan' => ' colspan="3"', 'cols'=> '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) + { + print $object->showOptionals($extrafields, 'edit', $parameters); + } - $object->load_ref_elements(); + $object->load_ref_elements(); - if (!empty($conf->commande->enabled)) - { - print ''; - } + if (!empty($conf->commande->enabled)) + { + print ''; + } - if (!empty($conf->propal->enabled)) - { - print ''; - } + if (!empty($conf->propal->enabled)) + { + print ''; + } - if (!empty($conf->contrat->enabled)) - { - print ''; - } + if (!empty($conf->contrat->enabled)) + { + print ''; + } - if (!empty($conf->facture->enabled)) - { - print ''; - } + if (!empty($conf->facture->enabled)) + { + print ''; + } - // Login Dolibarr - print ''; + // Login Dolibarr + print ''; - // Photo - print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; + print ''; - print '
'.$langs->trans("ID").''; - print $object->ref; - print '
'.$langs->trans("ID").''; + print $object->ref; + print '
lastname).'" autofocus="autofocus">
firstname).'">
lastname).'" autofocus="autofocus">
firstname).'">
'; - print $form->select_company(GETPOST('socid', 'int') ?GETPOST('socid', 'int') : ($object->socid ? $object->socid : -1), 'socid', '', $langs->trans("SelectThirdParty")); - print '
'; + print $form->select_company(GETPOST('socid', 'int') ?GETPOST('socid', 'int') : ($object->socid ? $object->socid : -1), 'socid', '', $langs->trans("SelectThirdParty")); + print '
'; - print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", "aZ09") : $object->civility_code, 'civility_code'); - print '
'; + print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", "aZ09") : $object->civility_code, 'civility_code'); + print '
poste).'">
poste).'">
'; - print '
'; - print ''; - print '
'; - if ($conf->use_javascript_ajax) print ''.$langs->trans('CopyAddressFromSoc').'
'; - print '
'; - print '
'; + print '
'; + print ''; + print '
'; + if ($conf->use_javascript_ajax) print ''.$langs->trans('CopyAddressFromSoc').'
'; + print '
'; + print '
/ '; - print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOST("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; - print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); - print '
/ '; + print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOST("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; + print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print '
'; - print img_picto('', 'globe-americas', 'class="paddingrightonly"'); - print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id") : $object->country_id, 'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - print '
'; + print img_picto('', 'globe-americas', 'class="paddingrightonly"'); + print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id") : $object->country_id, 'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print '
'; - } else { - print '
'; - } + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) + { + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + { + print '
'; + } else { + print '
'; + } - print $formcompany->select_state(GETPOSTISSET('state_id') ? GETPOST('state_id', 'alpha') : $object->state_id, $object->country_code, 'state_id'); - print '
'.$form->editfieldkey('PhonePro', 'phone_pro', GETPOST('phone_pro', 'alpha'), $object, 0).''; - print img_picto('', 'object_phoning'); - print ''.$form->editfieldkey('PhonePerso', 'fax', GETPOST('phone_perso', 'alpha'), $object, 0).''; - print img_picto('', 'object_phoning'); - print '
'.$form->editfieldkey('PhonePro', 'phone_pro', GETPOST('phone_pro', 'alpha'), $object, 0).''; + print img_picto('', 'object_phoning'); + print ''.$form->editfieldkey('PhonePerso', 'fax', GETPOST('phone_perso', 'alpha'), $object, 0).''; + print img_picto('', 'object_phoning'); + print '
'.$form->editfieldkey('PhoneMobile', 'phone_mobile', GETPOST('phone_mobile', 'alpha'), $object, 0, 'string', '').''; - print img_picto('', 'object_phoning_mobile'); - print ''.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).''; - print img_picto('', 'object_phoning_fax'); - print '
'.$form->editfieldkey('PhoneMobile', 'phone_mobile', GETPOST('phone_mobile', 'alpha'), $object, 0, 'string', '').''; + print img_picto('', 'object_phoning_mobile'); + print ''.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).''; + print img_picto('', 'object_phoning_fax'); + print '
'.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''; - print img_picto('', 'object_email'); - print ''.$langs->trans("NbOfEMailingsSend").''.$object->getNbOfEMailings().'
'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).'
'.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''; + print img_picto('', 'object_email'); + print ''.$langs->trans("NbOfEMailingsSend").''.$object->getNbOfEMailings().'
'; - print ''; - print '
jabberid).'">
skype).'">
twitter).'">
facebook).'">
linkedin).'">
'; - $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); - print $form->selectarray('priv', $selectarray, $object->priv, 0); - print '
'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).'
'; - $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); - print $doleditor->Create(1); - print '
'; + print ''; + print '
jabberid).'">
skype).'">
twitter).'">
facebook).'">
linkedin).'">
'; - $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); - print $doleditor->Create(1); - print '
'; + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); + print $form->selectarray('priv', $selectarray, $object->priv, 0); + print '
'.$langs->trans("Status").''; - print $object->getLibStatut(4); - print '
'; + $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + print '
'; + $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + print '
'.$langs->trans("Status").''; + print $object->getLibStatut(4); + print '
'.$langs->trans("ContactByDefaultFor").''; - print $formcompany->showRoles("roles", $object, 'edit', $object->roles); - print '
'.$langs->trans("ContactByDefaultFor").''; + print $formcompany->showRoles("roles", $object, 'edit', $object->roles); + print '
'.$langs->trans("ContactForOrders").''; - print $object->ref_commande ? $object->ref_commande : $langs->trans("NoContactForAnyOrder"); - print '
'.$langs->trans("ContactForOrders").''; + print $object->ref_commande ? $object->ref_commande : $langs->trans("NoContactForAnyOrder"); + print '
'.$langs->trans("ContactForProposals").''; - print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); - print '
'.$langs->trans("ContactForProposals").''; + print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); + print '
'.$langs->trans("ContactForContracts").''; - print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); - print '
'.$langs->trans("ContactForContracts").''; + print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); + print '
'.$langs->trans("ContactForInvoices").''; - print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); - print '
'.$langs->trans("ContactForInvoices").''; + print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); + print '
'.$langs->trans("DolibarrLogin").''; - if ($object->user_id) - { - $dolibarr_user = new User($db); - $result = $dolibarr_user->fetch($object->user_id); - print $dolibarr_user->getLoginUrl(1); - } else print $langs->trans("NoDolibarrAccess"); - print '
'.$langs->trans("DolibarrLogin").''; + if ($object->user_id) + { + $dolibarr_user = new User($db); + $result = $dolibarr_user->fetch($object->user_id); + print $dolibarr_user->getLoginUrl(1); + } else print $langs->trans("NoDolibarrAccess"); + print '
'.$langs->trans("PhotoFile").''; - if ($object->photo) { - print $form->showphoto('contact', $object); - print "
\n"; - } - print ''; - if ($object->photo) print ''; - //print ''; - print ''; - print '
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; + // Photo + print '
'.$langs->trans("PhotoFile").''; + if ($object->photo) { + print $form->showphoto('contact', $object); + print "
\n"; + } + print ''; + if ($object->photo) print ''; + //print ''; + print ''; + print '
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; - print '
'; + print ''; - dol_fiche_end(); + dol_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; - print "
"; - } - } + print ""; + } + } - if (!empty($id) && $action != 'edit' && $action != 'create') - { - $objsoc = new Societe($db); + if (!empty($id) && $action != 'edit' && $action != 'create') + { + $objsoc = new Societe($db); - // View mode + // View mode - // Show errors - dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); + // Show errors + dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); - dol_fiche_head($head, 'card', $title, -1, 'contact'); + dol_fiche_head($head, 'card', $title, -1, 'contact'); - if ($action == 'create_user') - { - // Full firstname and lastname separated with a dot : firstname.lastname - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $login = dol_buildlogin($object->lastname, $object->firstname); + if ($action == 'create_user') + { + // Full firstname and lastname separated with a dot : firstname.lastname + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $login = dol_buildlogin($object->lastname, $object->firstname); - $generated_password = ''; - if (!$ldap_sid) // TODO ldap_sid ? - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $generated_password = getRandomPassword(false); - } - $password = $generated_password; + $generated_password = ''; + if (!$ldap_sid) // TODO ldap_sid ? + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $generated_password = getRandomPassword(false); + } + $password = $generated_password; - // Create a form array - $formquestion = array( - array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), - array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password), - //array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External'))) - ); - $text = $langs->trans("ConfirmCreateContact").'
'; - if (!empty($conf->societe->enabled)) - { - if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser"); - else $text .= $langs->trans("UserWillBeInternalUser"); - } - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes'); - } + // Create a form array + $formquestion = array( + array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), + array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password), + //array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External'))) + ); + $text = $langs->trans("ConfirmCreateContact").'
'; + if (!empty($conf->societe->enabled)) + { + if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser"); + else $text .= $langs->trans("UserWillBeInternalUser"); + } + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes'); + } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
'; + $morehtmlref = '
'; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - print '
'; - print '
'; + print '
'; + print '
'; - print '
'; - print ''; + print '
'; + print '
'; - // Civility - print ''; + // Civility + print ''; - // Job / position - print ''; + // Job / position + print ''; - // Email - if (!empty($conf->mailing->enabled)) - { - $langs->load("mails"); - print ''; - print ''; - } + // Email + if (!empty($conf->mailing->enabled)) + { + $langs->load("mails"); + print ''; + print ''; + } - // Unsubscribe opt-out - if (!empty($conf->mailing->enabled)) - { - //print 'eee'.$object->email; - $noemail = $object->no_email; - if (empty($noemail) && !empty($object->email)) - { - $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; - //print $sql; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - $noemail = $obj->nb; - } - } - print ''; - } + // Unsubscribe opt-out + if (!empty($conf->mailing->enabled)) + { + //print 'eee'.$object->email; + $noemail = $object->no_email; + if (empty($noemail) && !empty($object->email)) + { + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $noemail = $obj->nb; + } + } + print ''; + } - print ''; + print ''; - print '
'.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
'.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
'.$langs->trans("PostOrFunction").''.$object->poste.'
'.$langs->trans("PostOrFunction").''.$object->poste.'
'.$langs->trans("NbOfEMailingsSend").''.$object->getNbOfEMailings().'
'.$langs->trans("NbOfEMailingsSend").''.$object->getNbOfEMailings().'
'.$langs->trans("No_Email").''.yn($noemail).'
'.$langs->trans("No_Email").''.yn($noemail).'
'.$langs->trans("ContactVisibility").''; - print $object->LibPubPriv($object->priv); - print '
'.$langs->trans("ContactVisibility").''; + print $object->LibPubPriv($object->priv); + print '
'; - print '
'; + print ''; + print '
'; $object->fetch_thirdparty(); @@ -1396,10 +1396,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } } - print '
'; + print '
'; - print '
'; - print ''; + print '
'; + print '
'; // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { @@ -1409,78 +1409,78 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; } - if (!empty($object->socid)) { - print ''; - print ''; - } + if (!empty($object->socid)) { + print ''; + print ''; + } - // Other attributes - $cols = 3; - $parameters = array('socid'=>$socid); - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // Other attributes + $cols = 3; + $parameters = array('socid'=>$socid); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - $object->load_ref_elements(); + $object->load_ref_elements(); - if (!empty($conf->propal->enabled)) - { - print ''; - } + if (!empty($conf->propal->enabled)) + { + print ''; + } - if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) - { - print ''; - } + if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) + { + print ''; + } - if (!empty($conf->contrat->enabled)) - { - print ''; - } + if (!empty($conf->contrat->enabled)) + { + print ''; + } - if (!empty($conf->facture->enabled)) - { - print ''; - } + if (!empty($conf->facture->enabled)) + { + print ''; + } - print ''; + print ''; - print ''; + print ''; - print "
'.$langs->trans("ContactByDefaultFor").''; - print $formcompany->showRoles("roles", $object, 'view'); - print '
'.$langs->trans("ContactByDefaultFor").''; + print $formcompany->showRoles("roles", $object, 'view'); + print '
'.$langs->trans("ContactForProposals").''; - print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); - print '
'.$langs->trans("ContactForProposals").''; + print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); + print '
'; - if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } else print $langs->trans("ContactForOrders"); - print ''; - $none = $langs->trans("NoContactForAnyOrder"); - if (!empty($conf->expedition->enabled)) { $none = $langs->trans("NoContactForAnyOrderOrShipments"); } - print $object->ref_commande ? $object->ref_commande : $none; - print '
'; + if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } else print $langs->trans("ContactForOrders"); + print ''; + $none = $langs->trans("NoContactForAnyOrder"); + if (!empty($conf->expedition->enabled)) { $none = $langs->trans("NoContactForAnyOrderOrShipments"); } + print $object->ref_commande ? $object->ref_commande : $none; + print '
'.$langs->trans("ContactForContracts").''; - print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); - print '
'.$langs->trans("ContactForContracts").''; + print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); + print '
'.$langs->trans("ContactForInvoices").''; - print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); - print '
'.$langs->trans("ContactForInvoices").''; + print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); + print '
'.$langs->trans("DolibarrLogin").''; - if ($object->user_id) - { - $dolibarr_user = new User($db); - $result = $dolibarr_user->fetch($object->user_id); - print $dolibarr_user->getLoginUrl(1); - } else print $langs->trans("NoDolibarrAccess"); - print '
'.$langs->trans("DolibarrLogin").''; + if ($object->user_id) + { + $dolibarr_user = new User($db); + $result = $dolibarr_user->fetch($object->user_id); + print $dolibarr_user->getLoginUrl(1); + } else print $langs->trans("NoDolibarrAccess"); + print '
'; - print $langs->trans("VCard").''; + print '
'; + print $langs->trans("VCard").''; print ''; print img_picto($langs->trans("Download"), 'vcard.png', 'class="paddingrightonly"'); print $langs->trans("Download"); print ''; - print '
"; + print ""; - print '
'; - print '
'; + print '
'; + print '
'; - dol_fiche_end(); + dol_fiche_end(); - // Barre d'actions - print '
'; + // Barre d'actions + print '
'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1498,66 +1498,66 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } if ($user->rights->societe->contact->creer) - { - print ''.$langs->trans('Modify').''; - } + { + print ''.$langs->trans('Modify').''; + } - if (!$object->user_id && $user->rights->user->user->creer) - { - print ''.$langs->trans("CreateDolibarrLogin").''; - } + if (!$object->user_id && $user->rights->user->user->creer) + { + print ''.$langs->trans("CreateDolibarrLogin").''; + } - // Activer - if ($object->statut == 0 && $user->rights->societe->contact->creer) - { - print ''.$langs->trans("Reactivate").''; - } - // Desactiver - if ($object->statut == 1 && $user->rights->societe->contact->creer) - { - print ''.$langs->trans("DisableUser").''; - } + // Activer + if ($object->statut == 0 && $user->rights->societe->contact->creer) + { + print ''.$langs->trans("Reactivate").''; + } + // Desactiver + if ($object->statut == 1 && $user->rights->societe->contact->creer) + { + print ''.$langs->trans("DisableUser").''; + } - // Delete - if ($user->rights->societe->contact->supprimer) - { - print ''.$langs->trans('Delete').''; - } - } + // Delete + if ($user->rights->societe->contact->supprimer) + { + print ''.$langs->trans('Delete').''; + } + } - print "
"; + print "
"; - //Select mail models is same action as presend - if (GETPOST('modelselected')) { - $action = 'presend'; - } + //Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } - if ($action != 'presend') - { - print '
'; + if ($action != 'presend') + { + print '
'; - print '
'; + print '
'; - $MAXEVENT = 10; + $MAXEVENT = 10; - $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id); + $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id); - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'contact', $object->socid, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'contact', $object->socid, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty - print '
'; - } + print '
'; + } - // Presend form - $modelmail = 'contact'; - $defaulttopic = 'Information'; - $diroutput = $conf->contact->dir_output; - $trackid = 'con'.$object->id; + // Presend form + $modelmail = 'contact'; + $defaulttopic = 'Information'; + $diroutput = $conf->contact->dir_output; + $trackid = 'con'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; - } + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + } } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index d7bcafc8363..a474df3b910 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -184,7 +184,7 @@ $arrayfields = array( 'p.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'p.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); -if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { +if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { $arrayfields['p.fk_prospectcontactlevel'] = array('label'=>"ProspectLevelShort", 'checked'=>1, 'position'=>210); $arrayfields['p.fk_stcommcontact'] = array('label'=>"StatusProsp", 'checked'=>1, 'position'=>215); } @@ -270,8 +270,8 @@ if (empty($reshook)) } } $search_priv = ""; - $search_stcomm=''; - $search_level=''; + $search_stcomm = ''; + $search_level = ''; $search_status = -1; $search_categ = ''; $search_categ_thirdparty = ''; @@ -314,7 +314,7 @@ $formother = new FormOther($db); $formcompany = new FormCompany($db); $contactstatic = new Contact($db); -if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { +if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { $contactstatic->loadCacheOfProspStatus(); } @@ -323,17 +323,17 @@ $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("C // Select every potentiels, and note each potentiels which fit in search parameters $tab_level = array(); $sql = "SELECT code, label, sortorder"; -$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel"; -$sql.= " WHERE active > 0"; -$sql.= " ORDER BY sortorder"; +$sql .= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel"; +$sql .= " WHERE active > 0"; +$sql .= " ORDER BY sortorder"; $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { // Compute level text - $level=$langs->trans($obj->code); - if ($level == $obj->code) $level=$langs->trans($obj->label); + $level = $langs->trans($obj->code); + if ($level == $obj->code) $level = $langs->trans($obj->label); $tab_level[$obj->code] = $level; } } @@ -343,7 +343,7 @@ $sql = "SELECT s.rowid as socid, s.nom as name,"; $sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,"; $sql .= " p.socialnetworks, p.photo,"; $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; -$sql.= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,"; +$sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,"; $sql .= " co.label as country, co.code as country_code"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -357,7 +357,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact"; if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ @@ -469,7 +469,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if (! $resql) +if (!$resql) { dol_print_error($db); exit; @@ -515,10 +515,10 @@ if ($search_email != '') $param .= '&search_email='.urlencode($search_email) if ($search_no_email != '') $param .= '&search_no_email='.urlencode($search_no_email); if ($search_status != '') $param .= '&search_status='.urlencode($search_status); if ($search_priv == '0' || $search_priv == '1') $param .= "&search_priv=".urlencode($search_priv); -if ($search_stcomm != '') $param.='&search_stcomm='.urlencode($search_stcomm); +if ($search_stcomm != '') $param .= '&search_stcomm='.urlencode($search_stcomm); if (is_array($search_level) && count($search_level)) { foreach ($search_level as $slevel) { - $param.='&search_level[]='.urlencode($slevel); + $param .= '&search_level[]='.urlencode($slevel); } } if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key); @@ -739,20 +739,20 @@ if (!empty($arrayfields['p.priv']['checked'])) print ''; } // Prospect level -if (! empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) +if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { print ''; print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2); print ''; } // Prospect status -if (! empty($arrayfields['p.fk_stcommcontact']['checked'])) +if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { print ''; - $arraystcomm=array(); + $arraystcomm = array(); foreach ($contactstatic->cacheprospectstatus as $key => $val) { - $arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); + $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); } print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', 'nowrap '); print ''; @@ -877,7 +877,7 @@ while ($i < min($num, $limit)) $contactstatic->country_code = $obj->country_code; $contactstatic->photo = $obj->photo; - $contactstatic->fk_prospectlevel=$obj->fk_prospectcontactlevel; + $contactstatic->fk_prospectlevel = $obj->fk_prospectcontactlevel; print ''; @@ -1007,7 +1007,7 @@ while ($i < min($num, $limit)) if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) + if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { // Prospect level print ''; @@ -1016,16 +1016,16 @@ while ($i < min($num, $limit)) if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['p.fk_stcommcontact']['checked'])) + if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { // Prospect status print '
'; - print '
' . $contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); + print '
'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); print '
-
'; foreach ($contactstatic->cacheprospectstatus as $key => $val) { $titlealt = 'default'; if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; - if ($obj->stcomm_id != $val['id']) print '' . img_action($titlealt, $val['code'], $val['picto']) . ''; + if ($obj->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code'], $val['picto']).''; } print '
'; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index a9c3fb713c5..ba1d296ac44 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -85,7 +85,7 @@ if ($action == 'add' && !empty($permissiontoadd)) $object->$key = $value; if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)') { - $object->$key = '(PROV)'; + $object->$key = '(PROV)'; } if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) { @@ -105,7 +105,7 @@ if ($action == 'add' && !empty($permissiontoadd)) $result = $object->create($user); if ($result > 0) { - // Creation OK + // Creation OK $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation header("Location: ".$urltogo); @@ -154,7 +154,7 @@ if ($action == 'update' && !empty($permissiontoadd)) $value = ''; } } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) { - $value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup + $value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup } elseif ($object->fields[$key]['type'] == 'boolean') { $value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0); } else { @@ -223,11 +223,11 @@ if ($action == "update_extras" && !empty($permissiontoadd)) // Action to delete if ($action == 'confirm_delete' && !empty($permissiontodelete)) { - if (!($object->id > 0)) - { - dol_print_error('', 'Error, object must be fetched before being deleted'); - exit; - } + if (!($object->id > 0)) + { + dol_print_error('', 'Error, object must be fetched before being deleted'); + exit; + } $result = $object->delete($user); if ($result > 0) @@ -246,7 +246,7 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete)) if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) { if (method_exists('deleteline', $object)) { - $result = $object->deleteline($user, $lineid); // For backward compatibility + $result = $object->deleteline($user, $lineid); // For backward compatibility } else { $result = $object->deleteLine($user, $lineid); } @@ -385,11 +385,11 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { - $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. + $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); - // ... - $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); - if (is_object($result) || $result > 0) + // ... + $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); + if (is_object($result) || $result > 0) { $newid = 0; if (is_object($result)) $newid = $result->id; @@ -397,7 +397,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object exit; } else { - setEventMessages($objectutil->error, $objectutil->errors, 'errors'); + setEventMessages($objectutil->error, $objectutil->errors, 'errors'); $action = ''; } } diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 4cfa0531a08..da010380276 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -263,12 +263,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST if (dol_strlen($sendto)) { - // Define $urlwithroot - $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + // Define $urlwithroot + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $langs->load("commercial"); @@ -419,7 +419,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST // Initialisation of datas of object to call trigger if (is_object($object)) { - if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically + if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically $object->socid = $sendtosocid; // To link to a company $object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array. @@ -456,7 +456,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST if ($error) { setEventMessages($object->error, $object->errors, 'errors'); - } + } } // End call of triggers } diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 54a0cbef2a1..41e23819266 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -34,28 +34,28 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); if (!isset($mode) || $mode != 'noajax') // For ajax call { - require_once '../../main.inc.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; + require_once '../../main.inc.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; - $action = GETPOST('action', 'aZ09'); - $file = urldecode(GETPOST('file', 'alpha')); - $section = GETPOST("section", 'alpha'); - $module = GETPOST("module", 'alpha'); - $urlsource = GETPOST("urlsource", 'alpha'); - $search_doc_ref = GETPOST('search_doc_ref', 'alpha'); + $action = GETPOST('action', 'aZ09'); + $file = urldecode(GETPOST('file', 'alpha')); + $section = GETPOST("section", 'alpha'); + $module = GETPOST("module", 'alpha'); + $urlsource = GETPOST("urlsource", 'alpha'); + $search_doc_ref = GETPOST('search_doc_ref', 'alpha'); - $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; - $sortfield = GETPOST("sortfield", 'alpha'); - $sortorder = GETPOST("sortorder", 'alpha'); - $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); - if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 - $offset = $limit * $page; - $pageprev = $page - 1; - $pagenext = $page + 1; - if (!$sortorder) $sortorder = "ASC"; - if (!$sortfield) $sortfield = "name"; + $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; + $sortfield = GETPOST("sortfield", 'alpha'); + $sortorder = GETPOST("sortorder", 'alpha'); + $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); + if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 + $offset = $limit * $page; + $pageprev = $page - 1; + $pagenext = $page + 1; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "name"; $rootdirfordoc = $conf->ecm->dir_output; @@ -63,30 +63,30 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call $ecmdir = new EcmDirectory($db); if ($section > 0) { - $result = $ecmdir->fetch($section); - if (!$result > 0) - { - //dol_print_error($db,$ecmdir->error); - //exit; - } + $result = $ecmdir->fetch($section); + if (!$result > 0) + { + //dol_print_error($db,$ecmdir->error); + //exit; + } } } else // For no ajax call { $rootdirfordoc = $conf->ecm->dir_output; $ecmdir = new EcmDirectory($db); - $relativepath = ''; - if ($section > 0) - { - $result = $ecmdir->fetch($section); - if (!$result > 0) - { - dol_print_error($db, $ecmdir->error); - exit; - } + $relativepath = ''; + if ($section > 0) + { + $result = $ecmdir->fetch($section); + if (!$result > 0) + { + dol_print_error($db, $ecmdir->error); + exit; + } - $relativepath = $ecmdir->getRelativePath(); // Example 'mydir/' - } elseif (GETPOST('section_dir')) + $relativepath = $ecmdir->getRelativePath(); // Example 'mydir/' + } elseif (GETPOST('section_dir')) { $relativepath = GETPOST('section_dir'); } @@ -113,10 +113,10 @@ if ($user->socid > 0) $socid = $user->socid; // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) { - dol_syslog("Refused to deliver file ".$upload_dir); - // Do no show plain path in shown error message - dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir)); - exit; + dol_syslog("Refused to deliver file ".$upload_dir); + // Do no show plain path in shown error message + dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir)); + exit; } // Check permissions @@ -145,10 +145,10 @@ if ($modulepart == 'medias') if (!isset($mode) || $mode != 'noajax') { // Ajout directives pour resoudre bug IE - header('Cache-Control: Public, must-revalidate'); - header('Pragma: public'); + header('Cache-Control: Public, must-revalidate'); + header('Pragma: public'); - top_httphead(); + top_httphead(); } $type = 'directory'; @@ -156,8 +156,8 @@ $type = 'directory'; // This test if file exists should be useless. We keep it to find bug more easily if (!dol_is_dir($upload_dir)) { - //dol_mkdir($upload_dir); - /*$langs->load("install"); + //dol_mkdir($upload_dir); + /*$langs->load("install"); dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir)); exit;*/ } @@ -173,76 +173,76 @@ if (!empty($pageid)) $param .= '&pageid='.urlencode($pageid); // Dir scan if ($type == 'directory') { - $formfile = new FormFile($db); + $formfile = new FormFile($db); - $maxlengthname = 40; - $excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$'); - $sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC); + $maxlengthname = 40; + $excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$'); + $sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC); - // Right area. If module is defined here, we are in automatic ecm. - $automodules = array( - 'company', - 'invoice', - 'invoice_supplier', - 'propal', - 'supplier_proposal', - 'order', - 'order_supplier', - 'contract', - 'product', - 'tax', - 'project', - 'fichinter', - 'user', - 'expensereport', - 'holiday', - 'recruitment-recruitmentcandidature', - 'banque', - 'mrp-mo' - ); + // Right area. If module is defined here, we are in automatic ecm. + $automodules = array( + 'company', + 'invoice', + 'invoice_supplier', + 'propal', + 'supplier_proposal', + 'order', + 'order_supplier', + 'contract', + 'product', + 'tax', + 'project', + 'fichinter', + 'user', + 'expensereport', + 'holiday', + 'recruitment-recruitmentcandidature', + 'banque', + 'mrp-mo' + ); - // TODO change for multicompany sharing - if ($module == 'company') $upload_dir = $conf->societe->dir_output; - elseif ($module == 'invoice') $upload_dir = $conf->facture->dir_output; - elseif ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; - elseif ($module == 'propal') $upload_dir = $conf->propal->dir_output; - elseif ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output; - elseif ($module == 'order') $upload_dir = $conf->commande->dir_output; - elseif ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; - elseif ($module == 'contract') $upload_dir = $conf->contrat->dir_output; - elseif ($module == 'product') $upload_dir = $conf->product->dir_output; - elseif ($module == 'tax') $upload_dir = $conf->tax->dir_output; - elseif ($module == 'project') $upload_dir = $conf->projet->dir_output; - elseif ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output; - elseif ($module == 'user') $upload_dir = $conf->user->dir_output; - elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output; - elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output; - elseif ($module == 'recruitment-recruitmentcandidature') $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature'; - elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output; - elseif ($module == 'mrp-mo') $upload_dir = $conf->mrp->dir_output.'/mo'; + // TODO change for multicompany sharing + if ($module == 'company') $upload_dir = $conf->societe->dir_output; + elseif ($module == 'invoice') $upload_dir = $conf->facture->dir_output; + elseif ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; + elseif ($module == 'propal') $upload_dir = $conf->propal->dir_output; + elseif ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output; + elseif ($module == 'order') $upload_dir = $conf->commande->dir_output; + elseif ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; + elseif ($module == 'contract') $upload_dir = $conf->contrat->dir_output; + elseif ($module == 'product') $upload_dir = $conf->product->dir_output; + elseif ($module == 'tax') $upload_dir = $conf->tax->dir_output; + elseif ($module == 'project') $upload_dir = $conf->projet->dir_output; + elseif ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output; + elseif ($module == 'user') $upload_dir = $conf->user->dir_output; + elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output; + elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output; + elseif ($module == 'recruitment-recruitmentcandidature') $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature'; + elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output; + elseif ($module == 'mrp-mo') $upload_dir = $conf->mrp->dir_output.'/mo'; - // Automatic list - if (in_array($module, $automodules)) - { - $param .= '&module='.$module; - if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref); + // Automatic list + if (in_array($module, $automodules)) + { + $param .= '&module='.$module; + if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref); - $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"))); + $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"))); - if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. + if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. - $filter = preg_quote($search_doc_ref, '/'); - $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); + $filter = preg_quote($search_doc_ref, '/'); + $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); - $perm = $user->rights->ecm->upload; + $perm = $user->rights->ecm->upload; - $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1); - } - // Manual list - else { - if ($module == 'medias') - { - /* + $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1); + } + // Manual list + else { + if ($module == 'medias') + { + /* $_POST is array like 'token' => string '062380e11b7dcd009d07318b57b71750' (length=32) 'action' => string 'file_manager' (length=12) @@ -253,82 +253,82 @@ if ($type == 'directory') 'max_file_size' => string '2097152' (length=7) 'sendit' => string 'Envoyer fichier' (length=15) */ - $relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha'); - if ($relativepath && $relativepath != '/') $relativepath .= '/'; - $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; - if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) - { - $param .= '&file_manager=1'; - if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha')); - if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int')); - //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); - } - } else { - $relativepath = $ecmdir->getRelativePath(); - $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; - } + $relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha'); + if ($relativepath && $relativepath != '/') $relativepath .= '/'; + $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; + if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) + { + $param .= '&file_manager=1'; + if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha')); + if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int')); + //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); + } + } else { + $relativepath = $ecmdir->getRelativePath(); + $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; + } - // If $section defined with value 0 + // If $section defined with value 0 if (($section === '0' || empty($section)) && ($module != 'medias')) - { - $filearray = array(); - } else { - $filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1); - } + { + $filearray = array(); + } else { + $filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1); + } - if ($section) - { - $param .= '§ion='.$section; - if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref; + if ($section) + { + $param .= '§ion='.$section; + if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref; - $textifempty = $langs->trans('NoFileFound'); - } elseif ($section === '0') - { - if ($module == 'ecm') $textifempty = '
'.$langs->trans("DirNotSynchronizedSyncFirst").'

'; - else $textifempty = $langs->trans('NoFileFound'); - } else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection")); + $textifempty = $langs->trans('NoFileFound'); + } elseif ($section === '0') + { + if ($module == 'ecm') $textifempty = '
'.$langs->trans("DirNotSynchronizedSyncFirst").'

'; + else $textifempty = $langs->trans('NoFileFound'); + } else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection")); - if ($module == 'medias') - { - $useinecm = 6; - $modulepart = 'medias'; - $perm = ($user->rights->website->write || $user->rights->emailing->creer); - $title = 'none'; - } elseif ($module == 'ecm') // DMS/ECM -> manual structure - { - if ($user->rights->ecm->read) - { - // Buttons: Preview - $useinecm = 2; - } + if ($module == 'medias') + { + $useinecm = 6; + $modulepart = 'medias'; + $perm = ($user->rights->website->write || $user->rights->emailing->creer); + $title = 'none'; + } elseif ($module == 'ecm') // DMS/ECM -> manual structure + { + if ($user->rights->ecm->read) + { + // Buttons: Preview + $useinecm = 2; + } - if ($user->rights->ecm->upload) - { - // Buttons: Preview + Delete - $useinecm = 4; - } + if ($user->rights->ecm->upload) + { + // Buttons: Preview + Delete + $useinecm = 4; + } - if ($user->rights->ecm->setup) - { - // Buttons: Preview + Delete + Edit - $useinecm = 5; - } + if ($user->rights->ecm->setup) + { + // Buttons: Preview + Delete + Edit + $useinecm = 5; + } - $perm = $user->rights->ecm->upload; - $modulepart = 'ecm'; - $title = ''; // Use default - } else { - $useinecm = 5; - $modulepart = 'ecm'; - $perm = $user->rights->ecm->upload; - $title = ''; // Use default - } + $perm = $user->rights->ecm->upload; + $modulepart = 'ecm'; + $title = ''; // Use default + } else { + $useinecm = 5; + $modulepart = 'ecm'; + $perm = $user->rights->ecm->upload; + $title = ''; // Use default + } - // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param - // When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath - //var_dump("section=".$section." title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url); - $formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm); - } + // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param + // When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath + //var_dump("section=".$section." title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url); + $formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm); + } } diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index a98846a6309..5048bcd31e8 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -41,47 +41,47 @@ class CMailFile public $sendmode; public $sendsetup; - public $subject; // Topic: Subject of email - public $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). + public $subject; // Topic: Subject of email + public $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). // Sender: Who send the email ("Sender" has sent emails on behalf of "From"). // Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain. // Return-Path: Email where to send bounds. - public $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) - public $errors_to; // Errors-To: Email where to send errors. - public $addr_to; - public $addr_cc; - public $addr_bcc; - public $trackid; + public $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) + public $errors_to; // Errors-To: Email where to send errors. + public $addr_to; + public $addr_cc; + public $addr_bcc; + public $trackid; - public $mixed_boundary; - public $related_boundary; - public $alternative_boundary; - public $deliveryreceipt; + public $mixed_boundary; + public $related_boundary; + public $alternative_boundary; + public $deliveryreceipt; - public $eol; - public $eol2; + public $eol; + public $eol2; /** * @var string Error code (or message) */ public $error = ''; - public $smtps; // Contains SMTPs object (if this method is used) - public $phpmailer; // Contains PHPMailer object (if this method is used) + public $smtps; // Contains SMTPs object (if this method is used) + public $phpmailer; // Contains PHPMailer object (if this method is used) /** * @var string CSS */ public $css; //! Defined css style for body background - public $styleCSS; + public $styleCSS; //! Defined background directly in body tag - public $bodyCSS; + public $bodyCSS; - public $msgid; - public $headers; - public $message; - /** + public $msgid; + public $headers; + public $message; + /** * @var array fullfilenames list (full path of filename on file system) */ public $filename_list = array(); @@ -95,21 +95,21 @@ class CMailFile public $mimefilename_list = array(); // Image - public $html; - public $image_boundary; - public $atleastoneimage = 0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used). - public $html_images = array(); - public $images_encoded = array(); - public $image_types = array( - 'gif' => 'image/gif', + public $html; + public $image_boundary; + public $atleastoneimage = 0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used). + public $html_images = array(); + public $images_encoded = array(); + public $image_types = array( + 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'bmp' => 'image/bmp', 'png' => 'image/png', 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - ); + 'tiff' => 'image/tiff', + ); /** @@ -147,7 +147,7 @@ class CMailFile // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; - $this->subject = $subject; + $this->subject = $subject; $this->addr_to = $to; $this->addr_from = $from; $this->msg = $msg; @@ -210,8 +210,8 @@ class CMailFile } if (empty($msg)) { - dol_syslog("CMailFile::CMailfile: Try to send an email with empty body"); - $msg = '.'; // Avoid empty message (with empty message content, you will see a multipart structure) + dol_syslog("CMailFile::CMailfile: Try to send an email with empty body"); + $msg = '.'; // Avoid empty message (with empty message content, you will see a multipart structure) } // Detect if message is HTML (use fast method) @@ -291,7 +291,7 @@ class CMailFile // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) { - $addr_bcc.=($addr_bcc?', ':'').$conf->global->MAIN_MAIL_AUTOCOPY_TO; + $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; } // We set all data according to choosed sending method. @@ -411,40 +411,40 @@ class CMailFile $this->smtps = $smtps; } elseif ($this->sendmode == 'swiftmailer') { // Use Swift Mailer library - $host = dol_getprefix('email'); + $host = dol_getprefix('email'); - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php'; - // egulias autoloader lib - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/autoload.php'; + // egulias autoloader lib + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/autoload.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; - // Create the message - //$this->message = Swift_Message::newInstance(); - $this->message = new Swift_Message(); - //$this->message = new Swift_SignedMessage(); - // Adding a trackid header to a message - $headers = $this->message->getHeaders(); - $headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host); - $this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host; - $headerID = $this->msgid; - $msgid = $headers->get('Message-ID'); - $msgid->setId($headerID); - $headers->addIdHeader('References', $headerID); - // TODO if (! empty($moreinheader)) ... + // Create the message + //$this->message = Swift_Message::newInstance(); + $this->message = new Swift_Message(); + //$this->message = new Swift_SignedMessage(); + // Adding a trackid header to a message + $headers = $this->message->getHeaders(); + $headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host); + $this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host; + $headerID = $this->msgid; + $msgid = $headers->get('Message-ID'); + $msgid->setId($headerID); + $headers->addIdHeader('References', $headerID); + // TODO if (! empty($moreinheader)) ... - // Give the message a subject - try { - $result = $this->message->setSubject($this->subject); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } + // Give the message a subject + try { + $result = $this->message->setSubject($this->subject); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } - // Set the From address with an associative array - //$this->message->setFrom(array('john@doe.com' => 'John Doe')); - if (! empty($this->addr_from)) { - try { + // Set the From address with an associative array + //$this->message->setFrom(array('john@doe.com' => 'John Doe')); + if (! empty($this->addr_from)) { + try { if (! empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) { // Prevent email spoofing for smtp server with a strict configuration $regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string @@ -459,35 +459,35 @@ class CMailFile } else { $result = $this->message->setFrom($this->getArrayAddress($this->addr_from)); } - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } - } + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } - // Set the To addresses with an associative array - if (! empty($this->addr_to)) { - try { - $result = $this->message->setTo($this->getArrayAddress($this->addr_to)); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } - } + // Set the To addresses with an associative array + if (! empty($this->addr_to)) { + try { + $result = $this->message->setTo($this->getArrayAddress($this->addr_to)); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } - if (! empty($this->reply_to)) { - try { - $result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to)); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } - } + if (! empty($this->reply_to)) { + try { + $result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to)); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } - try { - $result = $this->message->setCharSet($conf->file->character_set_client); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } + try { + $result = $this->message->setCharSet($conf->file->character_set_client); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } - if (!empty($this->html)) { + if (!empty($this->html)) { if (!empty($css)) { $this->css = $css; $this->buildCSS(); @@ -578,26 +578,26 @@ class CMailFile $sendingmode = $this->sendmode; if ($this->context == 'emailing' && !empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') { - // List of sending methods - $listofmethods = array(); - $listofmethods['mail'] = 'PHP mail function'; - //$listofmethods['simplemail']='Simplemail class'; - $listofmethods['smtps'] = 'SMTP/SMTPS socket library'; + // List of sending methods + $listofmethods = array(); + $listofmethods['mail'] = 'PHP mail function'; + //$listofmethods['simplemail']='Simplemail class'; + $listofmethods['smtps'] = 'SMTP/SMTPS socket library'; - // EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent. - // You ensure that every user is using its own SMTP server when using the mass emailing module. - $linktoadminemailbefore = ''; - $linktoadminemailend = ''; - $this->error = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]); - $this->errors[] = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]); - $this->error .= '
'.$langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']); - $this->errors[] = $langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']); - if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) - { - $this->error .= '
'.$langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS); - $this->errors[] = $langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS); - } - return false; + // EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent. + // You ensure that every user is using its own SMTP server when using the mass emailing module. + $linktoadminemailbefore = ''; + $linktoadminemailend = ''; + $this->error = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]); + $this->errors[] = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]); + $this->error .= '
'.$langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']); + $this->errors[] = $langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']); + if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) + { + $this->error .= '
'.$langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS); + $this->errors[] = $langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS); + } + return false; } // Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL @@ -828,9 +828,9 @@ class CMailFile } } elseif ($this->sendmode == 'swiftmailer') { - // Use Swift Mailer library - // ------------------------------------------ - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; + // Use Swift Mailer library + // ------------------------------------------ + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; // Clean parameters if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver = ini_get('SMTP'); @@ -849,22 +849,22 @@ class CMailFile //$smtps->_msgReplyTo = 'reply@web.com'; // Switch content encoding to base64 - avoid the doubledot issue with quoted-printable - $contentEncoderBase64 = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); - $this->message->setEncoder($contentEncoderBase64); + $contentEncoderBase64 = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + $this->message->setEncoder($contentEncoderBase64); // Create the Mailer using your created Transport $this->mailer = new Swift_Mailer($this->transport); - // DKIM SIGN - if ($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) { - $privateKey = $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; - $domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; - $selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; - $signer = new Swift_Signers_DKIMSigner($privateKey, $domainName, $selector); - $this->message->attachSigner($signer->ignoreHeader('Return-Path')); - } + // DKIM SIGN + if ($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) { + $privateKey = $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; + $domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; + $selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; + $signer = new Swift_Signers_DKIMSigner($privateKey, $domainName, $selector); + $this->message->attachSigner($signer->ignoreHeader('Return-Path')); + } - if (!empty($conf->global->MAIN_MAIL_DEBUG)) { + if (!empty($conf->global->MAIN_MAIL_DEBUG)) { // To use the ArrayLogger $this->logger = new Swift_Plugins_Loggers_ArrayLogger(); // Or to use the Echo Logger @@ -924,7 +924,7 @@ class CMailFile return '=?'.$conf->file->character_set_client.'?B?'.base64_encode($stringtoencode).'?='; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read a file on disk and return encoded content for emails (mode = 'mail') * @@ -933,7 +933,7 @@ class CMailFile */ private function _encode_file($sourcefile) { - // phpcs:enable + // phpcs:enable $newsourcefile = dol_osencode($sourcefile); if (is_readable($newsourcefile)) @@ -949,7 +949,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write content of a SMTP request into a dump file (mode = all) * Used for debugging. @@ -959,7 +959,7 @@ class CMailFile */ public function dump_mail() { - // phpcs:enable + // phpcs:enable global $conf, $dolibarr_main_data_root; if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir @@ -1040,7 +1040,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create SMTP headers (mode = 'mail') * @@ -1048,7 +1048,7 @@ class CMailFile */ public function write_smtpheaders() { - // phpcs:enable + // phpcs:enable global $conf; $out = ""; @@ -1104,7 +1104,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create header MIME (mode = 'mail') * @@ -1114,7 +1114,7 @@ class CMailFile */ public function write_mimeheaders($filename_list, $mimefilename_list) { - // phpcs:enable + // phpcs:enable $mimedone = 0; $out = ""; @@ -1135,7 +1135,7 @@ class CMailFile return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return email content (mode = 'mail') * @@ -1144,7 +1144,7 @@ class CMailFile */ public function write_body($msgtext) { - // phpcs:enable + // phpcs:enable global $conf; $out = ''; @@ -1235,7 +1235,7 @@ class CMailFile return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Attach file to email (mode = 'mail') * @@ -1246,7 +1246,7 @@ class CMailFile */ public function write_files($filename_list, $mimetype_list, $mimefilename_list) { - // phpcs:enable + // phpcs:enable $out = ''; $filename_list_size = count($filename_list); @@ -1282,7 +1282,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Attach an image to email (mode = 'mail') * @@ -1291,7 +1291,7 @@ class CMailFile */ public function write_images($images_list) { - // phpcs:enable + // phpcs:enable $out = ''; if (is_array($images_list)) @@ -1315,7 +1315,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Try to create a socket connection * @@ -1325,7 +1325,7 @@ class CMailFile */ public function check_server_port($host, $port) { - // phpcs:enable + // phpcs:enable global $conf; $_retVal = 0; @@ -1356,7 +1356,7 @@ class CMailFile dol_syslog("Try socket connection to host=".$host." port=".$port); //See if we can connect to the SMTP server - if ($socket = @fsockopen( + if ($socket = @fsockopen( $host, // Host to test, IP or domain. Add ssl:// for SSL/TLS. $port, // which Port number to use $errno, // actual system level error @@ -1377,7 +1377,7 @@ class CMailFile return $_retVal; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * This function has been modified as provided by SirSir to allow multiline responses when * using SMTP Extensions. @@ -1388,7 +1388,7 @@ class CMailFile */ public function server_parse($socket, $response) { - // phpcs:enable + // phpcs:enable $_retVal = true; // Indicates if Object was created or not $server_response = ''; @@ -1512,8 +1512,8 @@ class CMailFile * If format 2: 'john@doe.com' * If format 3: '' or '"John Doe" ' or '"=?UTF-8?B?Sm9obiBEb2U=?=" ' * If format 4: 'John Doe' or 'john@doe.com' if no label exists - * If format 5: John Doe or john@doe.com if no label exists - * @see getArrayAddress() + * If format 5: John Doe or john@doe.com if no label exists + * @see getArrayAddress() */ public static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0) { @@ -1541,10 +1541,10 @@ class CMailFile $i++; $newemail = ''; - if ($format == 5) { - $newemail = $name ? $name : $email; - $newemail = ''.$newemail.''; - } + if ($format == 5) { + $newemail = $name ? $name : $email; + $newemail = ''.$newemail.''; + } if ($format == 4) { $newemail = $name ? $name : $email; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8b7baaee7c9..d3abceb7097 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -222,9 +222,9 @@ abstract class CommonObject * @var string * @see getFullAddress(), isInEEC(), country */ - public $country_code; + public $country_code; - /** + /** * @var string * @see getFullAddress() */ @@ -240,7 +240,7 @@ abstract class CommonObject * @var string * @see getFullAddress(), $state */ - public $state_code; + public $state_code; /** * @var int @@ -252,15 +252,15 @@ abstract class CommonObject * @var string * @see getFullAddress(), $region_id, $region */ - public $region_code; + public $region_code; - /** - * @var string - * @see getFullAddress(), $region_id, $region_code - */ - public $region; + /** + * @var string + * @see getFullAddress(), $region_id, $region_code + */ + public $region; - /** + /** * @var int * @see fetch_barcode() */ @@ -416,25 +416,25 @@ abstract class CommonObject */ public $name; - /** - * @var string The lastname - */ + /** + * @var string The lastname + */ public $lastname; - /** - * @var string The firstname - */ + /** + * @var string The firstname + */ public $firstname; - /** - * @var string The civility code, not an integer - */ + /** + * @var string The civility code, not an integer + */ public $civility_id; // Dates /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creation; /** @@ -521,16 +521,16 @@ abstract class CommonObject */ public function getFormatedCustomerRef($objref) { - global $hookmanager; + global $hookmanager; - $parameters = array('objref'=>$objref); - $action = ''; - $reshook = $hookmanager->executeHooks('getFormatedCustomerRef', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) - { - return $hookmanager->resArray['objref']; - } - return $objref.(isset($hookmanager->resArray['objref']) ? $hookmanager->resArray['objref'] : ''); + $parameters = array('objref'=>$objref); + $action = ''; + $reshook = $hookmanager->executeHooks('getFormatedCustomerRef', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) + { + return $hookmanager->resArray['objref']; + } + return $objref.(isset($hookmanager->resArray['objref']) ? $hookmanager->resArray['objref'] : ''); } /** @@ -541,16 +541,16 @@ abstract class CommonObject */ public function getFormatedSupplierRef($objref) { - global $hookmanager; + global $hookmanager; - $parameters = array('objref'=>$objref); - $action = ''; - $reshook = $hookmanager->executeHooks('getFormatedSupplierRef', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) - { - return $hookmanager->resArray['objref']; - } - return $objref.(isset($hookmanager->resArray['objref']) ? $hookmanager->resArray['objref'] : ''); + $parameters = array('objref'=>$objref); + $action = ''; + $reshook = $hookmanager->executeHooks('getFormatedSupplierRef', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) + { + return $hookmanager->resArray['objref']; + } + return $objref.(isset($hookmanager->resArray['objref']) ? $hookmanager->resArray['objref'] : ''); } /** @@ -622,15 +622,15 @@ abstract class CommonObject $this->country = $tmparray['label']; } - if ($withregion && $this->state_id && (empty($this->state_code) || empty($this->state) || empty($this->region) || empty($this->region_code))) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - $tmparray = getState($this->state_id, 'all', 0, 1); + if ($withregion && $this->state_id && (empty($this->state_code) || empty($this->state) || empty($this->region) || empty($this->region_code))) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + $tmparray = getState($this->state_id, 'all', 0, 1); $this->state_code = $tmparray['code']; $this->state = $tmparray['label']; $this->region_code = $tmparray['region_code']; $this->region = $tmparray['region']; - } + } return dol_format_address($this, $withcountry, $sep, '', 0, $extralangcode); } @@ -703,7 +703,7 @@ abstract class CommonObject if (!empty($extralanguages->attributes[$elementforaltlanguage]['address']) || !empty($extralanguages->attributes[$elementforaltlanguage]['town'])) { - $out .= "\n"; + $out .= "\n"; $this->fetchValuesForExtraLanguages(); if (!is_object($form)) $form = new Form($this->db); $htmltext = ''; @@ -721,11 +721,11 @@ abstract class CommonObject if (!in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress && empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) { - if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) { - $out .= ($outdone ? ' - ' : '').$this->region.' - '.$this->state; - } else { - $out .= ($outdone ? ' - ' : '').$this->state; - } + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) { + $out .= ($outdone ? ' - ' : '').$this->region.' - '.$this->state; + } else { + $out .= ($outdone ? ' - ' : '').$this->state; + } $outdone++; } @@ -764,8 +764,8 @@ abstract class CommonObject } if (!empty($this->url)) { - //$out.=dol_print_url($this->url,'_goout',0,1);//steve changed to blank - $out .= dol_print_url($this->url, '_blank', 0, 1); + //$out.=dol_print_url($this->url,'_goout',0,1);//steve changed to blank + $out .= dol_print_url($this->url, '_blank', 0, 1); $outdone++; } @@ -890,7 +890,7 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a link between element $this->element and a contact * @@ -902,7 +902,7 @@ abstract class CommonObject */ public function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $user, $langs; @@ -1007,7 +1007,7 @@ abstract class CommonObject } else return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Copy contact from one element to current * @@ -1017,7 +1017,7 @@ abstract class CommonObject */ public function copy_linked_contact($objFrom, $source = 'internal') { - // phpcs:enable + // phpcs:enable $contacts = $objFrom->liste_contact(-1, $source); foreach ($contacts as $contact) { @@ -1030,7 +1030,7 @@ abstract class CommonObject return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a link to contact line * @@ -1042,7 +1042,7 @@ abstract class CommonObject */ public function update_contact($rowid, $statut, $type_contact_id = 0, $fk_socpeople = 0) { - // phpcs:enable + // phpcs:enable // Insert into database $sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set"; $sql .= " statut = ".$statut; @@ -1059,7 +1059,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a link to contact line * @@ -1069,7 +1069,7 @@ abstract class CommonObject */ public function delete_contact($rowid, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $user; @@ -1096,7 +1096,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete all links between an object $this and all its contacts * @@ -1106,7 +1106,7 @@ abstract class CommonObject */ public function delete_linked_contact($source = '', $code = '') { - // phpcs:enable + // phpcs:enable $temp = array(); $typeContact = $this->liste_type_contact($source, '', 0, 0, $code); @@ -1131,7 +1131,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get array of all contacts for an object * @@ -1143,7 +1143,7 @@ abstract class CommonObject */ public function liste_contact($status = -1, $source = 'external', $list = 0, $code = '') { - // phpcs:enable + // phpcs:enable global $langs; $tab = array(); @@ -1234,7 +1234,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return array with list of possible values for type of contacts * @@ -1247,7 +1247,7 @@ abstract class CommonObject */ public function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '') { - // phpcs:enable + // phpcs:enable global $langs; if (empty($order)) $order = 'position'; @@ -1430,7 +1430,7 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object contact with id=$this->contact_id into $this->contact * @@ -1439,7 +1439,7 @@ abstract class CommonObject */ public function fetch_contact($contactid = null) { - // phpcs:enable + // phpcs:enable if (empty($contactid)) $contactid = $this->contact_id; if (empty($contactid)) return 0; @@ -1451,7 +1451,7 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty * @@ -1460,7 +1460,7 @@ abstract class CommonObject */ public function fetch_thirdparty($force_thirdparty_id = 0) { - // phpcs:enable + // phpcs:enable global $conf; if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) @@ -1513,7 +1513,7 @@ abstract class CommonObject return $this->fetch($result->rowid); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load data for barcode into properties ->barcode_type* * Properties ->barcode_type that is id of barcode. Type is used to find other properties, but @@ -1523,7 +1523,7 @@ abstract class CommonObject */ public function fetch_barcode() { - // phpcs:enable + // phpcs:enable global $conf; dol_syslog(get_class($this).'::fetch_barcode this->element='.$this->element.' this->barcode_type='.$this->barcode_type); @@ -1562,7 +1562,7 @@ abstract class CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the project with id $this->fk_project into this->project * @@ -1570,7 +1570,7 @@ abstract class CommonObject */ public function fetch_projet() { - // phpcs:enable + // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; if (empty($this->fk_project) && !empty($this->fk_projet)) $this->fk_project = $this->fk_projet; // For backward compatibility @@ -1584,7 +1584,7 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the product with id $this->fk_product into this->product * @@ -1592,7 +1592,7 @@ abstract class CommonObject */ public function fetch_product() { - // phpcs:enable + // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; if (empty($this->fk_product)) return 0; @@ -1604,7 +1604,7 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the user with id $userid into this->user * @@ -1613,14 +1613,14 @@ abstract class CommonObject */ public function fetch_user($userid) { - // phpcs:enable + // phpcs:enable $user = new User($this->db); $result = $user->fetch($userid); $this->user = $user; return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read linked origin object * @@ -1628,10 +1628,10 @@ abstract class CommonObject */ public function fetch_origin() { - // phpcs:enable + // phpcs:enable if ($this->origin == 'shipping') $this->origin = 'expedition'; if ($this->origin == 'delivery') $this->origin = 'livraison'; - if ($this->origin == 'order_supplier') $this->origin = 'commandeFournisseur'; + if ($this->origin == 'order_supplier') $this->origin = 'commandeFournisseur'; $origin = $this->origin; @@ -1641,14 +1641,14 @@ abstract class CommonObject } /** - * Load object from specific field - * - * @param string $table Table element or element line - * @param string $field Field selected - * @param string $key Import key - * @param string $element Element name - * @return int <0 if KO, >0 if OK - */ + * Load object from specific field + * + * @param string $table Table element or element line + * @param string $field Field selected + * @param string $key Import key + * @param string $element Element name + * @return int <0 if KO, >0 if OK + */ public function fetchObjectFrom($table, $field, $key, $element = null) { global $conf; @@ -1783,7 +1783,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load properties id_previous and id_next by comparing $fieldid with $this->ref * @@ -1794,7 +1794,7 @@ abstract class CommonObject */ public function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0) { - // phpcs:enable + // phpcs:enable global $conf, $user; if (!$this->table_element) @@ -1824,7 +1824,7 @@ abstract class CommonObject } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; - $sql .= " WHERE te.".$fieldid." < '".$this->db->escape($fieldid=='rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) + $sql .= " WHERE te.".$fieldid." < '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; if (!empty($filter)) @@ -1877,7 +1877,7 @@ abstract class CommonObject } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; - $sql .= " WHERE te.".$fieldid." > '".$this->db->escape($fieldid=='rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) + $sql .= " WHERE te.".$fieldid." > '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; if (!empty($filter)) @@ -2217,29 +2217,29 @@ abstract class CommonObject */ public function setRetainedWarrantyPaymentTerms($id) { - dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms('.$id.')'); - if ($this->statut >= 0 || $this->element == 'societe') - { - $fieldname = 'retained_warranty_fk_cond_reglement'; + dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms('.$id.')'); + if ($this->statut >= 0 || $this->element == 'societe') + { + $fieldname = 'retained_warranty_fk_cond_reglement'; - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.$id; - $sql .= ' WHERE rowid='.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = '.$id; + $sql .= ' WHERE rowid='.$this->id; - if ($this->db->query($sql)) - { - $this->retained_warranty_fk_cond_reglement = $id; - return 1; - } else { - dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms Erreur '.$sql.' - '.$this->db->error()); - $this->error = $this->db->error(); - return -1; - } - } else { - dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms, status of the object is incompatible'); - $this->error = 'Status of the object is incompatible '.$this->statut; - return -2; - } + if ($this->db->query($sql)) + { + $this->retained_warranty_fk_cond_reglement = $id; + return 1; + } else { + dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms Erreur '.$sql.' - '.$this->db->error()); + $this->error = $this->db->error(); + return -1; + } + } else { + dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms, status of the object is incompatible'); + $this->error = 'Status of the object is incompatible '.$this->statut; + return -2; + } } /** @@ -2384,7 +2384,7 @@ abstract class CommonObject if ($resql) { $this->model_pdf = $modelpdf; - $this->modelpdf = $modelpdf; // For bakward compatibility + $this->modelpdf = $modelpdf; // For bakward compatibility return 1; } else { dol_print_error($this->db); @@ -2452,7 +2452,7 @@ abstract class CommonObject // TODO: Move line related operations to CommonObjectLine? - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Save a new position (field rang) for details lines. * You can choose to set position for lines with already a position or lines without any position defined. @@ -2464,7 +2464,7 @@ abstract class CommonObject */ public function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line = true) { - // phpcs:enable + // phpcs:enable if (!$this->table_element_line) { dol_syslog(get_class($this)."::line_order was called on objet with property table_element_line not defined", LOG_ERR); @@ -2568,7 +2568,7 @@ abstract class CommonObject return $rows; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a line to have a lower rank * @@ -2578,7 +2578,7 @@ abstract class CommonObject */ public function line_up($rowid, $fk_parent_line = true) { - // phpcs:enable + // phpcs:enable $this->line_order(false, 'ASC', $fk_parent_line); // Get rang of line @@ -2588,7 +2588,7 @@ abstract class CommonObject $this->updateLineUp($rowid, $rang); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a line to have a higher rank * @@ -2598,7 +2598,7 @@ abstract class CommonObject */ public function line_down($rowid, $fk_parent_line = true) { - // phpcs:enable + // phpcs:enable $this->line_order(false, 'ASC', $fk_parent_line); // Get rang of line @@ -2633,7 +2633,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update position of line with ajax (rang) * @@ -2642,7 +2642,7 @@ abstract class CommonObject */ public function line_ajaxorder($rows) { - // phpcs:enable + // phpcs:enable $num = count($rows); for ($i = 0; $i < $num; $i++) { @@ -2752,7 +2752,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get max value used for position of line (rang) * @@ -2761,8 +2761,8 @@ abstract class CommonObject */ public function line_max($fk_parent_line = 0) { - // phpcs:enable - $positionfield = 'rang'; + // phpcs:enable + $positionfield = 'rang'; if ($this->table_element == 'bom') $positionfield = 'position'; // Search the last rang with fk_parent_line @@ -2800,7 +2800,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update external ref of element * @@ -2809,7 +2809,7 @@ abstract class CommonObject */ public function update_ref_ext($ref_ext) { - // phpcs:enable + // phpcs:enable if (!$this->table_element) { dol_syslog(get_class($this)."::update_ref_ext was called on objet with property table_element not defined", LOG_ERR); @@ -2831,7 +2831,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update note of element * @@ -2841,7 +2841,7 @@ abstract class CommonObject */ public function update_note($note, $suffix = '') { - // phpcs:enable + // phpcs:enable global $user; if (!$this->table_element) @@ -2883,7 +2883,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update public note (kept for backward compatibility) * @@ -2894,11 +2894,11 @@ abstract class CommonObject */ public function update_note_public($note) { - // phpcs:enable + // phpcs:enable return $this->update_note($note, '_public'); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines). * Must be called at end of methods addline or updateline. @@ -2911,16 +2911,16 @@ abstract class CommonObject */ public function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null) { - // phpcs:enable + // phpcs:enable global $conf, $hookmanager, $action; - $parameters = array('exclspec' => $exclspec, 'roundingadjust' => $roundingadjust, 'nodatabaseupdate' => $nodatabaseupdate, 'seller' => $seller); - $reshook = $hookmanager->executeHooks('updateTotalPrice', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) { - return 1; // replacement code - } elseif ($reshook < 0) { - return -1; // failure - } // reshook = 0 => execute normal code + $parameters = array('exclspec' => $exclspec, 'roundingadjust' => $roundingadjust, 'nodatabaseupdate' => $nodatabaseupdate, 'seller' => $seller); + $reshook = $hookmanager->executeHooks('updateTotalPrice', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + return 1; // replacement code + } elseif ($reshook < 0) { + return -1; // failure + } // reshook = 0 => execute normal code // Some external module want no update price after a trigger because they have another method to calculate the total (ex: with an extrafield) $MODULE = ""; @@ -3803,7 +3803,7 @@ abstract class CommonObject } $weight = $line->weight ? $line->weight : 0; - ($weight == 0 && !empty($line->product->weight)) ? $weight = $line->product->weight : 0; + ($weight == 0 && !empty($line->product->weight)) ? $weight = $line->product->weight : 0; $volume = $line->volume ? $line->volume : 0; ($volume == 0 && !empty($line->product->volume)) ? $volume = $line->product->volume : 0; @@ -3882,7 +3882,7 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return incoterms informations * TODO Use a cache for label get @@ -3891,7 +3891,7 @@ abstract class CommonObject */ public function display_incoterms() { - // phpcs:enable + // phpcs:enable $out = ''; $this->label_incoterms = ''; if (!empty($this->fk_incoterms)) @@ -4275,8 +4275,8 @@ abstract class CommonObject print ''.$langs->trans('Unit').''; } print ''.$langs->trans('ReductionShort').''; - print ''.$form->showCheckAddButtons('checkforselect', 1).''; - print ''; + print ''.$form->showCheckAddButtons('checkforselect', 1).''; + print ''; $i = 0; if (!empty($this->lines)) @@ -4333,7 +4333,7 @@ abstract class CommonObject if ($line->date_fin_reel) $date_end = $line->date_fin_reel; } - $this->tpl['id'] = $line->id; + $this->tpl['id'] = $line->id; $this->tpl['label'] = ''; if (!empty($line->fk_parent_line)) $this->tpl['label'] .= img_picto('', 'rightarrow'); @@ -4405,10 +4405,10 @@ abstract class CommonObject $this->tpl['description'] = ' '; } - // VAT Rate - $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); - $this->tpl['vat_rate'] .= (($line->info_bits & 1) == 1) ? '*' : ''; - if (!empty($line->vat_src_code) && !preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'] .= ' ('.$line->vat_src_code.')'; + // VAT Rate + $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); + $this->tpl['vat_rate'] .= (($line->info_bits & 1) == 1) ? '*' : ''; + if (!empty($line->vat_src_code) && !preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'] .= ' ('.$line->vat_src_code.')'; $this->tpl['price'] = price($line->subprice); $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); @@ -4442,7 +4442,7 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add resources to the current object : add entry into llx_element_resources * Need $this->element & $this->id @@ -4455,7 +4455,7 @@ abstract class CommonObject */ public function add_element_resource($resource_id, $resource_type, $busy = 0, $mandatory = 0) { - // phpcs:enable + // phpcs:enable $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_resources ("; @@ -4486,7 +4486,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a link to resource line * @@ -4497,7 +4497,7 @@ abstract class CommonObject */ public function delete_resource($rowid, $element, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $user; $this->db->begin(); @@ -4797,7 +4797,7 @@ abstract class CommonObject return -1; } } else { - if (! $filefound) { + if (!$filefound) { $this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele; dol_print_error('', $this->error); } else { @@ -5287,7 +5287,7 @@ abstract class CommonObject if ($this->array_options[$key] === '') $mandatorypb = true; if ($mandatorypb) { - dol_syslog("Mandatory extra field ".$key." is empty"); + dol_syslog("Mandatory extra field ".$key." is empty"); $this->errors[] = $langs->trans('ErrorFieldRequired', $attributeLabel); return -1; } @@ -5301,8 +5301,8 @@ abstract class CommonObject if (!empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { $value = dol_eval($attrfieldcomputed, 1, 0); - dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG); - $new_array_options[$key] = $value; + dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG); + $new_array_options[$key] = $value; } else { $new_array_options[$key] = null; } @@ -5433,13 +5433,13 @@ abstract class CommonObject // We must insert a default value for fields for other entities that are mandatory to avoid not null error if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) { - foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) - { - if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously - { - $sql .= ",".$tmpkey; - } - } + foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) + { + if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously + { + $sql .= ",".$tmpkey; + } + } } $sql .= ") VALUES (".$this->id; @@ -5460,14 +5460,14 @@ abstract class CommonObject // We must insert a default value for fields for other entities that are mandatory to avoid not null error if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) { - foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) - { - if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously - { - if (in_array($tmpval, array('int', 'double', 'price'))) $sql .= ", 0"; - else $sql .= ", ''"; - } - } + foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) + { + if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously + { + if (in_array($tmpval, array('int', 'double', 'price'))) $sql .= ", 0"; + else $sql .= ", ''"; + } + } } $sql .= ")"; @@ -5796,38 +5796,38 @@ abstract class CommonObject } $out = ''; - $type = ''; - $param = array(); - $param['options'] = array(); - $reg = array(); - $size = $this->fields[$key]['size']; - // Because we work on extrafields - if (preg_match('/^(integer|link):(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { - $param['options'] = array($reg[2].':'.$reg[3].':'.$reg[4].':'.$reg[5] => 'N'); - $type = 'link'; - } elseif (preg_match('/^(integer|link):(.*):(.*):(.*)/i', $val['type'], $reg)) { - $param['options'] = array($reg[2].':'.$reg[3].':'.$reg[4] => 'N'); - $type = 'link'; - } elseif (preg_match('/^(integer|link):(.*):(.*)/i', $val['type'], $reg)) { - $param['options'] = array($reg[2].':'.$reg[3] => 'N'); - $type = 'link'; - } elseif (preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { - $param['options'] = array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4] => 'N'); - $type = 'sellist'; - } elseif (preg_match('/varchar\((\d+)\)/', $val['type'], $reg)) { - $param['options'] = array(); - $type = 'varchar'; - $size = $reg[1]; - } elseif (preg_match('/varchar/', $val['type'])) { - $param['options'] = array(); - $type = 'varchar'; - } elseif (is_array($this->fields[$key]['arrayofkeyval'])) { - $param['options'] = $this->fields[$key]['arrayofkeyval']; - $type = 'select'; - } else { - $param['options'] = array(); - $type = $this->fields[$key]['type']; - } + $type = ''; + $param = array(); + $param['options'] = array(); + $reg = array(); + $size = $this->fields[$key]['size']; + // Because we work on extrafields + if (preg_match('/^(integer|link):(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[2].':'.$reg[3].':'.$reg[4].':'.$reg[5] => 'N'); + $type = 'link'; + } elseif (preg_match('/^(integer|link):(.*):(.*):(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[2].':'.$reg[3].':'.$reg[4] => 'N'); + $type = 'link'; + } elseif (preg_match('/^(integer|link):(.*):(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[2].':'.$reg[3] => 'N'); + $type = 'link'; + } elseif (preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4] => 'N'); + $type = 'sellist'; + } elseif (preg_match('/varchar\((\d+)\)/', $val['type'], $reg)) { + $param['options'] = array(); + $type = 'varchar'; + $size = $reg[1]; + } elseif (preg_match('/varchar/', $val['type'])) { + $param['options'] = array(); + $type = 'varchar'; + } elseif (is_array($this->fields[$key]['arrayofkeyval'])) { + $param['options'] = $this->fields[$key]['arrayofkeyval']; + $type = 'select'; + } else { + $param['options'] = array(); + $type = $this->fields[$key]['type']; + } $label = $this->fields[$key]['label']; //$elementtype=$this->fields[$key]['elementtype']; // Seems not used @@ -5852,7 +5852,7 @@ abstract class CommonObject // Set value of $morecss. For this, we use in priority showsize from parameters, then $val['css'] then autodefine if (empty($morecss) && !empty($val['css'])) { - $morecss = $val['css']; + $morecss = $val['css']; } elseif (empty($morecss)) { if ($type == 'date') @@ -5962,7 +5962,7 @@ abstract class CommonObject } $out .= ''; + $ret .= ''; - if (empty($conf->dol_optimize_smallscreen)) $ret .= ajax_combobox('.' . $name . 'select'); + if (empty($conf->dol_optimize_smallscreen)) $ret .= ajax_combobox('.'.$name.'select'); // Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button $ret .= ''; // Hidden button BEFORE so it is the one used when we submit with ENTER. - $ret .= ''; + $ret .= ''; $ret .= '
'; if (!empty($conf->use_javascript_ajax)) @@ -701,11 +701,11 @@ class Form } jQuery(document).ready(function () { - initCheckForSelect(0, "' . $name . '", "' . $cssclass . '"); - jQuery(".' . $cssclass . '").click(function() { - initCheckForSelect(1, "'.$name.'", "' . $cssclass . '"); + initCheckForSelect(0, "' . $name.'", "'.$cssclass.'"); + jQuery(".' . $cssclass.'").click(function() { + initCheckForSelect(1, "'.$name.'", "'.$cssclass.'"); }); - jQuery(".' . $name . 'select").change(function() { + jQuery(".' . $name.'select").change(function() { var massaction = $( this ).val(); var urlform = $( this ).closest("form").attr("action").replace("#show_files",""); if (massaction == "builddoc") @@ -717,14 +717,14 @@ class Form /* Warning: if you set submit button to disabled, post using Enter will no more work if there is no other button */ if ($(this).val() != \'0\') { - jQuery(".' . $name . 'confirmed").prop(\'disabled\', false); - jQuery(".' . $name . 'other").hide(); /* To disable if another div was open */ - jQuery(".' . $name . '"+massaction).show(); + jQuery(".' . $name.'confirmed").prop(\'disabled\', false); + jQuery(".' . $name.'other").hide(); /* To disable if another div was open */ + jQuery(".' . $name.'"+massaction).show(); } else { - jQuery(".' . $name . 'confirmed").prop(\'disabled\', true); - jQuery(".' . $name . 'other").hide(); /* To disable any div open */ + jQuery(".' . $name.'confirmed").prop(\'disabled\', true); + jQuery(".' . $name.'other").hide(); /* To disable any div open */ } }); }); @@ -2052,7 +2052,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of products for a customer * @@ -2076,18 +2076,18 @@ class Form * 'warehouseinternal' = count products from warehouses for internal correct/transfer only * @return array Array of keys for json */ - public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') + public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf, $user, $db; $out = ''; $outarray = array(); - // Units - if ($conf->global->PRODUCT_USE_UNITS) { - $langs->load('other'); - } + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $langs->load('other'); + } $warehouseStatusArray = array(); if (!empty($warehouseStatus)) @@ -2110,9 +2110,9 @@ class Form $selectFields = " p.rowid, p.ref, p.label, p.description, p.barcode, p.fk_country, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.fk_price_expression"; if (count($warehouseStatusArray)) { - $selectFieldsGrouped = ", sum(".$db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock + $selectFieldsGrouped = ", sum(".$db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock } else { - $selectFieldsGrouped = ", ".$db->ifsql("p.stock IS NULL", 0, "p.stock")." AS stock"; + $selectFieldsGrouped = ", ".$db->ifsql("p.stock IS NULL", 0, "p.stock")." AS stock"; } $sql = "SELECT "; @@ -2135,11 +2135,11 @@ class Form $sql .= ' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx'; $selectFields .= ", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx"; } - // Units - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; - $selectFields .= ', unit_long, unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units'; - } + // Units + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; + $selectFields .= ', unit_long, unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units'; + } // Multilang : we add translation if (!empty($conf->global->MAIN_MULTILANGS)) @@ -2171,17 +2171,17 @@ class Form // include search in supplier ref if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; } //Price by customer if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_customer_price as pcp ON pcp.fk_soc=".$socid." AND pcp.fk_product=p.rowid"; } - // Units - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; - } + // Units + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; + } // Multilang : we add translation if (!empty($conf->global->MAIN_MULTILANGS)) { @@ -2289,7 +2289,7 @@ class Form if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); else $textifempty .= $langs->trans("All"); } else { - if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); + if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); } if ($showempty) $out .= ''; @@ -2429,43 +2429,43 @@ class Form if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - // Units - $outvalUnits = ''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - if (!empty($objp->unit_short)) { - $outvalUnits .= ' - '.$objp->unit_short; - } - } - if (!empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) { - if (!empty($objp->weight) && $objp->weight_units !== null) { - $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); - $outvalUnits .= ' - '.$unitToShow; - } - if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { - $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); - $outvalUnits .= ' - '.$unitToShow; - } - if (!empty($objp->surface) && $objp->surface_units !== null) { - $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); - $outvalUnits .= ' - '.$unitToShow; - } - if (!empty($objp->volume) && $objp->volume_units !== null) { - $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); - $outvalUnits .= ' - '.$unitToShow; - } - } - if ($outdurationvalue && $outdurationunit) { - $da = array( - 'h' => $langs->trans('Hour'), - 'd' => $langs->trans('Day'), - 'w' => $langs->trans('Week'), - 'm' => $langs->trans('Month'), - 'y' => $langs->trans('Year') - ); - if (isset($da[$outdurationunit])) { - $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); - } - } + // Units + $outvalUnits = ''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (!empty($objp->unit_short)) { + $outvalUnits .= ' - '.$objp->unit_short; + } + } + if (!empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) { + if (!empty($objp->weight) && $objp->weight_units !== null) { + $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); + $outvalUnits .= ' - '.$unitToShow; + } + if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { + $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); + $outvalUnits .= ' - '.$unitToShow; + } + if (!empty($objp->surface) && $objp->surface_units !== null) { + $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); + $outvalUnits .= ' - '.$unitToShow; + } + if (!empty($objp->volume) && $objp->volume_units !== null) { + $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); + $outvalUnits .= ' - '.$unitToShow; + } + } + if ($outdurationvalue && $outdurationunit) { + $da = array( + 'h' => $langs->trans('Hour'), + 'd' => $langs->trans('Day'), + 'w' => $langs->trans('Week'), + 'm' => $langs->trans('Month'), + 'y' => $langs->trans('Year') + ); + if (isset($da[$outdurationunit])) { + $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); + } + } $opt = '\n"; $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'pbq'=>$outpbq); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of products for customer (in Ajax if Ajax activated or go to select_produits_fournisseurs_list) * @@ -2668,9 +2668,9 @@ class Form * @param string $morecss More CSS * @return void */ - public function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '') + public function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf; global $price_level, $status, $finished; @@ -2695,7 +2695,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of suppliers products * @@ -2712,9 +2712,9 @@ class Form * @param string $morecss Add more CSS * @return array Array of keys for json */ - public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '') + public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf, $db; $out = ''; @@ -2723,28 +2723,28 @@ class Form $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO); $langs->load('stocks'); - // Units - if ($conf->global->PRODUCT_USE_UNITS) { - $langs->load('other'); - } + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $langs->load('other'); + } $sql = "SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type,"; $sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,"; $sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,"; $sql .= " pfp.supplier_reputation"; - // Units - if ($conf->global->PRODUCT_USE_UNITS) { - $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; - } - if (!empty($conf->barcode->enabled)) $sql .= ", pfp.barcode"; + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; + } + if (!empty($conf->barcode->enabled)) $sql .= ", pfp.barcode"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (".getEntity('product').") )"; if ($socid) $sql .= " AND pfp.fk_soc = ".$socid; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; - // Units - if ($conf->global->PRODUCT_USE_UNITS) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; - } + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; + } $sql .= " WHERE p.entity IN (".getEntity('product').")"; $sql .= " AND p.tobuy = 1"; if (strval($filtertype) != '') $sql .= " AND p.fk_product_type=".$this->db->escape($filtertype); @@ -2766,9 +2766,9 @@ class Form } if (count($scrit) > 1) $sql .= ")"; if (!empty($conf->barcode->enabled)) { - $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; - $sql .= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; - } + $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + $sql .= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + } $sql .= ')'; } $sql .= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC"; @@ -2807,41 +2807,41 @@ class Form $outdurationvalue = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; $outdurationunit = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, -1) : ''; - // Units - $outvalUnits = ''; - if ($conf->global->PRODUCT_USE_UNITS) { - if (!empty($objp->unit_short)) { - $outvalUnits .= ' - '.$objp->unit_short; - } - if (!empty($objp->weight) && $objp->weight_units !== null) { - $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); - $outvalUnits .= ' - '.$unitToShow; - } - if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { - $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); - $outvalUnits .= ' - '.$unitToShow; - } - if (!empty($objp->surface) && $objp->surface_units !== null) { - $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); - $outvalUnits .= ' - '.$unitToShow; - } - if (!empty($objp->volume) && $objp->volume_units !== null) { - $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); - $outvalUnits .= ' - '.$unitToShow; - } - if ($outdurationvalue && $outdurationunit) { - $da = array( - 'h' => $langs->trans('Hour'), - 'd' => $langs->trans('Day'), - 'w' => $langs->trans('Week'), - 'm' => $langs->trans('Month'), - 'y' => $langs->trans('Year') - ); - if (isset($da[$outdurationunit])) { - $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); - } - } - } + // Units + $outvalUnits = ''; + if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($objp->unit_short)) { + $outvalUnits .= ' - '.$objp->unit_short; + } + if (!empty($objp->weight) && $objp->weight_units !== null) { + $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); + $outvalUnits .= ' - '.$unitToShow; + } + if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { + $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); + $outvalUnits .= ' - '.$unitToShow; + } + if (!empty($objp->surface) && $objp->surface_units !== null) { + $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); + $outvalUnits .= ' - '.$unitToShow; + } + if (!empty($objp->volume) && $objp->volume_units !== null) { + $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); + $outvalUnits .= ' - '.$unitToShow; + } + if ($outdurationvalue && $outdurationunit) { + $da = array( + 'h' => $langs->trans('Hour'), + 'd' => $langs->trans('Day'), + 'w' => $langs->trans('Week'), + 'm' => $langs->trans('Month'), + 'y' => $langs->trans('Year') + ); + if (isset($da[$outdurationunit])) { + $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); + } + } + } $objRef = $objp->ref; if ($filterkey && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '$1', $objRef, 1); @@ -2868,7 +2868,7 @@ class Form } $outvallabel .= ' - '.dol_trunc($label, $maxlengtharticle); - // Units + // Units $optlabel .= $outvalUnits; $outvallabel .= $outvalUnits; @@ -2992,7 +2992,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of suppliers prices for a product * @@ -3001,9 +3001,9 @@ class Form * @param int $selected_supplier Pre-selected supplier if more than 1 result * @return string */ - public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') + public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf; $langs->load('stocks'); @@ -3099,7 +3099,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of delivery address * @@ -3109,9 +3109,9 @@ class Form * @param int $showempty Add an empty field * @return integer|null */ - public function select_address($selected, $socid, $htmlname = 'address_id', $showempty = 0) + public function select_address($selected, $socid, $htmlname = 'address_id', $showempty = 0) { - // phpcs:enable + // phpcs:enable // looking for users $sql = "SELECT a.rowid, a.label"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_address as a"; @@ -3149,15 +3149,15 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load into cache list of payment terms * * @return int Nb of lines loaded, <0 if KO */ - public function load_cache_conditions_paiements() + public function load_cache_conditions_paiements() { - // phpcs:enable + // phpcs:enable global $langs; $num = count($this->cache_conditions_paiements); @@ -3196,15 +3196,15 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge dans cache la liste des délais de livraison possibles * * @return int Nb of lines loaded, <0 if KO */ - public function load_cache_availability() + public function load_cache_availability() { - // phpcs:enable + // phpcs:enable global $langs; $num = count($this->cache_availability); @@ -3252,7 +3252,7 @@ class Form * @param int $addempty Add empty entry * @return void */ - public function selectAvailabilityDelay($selected = '', $htmlname = 'availid', $filtertype = '', $addempty = 0) + public function selectAvailabilityDelay($selected = '', $htmlname = 'availid', $filtertype = '', $addempty = 0) { global $langs, $user; @@ -3282,7 +3282,7 @@ class Form * * @return int Nb of lines loaded, <0 if KO */ - public function loadCacheInputReason() + public function loadCacheInputReason() { global $langs; @@ -3334,7 +3334,7 @@ class Form * @param int $addempty Add an empty entry * @return void */ - public function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0) + public function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0) { global $langs, $user; @@ -3360,15 +3360,15 @@ class Form if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge dans cache la liste des types de paiements possibles * * @return int Nb of lines loaded, <0 if KO */ - public function load_cache_types_paiements() + public function load_cache_types_paiements() { - // phpcs:enable + // phpcs:enable global $langs; $num = count($this->cache_types_paiements); @@ -3412,7 +3412,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of payment modes. * Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want. @@ -3426,9 +3426,9 @@ class Form * @param string $morecss Add more CSS on select tag * @return void */ - public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '') + public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '') { - // phpcs:enable + // phpcs:enable global $langs, $user, $conf; dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG); @@ -3456,7 +3456,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of payment methods * Constant MAIN_DEFAULT_PAYMENT_TYPE_ID can used to set default value but scope is all application, probably not what you want. @@ -3472,9 +3472,9 @@ class Form * @param string $morecss Add more CSS on select tag * @return void */ - public function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') + public function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') { - // phpcs:enable + // phpcs:enable global $langs, $user, $conf; dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); @@ -3532,7 +3532,7 @@ class Form * @param string $htmlname Nom de la zone select * @return string Code of HTML select to chose tax or not */ - public function selectPriceBaseType($selected = '', $htmlname = 'price_base_type') + public function selectPriceBaseType($selected = '', $htmlname = 'price_base_type') { global $langs; @@ -3568,7 +3568,7 @@ class Form * @param string $moreattrib To add more attribute on select * @return void */ - public function selectShippingMethod($selected = '', $htmlname = 'shipping_method_id', $filtre = '', $useempty = 0, $moreattrib = '') + public function selectShippingMethod($selected = '', $htmlname = 'shipping_method_id', $filtre = '', $useempty = 0, $moreattrib = '') { global $langs, $conf, $user; @@ -3621,7 +3621,7 @@ class Form * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void */ - public function formSelectShippingMethod($page, $selected = '', $htmlname = 'shipping_method_id', $addempty = 0) + public function formSelectShippingMethod($page, $selected = '', $htmlname = 'shipping_method_id', $addempty = 0) { global $langs, $db; @@ -3652,7 +3652,7 @@ class Form * * @return string HTML select */ - public function selectSituationInvoices($selected = '', $socid = 0) + public function selectSituationInvoices($selected = '', $socid = 0) { global $langs; @@ -3673,17 +3673,17 @@ class Form $ref = 0; while ($obj = $this->db->fetch_object($resql)) { //Same cycle ? - if ($obj->situation_cycle_ref != $ref) { + if ($obj->situation_cycle_ref != $ref) { // Just seen this cycle - $ref = $obj->situation_cycle_ref; + $ref = $obj->situation_cycle_ref; //not final ? - if ($obj->situation_final != 1) { + if ($obj->situation_final != 1) { //Not prov? - if (substr($obj->ref, 1, 4) != 'PROV') { - if ($selected == $obj->rowid) { - $opt .= ''; + if (substr($obj->ref, 1, 4) != 'PROV') { + if ($selected == $obj->rowid) { + $opt .= ''; } else { - $opt .= ''; + $opt .= ''; } } } @@ -3707,7 +3707,7 @@ class Form * @param int $showempty Add a nempty line * @return string HTML select */ - public function selectUnits($selected = '', $htmlname = 'units', $showempty = 0) + public function selectUnits($selected = '', $htmlname = 'units', $showempty = 0) { global $langs; @@ -3725,17 +3725,17 @@ class Form while ($res = $this->db->fetch_object($resql)) { - $unitLabel = $res->label; - if (!empty($langs->tab_translate['unit'.$res->code])) // check if Translation is available before - { - $unitLabel = $langs->trans('unit'.$res->code) != $res->label ? $langs->trans('unit'.$res->code) : $res->label; - } + $unitLabel = $res->label; + if (!empty($langs->tab_translate['unit'.$res->code])) // check if Translation is available before + { + $unitLabel = $langs->trans('unit'.$res->code) != $res->label ? $langs->trans('unit'.$res->code) : $res->label; + } if ($selected == $res->rowid) { - $return .= ''; + $return .= ''; } else { - $return .= ''; + $return .= ''; } } $return .= ''; @@ -3743,7 +3743,7 @@ class Form return $return; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a HTML select list of bank accounts * @@ -3757,9 +3757,9 @@ class Form * @param string $morecss More CSS * @return int <0 if error, Num of bank account found if OK (0, 1, 2, ...) */ - public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '') + public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf; $langs->load("admin"); @@ -3826,7 +3826,7 @@ class Form */ public function selectEstablishments($selected = '', $htmlname = 'entity', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf; $langs->load("admin"); @@ -3886,7 +3886,7 @@ class Form * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void */ - public function formSelectAccount($page, $selected = '', $htmlname = 'fk_account', $addempty = 0) + public function formSelectAccount($page, $selected = '', $htmlname = 'fk_account', $addempty = 0) { global $langs; if ($htmlname != "none") { @@ -3910,7 +3910,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of categories having choosed type * @@ -3918,20 +3918,20 @@ class Form * @param string $selected Id of category preselected or 'auto' (autoselect category if there is only one element). Not used if $outputmode = 1. * @param string $htmlname HTML field name * @param int $maxlength Maximum length for labels - * @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id. - * $markafterid can be an : - * - int (id of category) - * - string (categories ids seprated by comma) - * - array (list of categories ids) + * @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id. + * $markafterid can be an : + * - int (id of category) + * - string (categories ids seprated by comma) + * - array (list of categories ids) * @param int $outputmode 0=HTML select string, 1=Array - * @param int $include [=0] Removed or 1=Keep only - * @param string $morecss More CSS + * @param int $include [=0] Removed or 1=Keep only + * @param string $morecss More CSS * @return string * @see select_categories() */ - public function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $markafterid = 0, $outputmode = 0, $include = 0, $morecss = '') + public function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $markafterid = 0, $outputmode = 0, $include = 0, $morecss = '') { - // phpcs:enable + // phpcs:enable global $conf, $langs; $langs->load("categories"); @@ -3966,7 +3966,7 @@ class Form } else dol_print_error($this->db); } else { $cat = new Categorie($this->db); - $cate_arbo = $cat->get_full_arbo($type, $markafterid, $include); + $cate_arbo = $cat->get_full_arbo($type, $markafterid, $include); } $output = ''; - if ($showempty) print ''; - foreach ($listofstatus as $key => $val) - { - print ''; - if ($key == '50' && $onlyselect == 2) - { - print ''; - } - } - print ''; - if ($selected == 0 || $selected == 100) $canedit = 0; - - if (empty($onlyselect)) - { - print ' = 0) ? '' : ' disabled').'>'; - print '%'; - } - } else { - print ' %'; - } - } - - - /** - * Show list of actions for element - * - * @param Object $object Object - * @param string $typeelement 'invoice', 'propal', 'order', 'invoice_supplier', 'order_supplier', 'fichinter' - * @param int $socid Socid of user - * @param int $forceshowtitle Show title even if there is no actions to show - * @param string $morecss More css on table - * @param int $max Max number of record - * @param string $moreparambacktopage More param for the backtopage - * @param string $morehtmlcenter More html text on center of title line - * @return int <0 if KO, >=0 if OK - */ - public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlcenter = '') - { - global $langs, $conf, $user; - - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - - $sortfield = 'a.datep,a.id'; - $sortorder = 'DESC,DESC'; - - $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0)); - if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions'); - - $num = count($listofactions); - if ($num || $forceshowtitle) - { - if ($typeelement == 'invoice') $title = $langs->trans('ActionsOnBill'); - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill'); - elseif ($typeelement == 'propal') $title = $langs->trans('ActionsOnPropal'); - elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal'); - elseif ($typeelement == 'order') $title = $langs->trans('ActionsOnOrder'); - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title = $langs->trans('ActionsOnOrder'); - elseif ($typeelement == 'shipping') $title = $langs->trans('ActionsOnShipping'); - elseif ($typeelement == 'fichinter') $title = $langs->trans('ActionsOnFicheInter'); - elseif ($typeelement == 'project') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); - elseif ($typeelement == 'task') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); - elseif ($typeelement == 'member') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); - else $title = $langs->trans("LatestLinkedEvents", $max ? $max : ''); - - $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : ''); - - $projectid = $object->fk_project; - if ($typeelement == 'project') $projectid = $object->id; - - $newcardbutton = ''; - if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create)) + } + if (!empty($conf->use_javascript_ajax) || $onlyselect) + { + //var_dump($selected); + if ($selected == 'done') $selected = '100'; + print ''; + if ($selected == 0 || $selected == 100) $canedit = 0; + + if (empty($onlyselect)) + { + print ' = 0) ? '' : ' disabled').'>'; + print '%'; + } + } else { + print ' %'; + } + } + + + /** + * Show list of actions for element + * + * @param Object $object Object + * @param string $typeelement 'invoice', 'propal', 'order', 'invoice_supplier', 'order_supplier', 'fichinter' + * @param int $socid Socid of user + * @param int $forceshowtitle Show title even if there is no actions to show + * @param string $morecss More css on table + * @param int $max Max number of record + * @param string $moreparambacktopage More param for the backtopage + * @param string $morehtmlcenter More html text on center of title line + * @return int <0 if KO, >=0 if OK + */ + public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlcenter = '') + { + global $langs, $conf, $user; + + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + + $sortfield = 'a.datep,a.id'; + $sortorder = 'DESC,DESC'; + + $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0)); + if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions'); + + $num = count($listofactions); + if ($num || $forceshowtitle) + { + if ($typeelement == 'invoice') $title = $langs->trans('ActionsOnBill'); + elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill'); + elseif ($typeelement == 'propal') $title = $langs->trans('ActionsOnPropal'); + elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal'); + elseif ($typeelement == 'order') $title = $langs->trans('ActionsOnOrder'); + elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title = $langs->trans('ActionsOnOrder'); + elseif ($typeelement == 'shipping') $title = $langs->trans('ActionsOnShipping'); + elseif ($typeelement == 'fichinter') $title = $langs->trans('ActionsOnFicheInter'); + elseif ($typeelement == 'project') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); + elseif ($typeelement == 'task') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); + elseif ($typeelement == 'member') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); + else $title = $langs->trans("LatestLinkedEvents", $max ? $max : ''); + + $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : ''); + + $projectid = $object->fk_project; + if ($typeelement == 'project') $projectid = $object->id; + + $newcardbutton = ''; + if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create)) + { + $newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage)); } - print ''."\n"; - print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlcenter); + print ''."\n"; + print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlcenter); - $page = 0; $param = ''; + $page = 0; $param = ''; - print '
'; - print ''; - print ''; - print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); - print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); - print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); - print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); - print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1); - print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1); - print ''; - print "\n"; + print '
'; + print '
'; + print ''; + print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1); + print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1); + print ''; + print "\n"; - if (is_array($listofactions) && count($listofactions)) - { - $cacheusers = array(); + if (is_array($listofactions) && count($listofactions)) + { + $cacheusers = array(); - $cursorevent = 0; - foreach ($listofactions as $actioncomm) - { - if ($max && $cursorevent >= $max) break; + $cursorevent = 0; + foreach ($listofactions as $actioncomm) + { + if ($max && $cursorevent >= $max) break; - $ref = $actioncomm->getNomUrl(1, -1); - $label = $actioncomm->getNomUrl(0, 38); + $ref = $actioncomm->getNomUrl(1, -1); + $label = $actioncomm->getNomUrl(0, 38); - print ''; - // Ref + print ''; + // Ref print ''; // Onwer - print ''; + print ''; // Type - print ''; - // Label - print ''; - // Date - print ''; - print ''; - print ''; + print ''; + // Label + print ''; + // Date + print ''; + print ''; + print ''; - $cursorevent++; - } - } else { - print ''; - } + $cursorevent++; + } + } else { + print ''; + } - if ($max && $num > $max) - { - print ''; - } + if ($max && $num > $max) + { + print ''; + } - print '
'.$ref.''; - if (!empty($actioncomm->userownerid)) - { - if (is_object($cacheusers[$actioncomm->userownerid])) - { - $tmpuser = $cacheusers[$actioncomm->userownerid]; - } else { - $tmpuser = new User($this->db); - $tmpuser->fetch($actioncomm->userownerid); - $cacheusers[$actioncomm->userownerid] = $tmpuser; - } - if ($tmpuser->id > 0) - { - print $tmpuser->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); - } - } - print ''; + if (!empty($actioncomm->userownerid)) + { + if (is_object($cacheusers[$actioncomm->userownerid])) + { + $tmpuser = $cacheusers[$actioncomm->userownerid]; + } else { + $tmpuser = new User($this->db); + $tmpuser->fetch($actioncomm->userownerid); + $cacheusers[$actioncomm->userownerid] = $tmpuser; + } + if ($tmpuser->id > 0) + { + print $tmpuser->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); + } + } + print ''; - // TODO Code common with code into comm/action/list.php + print ''; + // TODO Code common with code into comm/action/list.php $imgpicto = ''; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { @@ -281,100 +281,100 @@ class FormActions } else { print $actioncomm->type_short ? $actioncomm->type_short : $actioncomm->type; } - print ''.$label.''.dol_print_date($actioncomm->datep, 'dayhour', 'tzuserrel'); - if ($actioncomm->datef) - { - $tmpa = dol_getdate($actioncomm->datep); - $tmpb = dol_getdate($actioncomm->datef); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) - { - if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($actioncomm->datef, 'hour', 'tzuserrel'); - } else print '-'.dol_print_date($actioncomm->datef, 'dayhour', 'tzuserrel'); - } - print ''; - print $actioncomm->getLibStatut(3); - print '
'.$label.''.dol_print_date($actioncomm->datep, 'dayhour', 'tzuserrel'); + if ($actioncomm->datef) + { + $tmpa = dol_getdate($actioncomm->datep); + $tmpb = dol_getdate($actioncomm->datef); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) + { + if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($actioncomm->datef, 'hour', 'tzuserrel'); + } else print '-'.dol_print_date($actioncomm->datef, 'dayhour', 'tzuserrel'); + } + print ''; + print $actioncomm->getLibStatut(3); + print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'.$langs->trans("More").'...
'.$langs->trans("More").'...
'; - print '
'; - } + print ''; + print ''; + } - return $num; - } + return $num; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Output html select list of type of event - * - * @param array|string $selected Type pre-selected (can be 'manual', 'auto' or 'AC_xxx'). Can be an array too. - * @param string $htmlname Name of select field - * @param string $excludetype A type to exclude ('systemauto', 'system', '') - * @param integer $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual" - * @param int $hideinfohelp 1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value - * @param int $multiselect 1=Allow multiselect of action type - * @param int $nooutput 1=No output - * @param string $morecss More css to add to SELECT component. - * @return string - */ - public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = '') - { - // phpcs:enable - global $langs, $user, $form, $conf; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Output html select list of type of event + * + * @param array|string $selected Type pre-selected (can be 'manual', 'auto' or 'AC_xxx'). Can be an array too. + * @param string $htmlname Name of select field + * @param string $excludetype A type to exclude ('systemauto', 'system', '') + * @param integer $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual" + * @param int $hideinfohelp 1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value + * @param int $multiselect 1=Allow multiselect of action type + * @param int $nooutput 1=No output + * @param string $morecss More css to add to SELECT component. + * @return string + */ + public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = '') + { + // phpcs:enable + global $langs, $user, $form, $conf; - if (!is_object($form)) $form = new Form($this->db); + if (!is_object($form)) $form = new Form($this->db); - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $caction = new CActionComm($this->db); + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + $caction = new CActionComm($this->db); - // Suggest a list with manual events or all auto events - $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot); - if (empty($multiselect)) { - // Add empty line at start only if no multiselect - array_unshift($arraylist, ' '); - } - //asort($arraylist); + // Suggest a list with manual events or all auto events + $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot); + if (empty($multiselect)) { + // Add empty line at start only if no multiselect + array_unshift($arraylist, ' '); + } + //asort($arraylist); - if ($selected == 'manual') $selected = 'AC_OTH'; - if ($selected == 'auto') $selected = 'AC_OTH_AUTO'; + if ($selected == 'manual') $selected = 'AC_OTH'; + if ($selected == 'auto') $selected = 'AC_OTH_AUTO'; - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); - $out = ''; + $out = ''; if (!empty($multiselect)) { - if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); + if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); } else { $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200'.($morecss ? ' '.$morecss : ''), 1); } - if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) - { - $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); - } + if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) + { + $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); + } - if ($nooutput) return $out; - else print $out; - return ''; - } + if ($nooutput) return $out; + else print $out; + return ''; + } } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 290bf30b0f7..4ee5c9f1f6a 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; class FormCompany extends Form { - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of labels (translated) of third parties type * @@ -50,7 +50,7 @@ class FormCompany extends Form */ public function typent_array($mode = 0, $filter = '') { - // phpcs:enable + // phpcs:enable global $langs, $mysoc; $effs = array(); @@ -83,7 +83,7 @@ class FormCompany extends Form return $effs; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre) * @@ -93,7 +93,7 @@ class FormCompany extends Form */ public function effectif_array($mode = 0, $filter = '') { - // phpcs:enable + // phpcs:enable $effs = array(); $sql = "SELECT id, code, libelle"; @@ -123,7 +123,7 @@ class FormCompany extends Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Affiche formulaire de selection des modes de reglement * @@ -135,7 +135,7 @@ class FormCompany extends Form */ public function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0) { - // phpcs:enable + // phpcs:enable global $user, $langs; print '
'; @@ -225,12 +225,12 @@ class FormCompany extends Form print '
'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. - * In the case of an all-country list, the display breaks on the country. - * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). - * Thus the links with the departments are done on a department independently of its name. + * In the case of an all-country list, the display breaks on the country. + * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). + * Thus the links with the departments are done on a department independently of its name. * * @param string $selected Code state preselected * @param int $country_codeid 0=list for all countries, otherwise country code or country rowid to show @@ -239,16 +239,16 @@ class FormCompany extends Form */ public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id') { - // phpcs:enable + // phpcs:enable print $this->select_state($selected, $country_codeid, $htmlname); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. - * In the case of an all-country list, the display breaks on the country. - * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). - * Thus the links with the departments are done on a department independently of its name. + * In the case of an all-country list, the display breaks on the country. + * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). + * Thus the links with the departments are done on a department independently of its name. * * @param int $selected Code state preselected (mus be state id) * @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show @@ -258,7 +258,7 @@ class FormCompany extends Form */ public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id') { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user; dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid, LOG_DEBUG); @@ -349,7 +349,7 @@ class FormCompany extends Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne la liste deroulante des regions actives dont le pays est actif * La cle de la liste est le code (il peut y avoir plusieurs entree pour @@ -362,7 +362,7 @@ class FormCompany extends Form */ public function select_region($selected = '', $htmlname = 'region_id') { - // phpcs:enable + // phpcs:enable global $conf, $langs; $langs->load("dict"); @@ -412,7 +412,7 @@ class FormCompany extends Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return combo list with people title * @@ -424,7 +424,7 @@ class FormCompany extends Form */ public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth150', $addjscombo = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user; $langs->load("dict"); @@ -473,7 +473,7 @@ class FormCompany extends Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne. * Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays. @@ -487,25 +487,25 @@ class FormCompany extends Form */ public function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '') { - // phpcs:enable + // phpcs:enable print $this->select_juridicalstatus($selected, $country_codeid, $filter); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne. * Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays * * @param string $selected Preselected code of juridical type * @param int $country_codeid 0=list for all countries, otherwise list only country requested - * @param string $filter Add a SQL filter on list - * @param string $htmlname HTML name of select - * @param string $morecss More CSS - * @return string String with HTML select + * @param string $filter Add a SQL filter on list + * @param string $htmlname HTML name of select + * @param string $morecss More CSS + * @return string String with HTML select */ public function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code', $morecss = '') { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user; $langs->load("dict"); @@ -578,9 +578,9 @@ class FormCompany extends Form $out .= ''; if ($user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - // Make select dynamic - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out .= ajax_combobox($htmlname); + // Make select dynamic + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $out .= ajax_combobox($htmlname); $out .= ''; } else { @@ -600,8 +600,8 @@ class FormCompany extends Form * @param string $htmlname Name of HTML form * @param array $limitto Disable answers that are not id in this array list * @param int $forceid This is to force another object id than object->id - * @param string $moreparam String with more param to add into url when noajax search is used. - * @param string $morecss More CSS on select component + * @param string $moreparam String with more param to add into url when noajax search is used. + * @param string $morecss More CSS on select component * @return int The selected third party ID */ public function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '') @@ -746,21 +746,21 @@ class FormCompany extends Form } } - /** - * Return a select list with types of contacts - * - * @param object $object Object to use to find type of contact - * @param string $selected Default selected value - * @param string $htmlname HTML select name - * @param string $source Source ('internal' or 'external') - * @param string $sortorder Sort criteria ('position', 'code', ...) - * @param int $showempty 1=Add en empty line - * @param string $morecss Add more css to select component - * @return void - */ - public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '') + /** + * Return a select list with types of contacts + * + * @param object $object Object to use to find type of contact + * @param string $selected Default selected value + * @param string $htmlname HTML select name + * @param string $source Source ('internal' or 'external') + * @param string $sortorder Sort criteria ('position', 'code', ...) + * @param int $showempty 1=Add en empty line + * @param string $morecss Add more css to select component + * @return void + */ + public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '') { - global $user, $langs; + global $user, $langs; if (is_object($object) && method_exists($object, 'liste_type_contact')) { @@ -822,7 +822,7 @@ class FormCompany extends Form return 'ErrorBadValueForParameterRenderMode'; // Should not happened } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a select list with zip codes and their town * @@ -837,7 +837,7 @@ class FormCompany extends Form */ public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = '', $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '') { - // phpcs:enable + // phpcs:enable global $conf; $out = ''; @@ -855,155 +855,155 @@ class FormCompany extends Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return HTML string to use as input of professional id into a HTML page (siren, siret, etc...) - * - * @param int $idprof 1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm) - * @param string $htmlname Name of HTML select - * @param string $preselected Default value to show - * @param string $country_code FR, IT, ... - * @param string $morecss More css - * @return string HTML string with prof id - */ - public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent') - { - // phpcs:enable - global $conf, $langs, $hookmanager; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return HTML string to use as input of professional id into a HTML page (siren, siret, etc...) + * + * @param int $idprof 1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm) + * @param string $htmlname Name of HTML select + * @param string $preselected Default value to show + * @param string $country_code FR, IT, ... + * @param string $morecss More css + * @return string HTML string with prof id + */ + public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent') + { + // phpcs:enable + global $conf, $langs, $hookmanager; - $formlength = 0; - if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) { - if ($country_code == 'FR') - { - if (isset($idprof)) { - if ($idprof == 1) $formlength = 9; - elseif ($idprof == 2) $formlength = 14; - elseif ($idprof == 3) $formlength = 5; // 4 chiffres et 1 lettre depuis janvier - elseif ($idprof == 4) $formlength = 32; // No maximum as we need to include a town name in this id - } - } elseif ($country_code == 'ES') - { - if ($idprof == 1) $formlength = 9; //CIF/NIF/NIE 9 digits - if ($idprof == 2) $formlength = 12; //NASS 12 digits without / - if ($idprof == 3) $formlength = 5; //CNAE 5 digits - if ($idprof == 4) $formlength = 32; //depend of college - } - } + $formlength = 0; + if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) { + if ($country_code == 'FR') + { + if (isset($idprof)) { + if ($idprof == 1) $formlength = 9; + elseif ($idprof == 2) $formlength = 14; + elseif ($idprof == 3) $formlength = 5; // 4 chiffres et 1 lettre depuis janvier + elseif ($idprof == 4) $formlength = 32; // No maximum as we need to include a town name in this id + } + } elseif ($country_code == 'ES') + { + if ($idprof == 1) $formlength = 9; //CIF/NIF/NIE 9 digits + if ($idprof == 2) $formlength = 12; //NASS 12 digits without / + if ($idprof == 3) $formlength = 5; //CNAE 5 digits + if ($idprof == 4) $formlength = 32; //depend of college + } + } - $selected = $preselected; - if (!$selected && isset($idprof)) { - if ($idprof == 1 && !empty($this->idprof1)) $selected = $this->idprof1; - elseif ($idprof == 2 && !empty($this->idprof2)) $selected = $this->idprof2; - elseif ($idprof == 3 && !empty($this->idprof3)) $selected = $this->idprof3; - elseif ($idprof == 4 && !empty($this->idprof4)) $selected = $this->idprof4; - } + $selected = $preselected; + if (!$selected && isset($idprof)) { + if ($idprof == 1 && !empty($this->idprof1)) $selected = $this->idprof1; + elseif ($idprof == 2 && !empty($this->idprof2)) $selected = $this->idprof2; + elseif ($idprof == 3 && !empty($this->idprof3)) $selected = $this->idprof3; + elseif ($idprof == 4 && !empty($this->idprof4)) $selected = $this->idprof4; + } - $maxlength = $formlength; - if (empty($formlength)) { $formlength = 24; $maxlength = 128; } + $maxlength = $formlength; + if (empty($formlength)) { $formlength = 24; $maxlength = 128; } - $out = ''; + $out = ''; - // Execute hook getInputIdProf to complete or replace $out - $parameters = array('formlength'=>$formlength, 'selected'=>$preselected, 'idprof'=>$idprof, 'htmlname'=>$htmlname, 'country_code'=>$country_code); - $reshook = $hookmanager->executeHooks('getInputIdProf', $parameters); - if (empty($reshook)) - { - $out .= ''; - } - $out .= $hookmanager->resPrint; + // Execute hook getInputIdProf to complete or replace $out + $parameters = array('formlength'=>$formlength, 'selected'=>$preselected, 'idprof'=>$idprof, 'htmlname'=>$htmlname, 'country_code'=>$country_code); + $reshook = $hookmanager->executeHooks('getInputIdProf', $parameters); + if (empty($reshook)) + { + $out .= ''; + } + $out .= $hookmanager->resPrint; - return $out; - } + return $out; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return a HTML select with localtax values for thirdparties - * - * @param int $local LocalTax - * @param int $selected Preselected value - * @param string $htmlname HTML select name - * @return void - */ - public function select_localtax($local, $selected, $htmlname) - { - // phpcs:enable - $tax = get_localtax_by_third($local); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return a HTML select with localtax values for thirdparties + * + * @param int $local LocalTax + * @param int $selected Preselected value + * @param string $htmlname HTML select name + * @return void + */ + public function select_localtax($local, $selected, $htmlname) + { + // phpcs:enable + $tax = get_localtax_by_third($local); - $num = $this->db->num_rows($tax); - $i = 0; - if ($num) - { - $valors = explode(":", $tax); + $num = $this->db->num_rows($tax); + $i = 0; + if ($num) + { + $valors = explode(":", $tax); - if (count($valors) > 1) - { - //montar select - print ''; - } - } - } + if (count($valors) > 1) + { + //montar select + print ''; + } + } + } - /** - * Return a HTML select for thirdparty type - * - * @param int $selected selected value - * @param string $htmlname HTML select name - * @param string $htmlidname HTML select id - * @param string $typeinput HTML output - * @param string $morecss More css - * @return string HTML string - */ - public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '') - { + /** + * Return a HTML select for thirdparty type + * + * @param int $selected selected value + * @param string $htmlname HTML select name + * @param string $htmlidname HTML select id + * @param string $typeinput HTML output + * @param string $morecss More css + * @return string HTML string + */ + public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '') + { - global $conf, $langs; + global $conf, $langs; - $out = ''; + $out = ''; - return $out; - } + return $out; + } } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 65e44b86efc..e4bab32a544 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -58,7 +58,7 @@ class FormFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form to upload a new file. * @@ -70,8 +70,8 @@ class FormFile * @param int $size Length of input file area. Deprecated. * @param Object $object Object to use (when attachment is done on an element) * @param string $options Add an option column - * @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). - * Deprecated 2 should never be used and if 1 is used, option should no be enabled. + * @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). + * Deprecated 2 should never be used and if 1 is used, option should no be enabled. * @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' * @param integer $linkfiles 1=Also add form to link files, 0=Do not show form to link files * @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM) @@ -83,14 +83,14 @@ class FormFile */ public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '', $usewithoutform = 0, $capture = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs, $hookmanager; $hookmanager->initHooks(array('formfile')); - // Deprecation warning - if ($useajax == 2) { - dol_syslog(__METHOD__.": using 2 for useajax is deprecated and should be not used", LOG_WARNING); - } + // Deprecation warning + if ($useajax == 2) { + dol_syslog(__METHOD__.": using 2 for useajax is deprecated and should be not used", LOG_WARNING); + } if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic') $useajax = 0; @@ -114,12 +114,12 @@ class FormFile if (empty($usewithoutform)) // Try to avoid this and set instead the form by the caller. { - $out .= '
'; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; } $out .= ''; @@ -201,24 +201,24 @@ class FormFile $out .= ""; if ($savingdocmask) - { - //add a global variable for disable the auto renaming on upload - $rename = (empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT) ? 'checked' : ''); + { + //add a global variable for disable the auto renaming on upload + $rename = (empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT) ? 'checked' : ''); - $out .= ''; - if (!empty($options)) $out .= ''; - $out .= ''; + if (!empty($options)) $out .= ''; + $out .= ''; - $out .= ''; - } + $out .= ''; + $out .= ''; + } $out .= "
'.$options.''; + $out .= '
'.$options.''; $out .= ' '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/', $langs->transnoentitiesnoconv("OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv("OriginFileName")); - $out .= '
"; if (empty($usewithoutform)) { - $out .= '
'; - if (empty($sectionid)) $out .= '
'; + $out .= ''; + if (empty($sectionid)) $out .= '
'; } $out .= "\n\n"; @@ -232,10 +232,10 @@ class FormFile if (empty($usewithoutform)) { - $out .= '
'; + $out .= '
'; + $out .= '
'; } $out .= "\n\n"; @@ -268,7 +268,7 @@ class FormFile $res = $hookmanager->executeHooks('formattachOptions', $parameters, $object); if (empty($res)) { - print '
'; + print '
'; print $out; print '
'; } @@ -278,7 +278,7 @@ class FormFile } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show the box with list of available documents for object * @@ -303,7 +303,7 @@ class FormFile */ public function show_documents($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '') { - // phpcs:enable + // phpcs:enable $this->numoffiles = 0; print $this->showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang); return $this->numoffiles; @@ -454,13 +454,13 @@ class FormFile $modellist = ModelePDFExpedition::liste_modeles($this->db); } } elseif ($modulepart == 'reception') - { - if (is_array($genallowed)) $modellist = $genallowed; - else { + { + if (is_array($genallowed)) $modellist = $genallowed; + else { include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php'; $modellist = ModelePdfReception::liste_modeles($this->db); } - } elseif ($modulepart == 'livraison') + } elseif ($modulepart == 'livraison') { if (is_array($genallowed)) $modellist = $genallowed; else { @@ -611,16 +611,16 @@ class FormFile $modellist = ModelePDFUserGroup::liste_modeles($this->db); } } else { - $submodulepart = $modulepart; + $submodulepart = $modulepart; - // modulepart = 'nameofmodule' or 'nameofmodule:NameOfObject' - $tmp = explode(':', $modulepart); - if (!empty($tmp[1])) { - $modulepart = $tmp[0]; - $submodulepart = $tmp[1]; - } + // modulepart = 'nameofmodule' or 'nameofmodule:NameOfObject' + $tmp = explode(':', $modulepart); + if (!empty($tmp[1])) { + $modulepart = $tmp[0]; + $submodulepart = $tmp[1]; + } - // For normalized standard modules + // For normalized standard modules $file = dol_buildpath('/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0); if (file_exists($file)) { @@ -628,7 +628,7 @@ class FormFile } // For normalized external modules. else { - $file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0); + $file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0); $res = include_once $file; } @@ -992,7 +992,7 @@ class FormFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show list of documents in $filearray (may be they are all in same directory but may not) * This also sync database if $upload_dir is defined. @@ -1027,7 +1027,7 @@ class FormFile */ public function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0, $disablecrop = -1) { - // phpcs:enable + // phpcs:enable global $user, $conf, $langs, $hookmanager; global $sortfield, $sortorder, $maxheightmini; global $dolibarr_main_url_root; @@ -1049,7 +1049,7 @@ class FormFile // For backward compatiblity, we detect file stored into an old path if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos') { - $relativepath = preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/'; + $relativepath = preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/'; } // Defined relative dir to DOL_DATA_ROOT $relativedir = ''; @@ -1233,13 +1233,13 @@ class FormFile print ''; if (image_format_supported($file['name']) >= 0) { - if ($useinecm == 5 || $useinecm == 6) - { - $smallfile = getImageFileNameForSize($file['name'], ''); // There is no thumb for ECM module and Media filemanager, so we use true image. TODO Change this it is slow on image dir. - } else { - $smallfile = getImageFileNameForSize($file['name'], '_small'); // For new thumbs using same ext (in lower case however) than original - } - if (!dol_is_file($file['path'].'/'.$smallfile)) $smallfile = getImageFileNameForSize($file['name'], '_small', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension + if ($useinecm == 5 || $useinecm == 6) + { + $smallfile = getImageFileNameForSize($file['name'], ''); // There is no thumb for ECM module and Media filemanager, so we use true image. TODO Change this it is slow on image dir. + } else { + $smallfile = getImageFileNameForSize($file['name'], '_small'); // For new thumbs using same ext (in lower case however) than original + } + if (!dol_is_file($file['path'].'/'.$smallfile)) $smallfile = getImageFileNameForSize($file['name'], '_small', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension //print $file['path'].'/'.$smallfile.'
'; $urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); @@ -1353,7 +1353,7 @@ class FormFile print 'browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>'; print ''; } - } + } } else { print ''; print ''; @@ -1398,7 +1398,7 @@ class FormFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show list of documents in a directory * @@ -1419,7 +1419,7 @@ class FormFile */ public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permissiontodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '', $addfilterfields = 0) { - // phpcs:enable + // phpcs:enable global $user, $conf, $langs, $form; global $sortfield, $sortorder; global $search_doc_ref; @@ -1532,8 +1532,8 @@ class FormFile $object_instance = new RecruitmentCandidature($this->db); } elseif ($modulepart == 'banque') { - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $object_instance = new Account($this->db); + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $object_instance = new Account($this->db); } elseif ($modulepart == 'mrp-mo') { include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; @@ -1574,7 +1574,7 @@ class FormFile 'banque'))) { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } else { - //print 'Error: Value for modulepart = '.$modulepart.' is not yet implemented in function list_of_autoecmfiles'."\n"; + //print 'Error: Value for modulepart = '.$modulepart.' is not yet implemented in function list_of_autoecmfiles'."\n"; } if (!$id && !$ref) continue; @@ -1733,7 +1733,7 @@ class FormFile print ''; print ''; - print_liste_field_titre( + print_liste_field_titre( $langs->trans("Links"), $_SERVER['PHP_SELF'], "name", @@ -1742,20 +1742,20 @@ class FormFile '', $sortfield, $sortorder, - '' + '' ); - print_liste_field_titre( + print_liste_field_titre( "", "", "", "", "", '', - '', - '', - 'right ' + '', + '', + 'right ' ); - print_liste_field_titre( + print_liste_field_titre( $langs->trans("Date"), $_SERVER['PHP_SELF'], "date", @@ -1764,18 +1764,18 @@ class FormFile '', $sortfield, $sortorder, - 'center ' + 'center ' ); - print_liste_field_titre( + print_liste_field_titre( '', $_SERVER['PHP_SELF'], "", "", $param, '', - '', - '', - 'center ' + '', + '', + 'center ' ); print_liste_field_titre('', '', ''); print ''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index bc427028385..e8f4d42148b 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -37,75 +37,75 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; class FormMail extends Form { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - /** - * @var int 1 = Include HTML form tag and show submit button - * 0 = Do not include form tag and submit button - * -1 = Do not include form tag but include submit button - */ + /** + * @var int 1 = Include HTML form tag and show submit button + * 0 = Do not include form tag and submit button + * -1 = Do not include form tag but include submit button + */ public $withform; - /** - * @var string name from - */ + /** + * @var string name from + */ public $fromname; - /** - * @var string email from - */ + /** + * @var string email from + */ public $frommail; - /** - * @var string user, company, robot - */ - public $fromtype; + /** + * @var string user, company, robot + */ + public $fromtype; - /** - * @var int from ID - */ - public $fromid; + /** + * @var int from ID + */ + public $fromid; - /** - * @var int also from robot - */ - public $fromalsorobot; + /** + * @var int also from robot + */ + public $fromalsorobot; - /** - * @var string thirdparty etc - */ - public $totype; + /** + * @var string thirdparty etc + */ + public $totype; - /** - * @var int ID - */ - public $toid; + /** + * @var int ID + */ + public $toid; - /** - * @var string replyto name - */ - public $replytoname; + /** + * @var string replyto name + */ + public $replytoname; - /** - * @var string replyto email - */ + /** + * @var string replyto email + */ public $replytomail; - /** - * @var string to name - */ + /** + * @var string to name + */ public $toname; - /** - * @var string to email - */ + /** + * @var string to email + */ public $tomail; - /** - * @var string trackid - */ + /** + * @var string trackid + */ public $trackid; public $withsubstit; // Show substitution array @@ -180,7 +180,7 @@ class FormMail extends Form $this->withfckeditor = -1; // -1 = Auto } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Clear list of attached files in send mail form (also stored in session) * @@ -188,7 +188,7 @@ class FormMail extends Form */ public function clear_attached_files() { - // phpcs:enable + // phpcs:enable global $conf, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -203,7 +203,7 @@ class FormMail extends Form unset($_SESSION["listofmimes".$keytoavoidconflict]); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a file into the list of attached files (stored in SECTION array) * @@ -214,7 +214,7 @@ class FormMail extends Form */ public function add_attached_files($path, $file = '', $type = '') { - // phpcs:enable + // phpcs:enable $listofpaths = array(); $listofnames = array(); $listofmimes = array(); @@ -237,7 +237,7 @@ class FormMail extends Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a file from the list of attached files (stored in SECTION array) * @@ -246,7 +246,7 @@ class FormMail extends Form */ public function remove_attached_files($keytodelete) { - // phpcs:enable + // phpcs:enable $listofpaths = array(); $listofnames = array(); $listofmimes = array(); @@ -267,7 +267,7 @@ class FormMail extends Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of attached files (stored in SECTION array) * @@ -275,7 +275,7 @@ class FormMail extends Form */ public function get_attached_files() { - // phpcs:enable + // phpcs:enable $listofpaths = array(); $listofnames = array(); $listofmimes = array(); @@ -287,7 +287,7 @@ class FormMail extends Form return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files @@ -299,11 +299,11 @@ class FormMail extends Form */ public function show_form($addfileaction = 'addfile', $removefileaction = 'removefile') { - // phpcs:enable + // phpcs:enable print $this->get_form($addfileaction, $removefileaction); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files @@ -316,17 +316,17 @@ class FormMail extends Form */ public function get_form($addfileaction = 'addfile', $removefileaction = 'removefile') { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user, $hookmanager, $form; - // Required to show preview of mail attachments - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - $formfile = new Formfile($this->db); + // Required to show preview of mail attachments + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new Formfile($this->db); if (!is_object($form)) $form = new Form($this->db); // Load translation files required by the page - $langs->loadLangs(array('other', 'mails')); + $langs->loadLangs(array('other', 'mails')); // Clear temp files. Must be done at beginning, before call of triggers if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) @@ -464,7 +464,7 @@ class FormMail extends Form 'propal_send', 'order_send', 'facture_send', 'shipping_send', 'fichinter_send', 'supplier_proposal_send', 'order_supplier_send', 'invoice_supplier_send', 'thirdparty', 'contract', 'user', 'recruitmentcandidature_send', 'all' - ))) + ))) { // If list of template is empty $out .= '
'."\n"; @@ -733,7 +733,7 @@ class FormMail extends Form { $out .= (!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : ""; } else { - $out .= 'withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />'; + $out .= 'withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />'; if (!empty($this->withtocc) && is_array($this->withtocc)) { $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; @@ -854,10 +854,10 @@ class FormMail extends Form foreach ($listofpaths as $key => $val) { $out .= '
'; - // Preview of attachment - preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT)-strlen($val))), $formfile_params); + // Preview of attachment + preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT)-strlen($val))), $formfile_params); $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; - $out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]); + $out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]); if (!$this->withfilereadonly) { $out .= ' '; @@ -1060,7 +1060,7 @@ class FormMail extends Form if (!empty($this->withtocccreadonly)) { $out .= (!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : ""; } else { - $out .= 'withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />'; + $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 @@ -1185,7 +1185,7 @@ class FormMail extends Form */ public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '') { - $ret = new ModelMail(); + $ret = new ModelMail(); if ($id == -2 && empty($label)) { $this->error = 'LabelIsMandatoryWhenIdIs-2'; @@ -1513,9 +1513,9 @@ class ModelMail public $id; /** - * @var string Model mail label - */ - public $label; + * @var string Model mail label + */ + public $label; public $topic; public $content; diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index f146de256da..6f730c03976 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -46,16 +46,16 @@ */ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLength = 2, $autoselect = 0, $ajaxoptions = array(), $moreparams = '') { - if (empty($minLength)) $minLength = 1; + if (empty($minLength)) $minLength = 1; - $dataforrenderITem = 'ui-autocomplete'; - $dataforitem = 'ui-autocomplete-item'; - // Allow two constant to use other values for backward compatibility - if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem = constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM'); - if (defined('JS_QUERY_AUTOCOMPLETE_ITEM')) $dataforitem = constant('JS_QUERY_AUTOCOMPLETE_ITEM'); + $dataforrenderITem = 'ui-autocomplete'; + $dataforitem = 'ui-autocomplete-item'; + // Allow two constant to use other values for backward compatibility + if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem = constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM'); + if (defined('JS_QUERY_AUTOCOMPLETE_ITEM')) $dataforitem = constant('JS_QUERY_AUTOCOMPLETE_ITEM'); - // Input search_htmlname is original field - // Input htmlname is a second input field used when using ajax autocomplete. + // Input search_htmlname is original field + // Input htmlname is a second input field used when using ajax autocomplete. $script = ''; $script .= ''."\n"; @@ -348,7 +348,7 @@ function ajax_dialog($title, $message, $w = 350, $h = 150) $msg = '
'; $msg .= $message; $msg .= '
'."\n"; - $msg .= ''; - $msg .= "\n"; + $msg .= "\n"; - return $msg; + return $msg; } @@ -397,8 +397,8 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete = 0; - $tmpplugin = 'select2'; - $msg = "\n".' + $tmpplugin = 'select2'; + $msg = "\n".' \n"; + $msg .= "\n"; - return $msg; + return $msg; } /** @@ -500,7 +500,7 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof global $conf, $langs, $user; $entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity); - if (! isset($input)) $input = array(); + if (!isset($input)) $input = array(); if (empty($conf->use_javascript_ajax) || $forcenoajax) { @@ -566,9 +566,9 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof */ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = array()) { - global $langs; + global $langs; - $out = ''; - $out .= ''.img_picto($langs->trans($text_off), 'switch_off').''; - $out .= ''.img_picto($langs->trans($text_on), 'switch_on').''; + $out .= ''.img_picto($langs->trans($text_off), 'switch_off').''; + $out .= ''.img_picto($langs->trans($text_on), 'switch_on').''; - return $out; + return $out; } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 688658a1f38..3dc09eb42ae 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -41,20 +41,20 @@ */ function societe_prepare_head(Societe $object) { - global $db, $langs, $conf, $user; - $h = 0; - $head = array(); + global $db, $langs, $conf, $user; + $h = 0; + $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/societe/card.php?socid='.$object->id; - $head[$h][1] = $langs->trans("ThirdParty"); - $head[$h][2] = 'card'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/societe/card.php?socid='.$object->id; + $head[$h][1] = $langs->trans("ThirdParty"); + $head[$h][2] = 'card'; + $h++; - if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) - { - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->societe->contact->lire) + if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) + { + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->societe->contact->lire) { - //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); $nbContact = 0; // TODO $sql = "SELECT COUNT(p.rowid) as nb"; @@ -67,13 +67,13 @@ function societe_prepare_head(Societe $object) if ($obj) $nbContact = $obj->nb; } - $head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id; - $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; - $head[$h][2] = 'contact'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; + $head[$h][2] = 'contact'; + $h++; } - } else { + } else { $head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id; $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][1] = $langs->trans("ContactsAddresses"); @@ -82,65 +82,65 @@ function societe_prepare_head(Societe $object) $h++; } - if ($object->client == 1 || $object->client == 2 || $object->client == 3) - { - $head[$h][0] = DOL_URL_ROOT.'/comm/card.php?socid='.$object->id; - $head[$h][1] = ''; - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client == 2 || $object->client == 3)) $head[$h][1] .= $langs->trans("Prospect"); - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && $object->client == 3) $head[$h][1] .= ' | '; - if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client == 1 || $object->client == 3)) $head[$h][1] .= $langs->trans("Customer"); - $head[$h][2] = 'customer'; - $h++; + if ($object->client == 1 || $object->client == 2 || $object->client == 3) + { + $head[$h][0] = DOL_URL_ROOT.'/comm/card.php?socid='.$object->id; + $head[$h][1] = ''; + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client == 2 || $object->client == 3)) $head[$h][1] .= $langs->trans("Prospect"); + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && $object->client == 3) $head[$h][1] .= ' | '; + if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client == 1 || $object->client == 3)) $head[$h][1] .= $langs->trans("Customer"); + $head[$h][2] = 'customer'; + $h++; - if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - $langs->load("products"); - // price - $head[$h][0] = DOL_URL_ROOT.'/societe/price.php?socid='.$object->id; - $head[$h][1] = $langs->trans("CustomerPrices"); - $head[$h][2] = 'price'; - $h++; - } - } - $supplier_module_enabled = 0; - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) $supplier_module_enabled = 1; - if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) - { - $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id; - $head[$h][1] = $langs->trans("Supplier"); - $head[$h][2] = 'supplier'; - $h++; - } + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + $langs->load("products"); + // price + $head[$h][0] = DOL_URL_ROOT.'/societe/price.php?socid='.$object->id; + $head[$h][1] = $langs->trans("CustomerPrices"); + $head[$h][2] = 'price'; + $h++; + } + } + $supplier_module_enabled = 0; + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) $supplier_module_enabled = 1; + if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) + { + $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id; + $head[$h][1] = $langs->trans("Supplier"); + $head[$h][2] = 'supplier'; + $h++; + } - if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) - { - $head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id; - $head[$h][1] = $langs->trans("Projects"); - $nbNote = 0; - $sql = "SELECT COUNT(n.rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as n"; - $sql .= " WHERE fk_soc = ".$object->id; - $sql .= " AND entity IN (".getEntity('project').")"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $nbNote = $obj->nb; - $i++; - } - } else { - dol_print_error($db); - } + if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) + { + $head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id; + $head[$h][1] = $langs->trans("Projects"); + $nbNote = 0; + $sql = "SELECT COUNT(n.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as n"; + $sql .= " WHERE fk_soc = ".$object->id; + $sql .= " AND entity IN (".getEntity('project').")"; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $nbNote = $obj->nb; + $i++; + } + } else { + dol_print_error($db); + } if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; - $head[$h][2] = 'project'; - $h++; - } + $head[$h][2] = 'project'; + $h++; + } - // Tab to link resources + // Tab to link resources if (!empty($conf->resource->enabled) && !empty($conf->global->RESOURCE_ON_THIRDPARTIES)) { $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=societe&element_id='.$object->id; @@ -171,24 +171,24 @@ function societe_prepare_head(Societe $object) } // Related items - if ((!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) - && empty($conf->global->THIRPARTIES_DISABLE_RELATED_OBJECT_TAB)) - { - $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; - $head[$h][1] = $langs->trans("Referers"); - $head[$h][2] = 'consumption'; - $h++; - } + if ((!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) + && empty($conf->global->THIRPARTIES_DISABLE_RELATED_OBJECT_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; + $head[$h][1] = $langs->trans("Referers"); + $head[$h][2] = 'consumption'; + $h++; + } - // Bank accounts - if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) - { - $nbBankAccount = 0; + // Bank accounts + if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) + { + $nbBankAccount = 0; $foundonexternalonlinesystem = 0; - $langs->load("banks"); + $langs->load("banks"); - //$title = $langs->trans("BankAccounts"); - $title = $langs->trans("PaymentInformation"); + //$title = $langs->trans("BankAccounts"); + $title = $langs->trans("PaymentInformation"); if (!empty($conf->stripe->enabled)) { @@ -204,147 +204,147 @@ function societe_prepare_head(Societe $object) if ($stripecu) $foundonexternalonlinesystem++; } - $sql = "SELECT COUNT(n.rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib as n"; - $sql .= " WHERE n.fk_soc = ".$object->id; - if (empty($conf->stripe->enabled)) { + $sql = "SELECT COUNT(n.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib as n"; + $sql .= " WHERE n.fk_soc = ".$object->id; + if (empty($conf->stripe->enabled)) { $sql .= " AND n.stripe_card_ref IS NULL"; } else { $sql .= " AND (n.stripe_card_ref IS NULL OR (n.stripe_card_ref IS NOT NULL AND n.status = ".$servicestatus."))"; } - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $nbBankAccount = $obj->nb; - $i++; - } - } else { - dol_print_error($db); - } + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $nbBankAccount = $obj->nb; + $i++; + } + } else { + dol_print_error($db); + } - //if (! empty($conf->stripe->enabled) && $nbBankAccount > 0) $nbBankAccount = '...'; // No way to know exact number + //if (! empty($conf->stripe->enabled) && $nbBankAccount > 0) $nbBankAccount = '...'; // No way to know exact number - $head[$h][0] = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; - $head[$h][1] = $title; - if ($foundonexternalonlinesystem) $head[$h][1] .= '...'; - elseif ($nbBankAccount > 0) $head[$h][1] .= ''.$nbBankAccount.''; - $head[$h][2] = 'rib'; - $h++; - } + $head[$h][0] = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; + $head[$h][1] = $title; + if ($foundonexternalonlinesystem) $head[$h][1] .= '...'; + elseif ($nbBankAccount > 0) $head[$h][1] .= ''.$nbBankAccount.''; + $head[$h][2] = 'rib'; + $h++; + } - if (!empty($conf->website->enabled) && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && (!empty($user->rights->societe->lire))) - { - $head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.$object->id; - $head[$h][1] = $langs->trans("WebSiteAccounts"); - $nbNote = 0; - $sql = "SELECT COUNT(n.rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as n"; - $sql .= " WHERE fk_soc = ".$object->id.' AND fk_website > 0'; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $nbNote = $obj->nb; - $i++; - } - } else { - dol_print_error($db); - } - if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; - $head[$h][2] = 'website'; - $h++; - } + if (!empty($conf->website->enabled) && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && (!empty($user->rights->societe->lire))) + { + $head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.$object->id; + $head[$h][1] = $langs->trans("WebSiteAccounts"); + $nbNote = 0; + $sql = "SELECT COUNT(n.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as n"; + $sql .= " WHERE fk_soc = ".$object->id.' AND fk_website > 0'; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $nbNote = $obj->nb; + $i++; + } + } else { + dol_print_error($db); + } + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; + $head[$h][2] = 'website'; + $h++; + } // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty'); + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty'); - if ($user->socid == 0) - { - // Notifications - if (!empty($conf->notification->enabled)) - { - $nbNote = 0; - $sql = "SELECT COUNT(n.rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n"; - $sql .= " WHERE fk_soc = ".$object->id; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $nbNote = $obj->nb; - $i++; - } - } else { - dol_print_error($db); - } + if ($user->socid == 0) + { + // Notifications + if (!empty($conf->notification->enabled)) + { + $nbNote = 0; + $sql = "SELECT COUNT(n.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n"; + $sql .= " WHERE fk_soc = ".$object->id; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $nbNote = $obj->nb; + $i++; + } + } else { + dol_print_error($db); + } - $head[$h][0] = DOL_URL_ROOT.'/societe/notify/card.php?socid='.$object->id; - $head[$h][1] = $langs->trans("Notifications"); + $head[$h][0] = DOL_URL_ROOT.'/societe/notify/card.php?socid='.$object->id; + $head[$h][1] = $langs->trans("Notifications"); if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; - $head[$h][2] = 'notify'; - $h++; - } + $head[$h][2] = 'notify'; + $h++; + } // Notes - $nbNote = 0; - if (!empty($object->note_private)) $nbNote++; + $nbNote = 0; + if (!empty($object->note_private)) $nbNote++; if (!empty($object->note_public)) $nbNote++; - $head[$h][0] = DOL_URL_ROOT.'/societe/note.php?id='.$object->id; - $head[$h][1] = $langs->trans("Notes"); + $head[$h][0] = DOL_URL_ROOT.'/societe/note.php?id='.$object->id; + $head[$h][1] = $langs->trans("Notes"); if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; - $head[$h][2] = 'note'; - $h++; + $head[$h][2] = 'note'; + $h++; - // Attached files - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id; - $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks = Link::count($db, $object->element, $object->id); + // Attached files + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id; + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); + $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$object->id; - $head[$h][1] = $langs->trans("Documents"); + $head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$object->id; + $head[$h][1] = $langs->trans("Documents"); if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; - $head[$h][2] = 'document'; - $h++; - } + $head[$h][2] = 'document'; + $h++; + } - $head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; - $head[$h][1] .= $langs->trans("Events"); - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) - { - $head[$h][1] .= '/'; - $head[$h][1] .= $langs->trans("Agenda"); - } - $head[$h][2] = 'agenda'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; + $head[$h][1] .= $langs->trans("Events"); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) + { + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); + } + $head[$h][2] = 'agenda'; + $h++; - // Log - /*$head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$object->id; + // Log + /*$head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++;*/ - complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty', 'remove'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'thirdparty', 'remove'); - return $head; + return $head; } @@ -356,21 +356,21 @@ function societe_prepare_head(Societe $object) */ function societe_prepare_head2($object) { - global $langs, $conf, $user; - $h = 0; - $head = array(); + global $langs, $conf, $user; + $h = 0; + $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/societe/card.php?socid='.$object->id; - $head[$h][1] = $langs->trans("ThirdParty"); - $head[$h][2] = 'company'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/societe/card.php?socid='.$object->id; + $head[$h][1] = $langs->trans("ThirdParty"); + $head[$h][2] = 'company'; + $h++; - $head[$h][0] = 'commerciaux.php?socid='.$object->id; - $head[$h][1] = $langs->trans("SalesRepresentative"); - $head[$h][2] = 'salesrepresentative'; - $h++; + $head[$h][0] = 'commerciaux.php?socid='.$object->id; + $head[$h][1] = $langs->trans("SalesRepresentative"); + $head[$h][2] = 'salesrepresentative'; + $h++; - return $head; + return $head; } @@ -382,35 +382,35 @@ function societe_prepare_head2($object) */ function societe_admin_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf, $user; - $h = 0; - $head = array(); + $h = 0; + $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/societe/admin/societe.php'; - $head[$h][1] = $langs->trans("Miscellaneous"); - $head[$h][2] = 'general'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/societe/admin/societe.php'; + $head[$h][1] = $langs->trans("Miscellaneous"); + $head[$h][2] = 'general'; + $h++; - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab - complete_head_from_modules($conf, $langs, null, $head, $h, 'company_admin'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf, $langs, null, $head, $h, 'company_admin'); - $head[$h][0] = DOL_URL_ROOT.'/societe/admin/societe_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFieldsThirdParties"); - $head[$h][2] = 'attributes'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/societe/admin/societe_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsThirdParties"); + $head[$h][2] = 'attributes'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/societe/admin/contact_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFieldsContacts"); - $head[$h][2] = 'attributes_contacts'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/societe/admin/contact_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsContacts"); + $head[$h][2] = 'attributes_contacts'; + $h++; - complete_head_from_modules($conf, $langs, null, $head, $h, 'company_admin', 'remove'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'company_admin', 'remove'); - return $head; + return $head; } @@ -432,49 +432,49 @@ function societe_admin_prepare_head() */ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', $entconv = 1, $searchlabel = '') { - global $db, $langs; + global $db, $langs; - $result = ''; + $result = ''; - // Check parameters - if (empty($searchkey) && empty($searchlabel)) - { - if ($withcode === 'all') return array('id'=>'', 'code'=>'', 'label'=>''); - else return ''; - } - if (!is_object($dbtouse)) $dbtouse = $db; - if (!is_object($outputlangs)) $outputlangs = $langs; + // Check parameters + if (empty($searchkey) && empty($searchlabel)) + { + if ($withcode === 'all') return array('id'=>'', 'code'=>'', 'label'=>''); + else return ''; + } + if (!is_object($dbtouse)) $dbtouse = $db; + if (!is_object($outputlangs)) $outputlangs = $langs; - $sql = "SELECT rowid, code, label FROM ".MAIN_DB_PREFIX."c_country"; - if (is_numeric($searchkey)) $sql .= " WHERE rowid=".$searchkey; - elseif (!empty($searchkey)) $sql .= " WHERE code='".$db->escape($searchkey)."'"; - else $sql .= " WHERE label='".$db->escape($searchlabel)."'"; + $sql = "SELECT rowid, code, label FROM ".MAIN_DB_PREFIX."c_country"; + if (is_numeric($searchkey)) $sql .= " WHERE rowid=".$searchkey; + elseif (!empty($searchkey)) $sql .= " WHERE code='".$db->escape($searchkey)."'"; + else $sql .= " WHERE label='".$db->escape($searchlabel)."'"; - $resql = $dbtouse->query($sql); - if ($resql) - { - $obj = $dbtouse->fetch_object($resql); - if ($obj) - { - $label = ((!empty($obj->label) && $obj->label != '-') ? $obj->label : ''); - if (is_object($outputlangs)) - { - $outputlangs->load("dict"); - if ($entconv) $label = ($obj->code && ($outputlangs->trans("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->trans("Country".$obj->code) : $label; - else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->transnoentitiesnoconv("Country".$obj->code) : $label; - } - if ($withcode == 1) $result = $label ? "$obj->code - $label" : "$obj->code"; - elseif ($withcode == 2) $result = $obj->code; - elseif ($withcode == 3) $result = $obj->rowid; - elseif ($withcode === 'all') $result = array('id'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$label); - else $result = $label; - } else { - $result = 'NotDefined'; - } - $dbtouse->free($resql); - return $result; - } else dol_print_error($dbtouse, ''); - return 'Error'; + $resql = $dbtouse->query($sql); + if ($resql) + { + $obj = $dbtouse->fetch_object($resql); + if ($obj) + { + $label = ((!empty($obj->label) && $obj->label != '-') ? $obj->label : ''); + if (is_object($outputlangs)) + { + $outputlangs->load("dict"); + if ($entconv) $label = ($obj->code && ($outputlangs->trans("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->trans("Country".$obj->code) : $label; + else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->transnoentitiesnoconv("Country".$obj->code) : $label; + } + if ($withcode == 1) $result = $label ? "$obj->code - $label" : "$obj->code"; + elseif ($withcode == 2) $result = $obj->code; + elseif ($withcode == 3) $result = $obj->rowid; + elseif ($withcode === 'all') $result = array('id'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$label); + else $result = $label; + } else { + $result = 'NotDefined'; + } + $dbtouse->free($resql); + return $result; + } else dol_print_error($dbtouse, ''); + return 'Error'; } /** @@ -494,60 +494,60 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', */ function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlangs = '', $entconv = 1) { - global $db, $langs; + global $db, $langs; - if (!is_object($dbtouse)) $dbtouse = $db; + if (!is_object($dbtouse)) $dbtouse = $db; - $sql = "SELECT d.rowid as id, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.code_region as region_code, r.nom as region_name FROM"; - $sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; - $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and d.rowid=".$id; - $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; - $sql .= " ORDER BY c.code, d.code_departement"; + $sql = "SELECT d.rowid as id, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.code_region as region_code, r.nom as region_name FROM"; + $sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; + $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and d.rowid=".$id; + $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; + $sql .= " ORDER BY c.code, d.code_departement"; - dol_syslog("Company.lib::getState", LOG_DEBUG); - $resql = $dbtouse->query($sql); - if ($resql) - { - $obj = $dbtouse->fetch_object($resql); - if ($obj) - { - $label = ((!empty($obj->name) && $obj->name != '-') ? $obj->name : ''); - if (is_object($outputlangs)) - { - $outputlangs->load("dict"); - if ($entconv) $label = ($obj->code && ($outputlangs->trans("State".$obj->code) != "State".$obj->code)) ? $outputlangs->trans("State".$obj->code) : $label; - else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code) != "State".$obj->code)) ? $outputlangs->transnoentitiesnoconv("State".$obj->code) : $label; - } + dol_syslog("Company.lib::getState", LOG_DEBUG); + $resql = $dbtouse->query($sql); + if ($resql) + { + $obj = $dbtouse->fetch_object($resql); + if ($obj) + { + $label = ((!empty($obj->name) && $obj->name != '-') ? $obj->name : ''); + if (is_object($outputlangs)) + { + $outputlangs->load("dict"); + if ($entconv) $label = ($obj->code && ($outputlangs->trans("State".$obj->code) != "State".$obj->code)) ? $outputlangs->trans("State".$obj->code) : $label; + else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code) != "State".$obj->code)) ? $outputlangs->transnoentitiesnoconv("State".$obj->code) : $label; + } - if ($withcode == 1) { - if ($withregion == 1) { - return $label = $obj->region_name.' - '.$obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); - } else { - return $label = $obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); - } - } elseif ($withcode == 2) { - if ($withregion == 1) { - return $label = $obj->region_name.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); - } else { - return $label = ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); - } - } elseif ($withcode === 'all') { - if ($withregion == 1) { - return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label, 'region_code'=>$obj->region_code, 'region'=>$obj->region_name); - } else { - return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label); - } - } else { - if ($withregion == 1) { - return $label = $obj->region_name.' - '.$label; - } else { - return $label; - } - } - } else { - return $langs->transnoentitiesnoconv("NotDefined"); - } - } else dol_print_error($dbtouse, ''); + if ($withcode == 1) { + if ($withregion == 1) { + return $label = $obj->region_name.' - '.$obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); + } else { + return $label = $obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); + } + } elseif ($withcode == 2) { + if ($withregion == 1) { + return $label = $obj->region_name.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); + } else { + return $label = ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); + } + } elseif ($withcode === 'all') { + if ($withregion == 1) { + return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label, 'region_code'=>$obj->region_code, 'region'=>$obj->region_name); + } else { + return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label); + } + } else { + if ($withregion == 1) { + return $label = $obj->region_name.' - '.$label; + } else { + return $label; + } + } + } else { + return $langs->transnoentitiesnoconv("NotDefined"); + } + } else dol_print_error($dbtouse, ''); } /** @@ -560,38 +560,38 @@ function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlan */ function currency_name($code_iso, $withcode = '', $outputlangs = null) { - global $langs, $db; + global $langs, $db; - if (empty($outputlangs)) $outputlangs = $langs; + if (empty($outputlangs)) $outputlangs = $langs; - $outputlangs->load("dict"); + $outputlangs->load("dict"); - // If there is a translation, we can send immediatly the label - if ($outputlangs->trans("Currency".$code_iso) != "Currency".$code_iso) - { - return ($withcode ? $code_iso.' - ' : '').$outputlangs->trans("Currency".$code_iso); - } + // If there is a translation, we can send immediatly the label + if ($outputlangs->trans("Currency".$code_iso) != "Currency".$code_iso) + { + return ($withcode ? $code_iso.' - ' : '').$outputlangs->trans("Currency".$code_iso); + } - // If no translation, we read table to get label by default - $sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies"; - $sql .= " WHERE code_iso='".$code_iso."'"; + // If no translation, we read table to get label by default + $sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies"; + $sql .= " WHERE code_iso='".$code_iso."'"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); - if ($num) - { - $obj = $db->fetch_object($resql); - $label = ($obj->label != '-' ? $obj->label : ''); - if ($withcode) return ($label == $code_iso) ? "$code_iso" : "$code_iso - $label"; - else return $label; - } else { - return $code_iso; - } - } - return 'ErrorWhenReadingCurrencyLabel'; + if ($num) + { + $obj = $db->fetch_object($resql); + $label = ($obj->label != '-' ? $obj->label : ''); + if ($withcode) return ($label == $code_iso) ? "$code_iso" : "$code_iso - $label"; + else return $label; + } else { + return $code_iso; + } + } + return 'ErrorWhenReadingCurrencyLabel'; } /** @@ -602,28 +602,28 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null) */ function getFormeJuridiqueLabel($code) { - global $db, $langs; + global $db, $langs; - if (!$code) return ''; + if (!$code) return ''; - $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."c_forme_juridique"; - $sql .= " WHERE code='$code'"; + $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."c_forme_juridique"; + $sql .= " WHERE code='$code'"; - dol_syslog("Company.lib::getFormeJuridiqueLabel", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); + dol_syslog("Company.lib::getFormeJuridiqueLabel", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); - if ($num) - { - $obj = $db->fetch_object($resql); - $label = ($obj->libelle != '-' ? $obj->libelle : ''); - return $label; - } else { - return $langs->trans("NotDefined"); - } - } + if ($num) + { + $obj = $db->fetch_object($resql); + $label = ($obj->libelle != '-' ? $obj->libelle : ''); + return $label; + } else { + return $langs->trans("NotDefined"); + } + } } @@ -696,8 +696,8 @@ function isInEEC($object) $country_code_in_EEC = getCountriesInEEC(); - //print "dd".$this->country_code; - return in_array($object->country_code, $country_code_in_EEC); + //print "dd".$this->country_code; + return in_array($object->country_code, $country_code_in_EEC); } @@ -715,116 +715,116 @@ function isInEEC($object) */ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatelink = 0, $morehtmlright = '') { - global $user; + global $user; - $i = -1; + $i = -1; - if (!empty($conf->projet->enabled) && $user->rights->projet->lire) - { - $langs->load("projects"); + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) + { + $langs->load("projects"); - $newcardbutton = ''; - if (!empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) - { - $newcardbutton .= dolGetButtonTitle($langs->trans('AddProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); - } + $newcardbutton = ''; + if (!empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) + { + $newcardbutton .= dolGetButtonTitle($langs->trans('AddProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); + } - print "\n"; - print load_fiche_titre($langs->trans("ProjectsDedicatedToThisThirdParty"), $newcardbutton.$morehtmlright, ''); - print '
'; - print "\n".'
'; + print "\n"; + print load_fiche_titre($langs->trans("ProjectsDedicatedToThisThirdParty"), $newcardbutton.$morehtmlright, ''); + print '
'; + print "\n".'
'; - $sql = "SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount"; - $sql .= ", cls.code as opp_status_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; - $sql .= " WHERE p.fk_soc = ".$object->id; - $sql .= " AND p.entity IN (".getEntity('project').")"; - $sql .= " ORDER BY p.dateo DESC"; + $sql = "SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount"; + $sql .= ", cls.code as opp_status_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; + $sql .= " WHERE p.fk_soc = ".$object->id; + $sql .= " AND p.entity IN (".getEntity('project').")"; + $sql .= " ORDER BY p.dateo DESC"; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - if ($num > 0) - { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + if ($num > 0) + { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projecttmp = new Project($db); + $projecttmp = new Project($db); - $i = 0; + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $projecttmp->fetch($obj->id); + while ($i < $num) + { + $obj = $db->fetch_object($result); + $projecttmp->fetch($obj->id); - // To verify role of users - $userAccess = $projecttmp->restrictedProjectArea($user); + // To verify role of users + $userAccess = $projecttmp->restrictedProjectArea($user); - if ($user->rights->projet->lire && $userAccess > 0) - { - print ''; + if ($user->rights->projet->lire && $userAccess > 0) + { + print ''; - // Ref - print ''; + // Ref + print ''; - // Label - print ''; - // Date start - print ''; - // Date end - print ''; - // Opp amount - print ''; - // Opp status - print ''; - // Opp percent - print ''; - // Status - print ''; + // Label + print ''; + // Date start + print ''; + // Date end + print ''; + // Opp amount + print ''; + // Opp status + print ''; + // Opp percent + print ''; + // Status + print ''; - print ''; - } - $i++; - } - } else { - print ''; - } - $db->free($result); - } else { - dol_print_error($db); - } - print "
'.$langs->trans("Ref").''.$langs->trans("Name").''.$langs->trans("DateStart").''.$langs->trans("DateEnd").''.$langs->trans("OpportunityAmountShort").''.$langs->trans("OpportunityStatusShort").''.$langs->trans("OpportunityProbabilityShort").''.$langs->trans("Status").'
'.$langs->trans("Ref").''.$langs->trans("Name").''.$langs->trans("DateStart").''.$langs->trans("DateEnd").''.$langs->trans("OpportunityAmountShort").''.$langs->trans("OpportunityStatusShort").''.$langs->trans("OpportunityProbabilityShort").''.$langs->trans("Status").'
'; - print $projecttmp->getNomUrl(1); - print ''; + print $projecttmp->getNomUrl(1); + print ''.$obj->title.''.dol_print_date($db->jdate($obj->do), "day").''.dol_print_date($db->jdate($obj->de), "day").''; - if ($obj->opp_status_code) - { - print price($obj->opp_amount, 1, '', 1, -1, -1, ''); - } - print ''; - if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code); - print ''; - if ($obj->opp_percent) print price($obj->opp_percent, 1, '', 1, 0).'%'; - print ''.$projecttmp->getLibStatut(5).''.$obj->title.''.dol_print_date($db->jdate($obj->do), "day").''.dol_print_date($db->jdate($obj->de), "day").''; + if ($obj->opp_status_code) + { + print price($obj->opp_amount, 1, '', 1, -1, -1, ''); + } + print ''; + if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code); + print ''; + if ($obj->opp_percent) print price($obj->opp_percent, 1, '', 1, 0).'%'; + print ''.$projecttmp->getLibStatut(5).'
'.$langs->trans("None").'
"; - print '
'; + print ''; + } + $i++; + } + } else { + print ''.$langs->trans("None").''; + } + $db->free($result); + } else { + dol_print_error($db); + } + print ""; + print ''; - print "
\n"; - } + print "
\n"; + } - return $i; + return $i; } @@ -845,386 +845,386 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $formcompany = new FormCompany($db); - $form = new Form($db); + $form = new Form($db); - $optioncss = GETPOST('optioncss', 'alpha'); - $sortfield = GETPOST("sortfield", 'alpha'); - $sortorder = GETPOST("sortorder", 'alpha'); - $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); + $optioncss = GETPOST('optioncss', 'alpha'); + $sortfield = GETPOST("sortfield", 'alpha'); + $sortorder = GETPOST("sortorder", 'alpha'); + $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); - $search_status = GETPOST("search_status", 'int'); - if ($search_status == '') $search_status = 1; // always display active customer first + $search_status = GETPOST("search_status", 'int'); + if ($search_status == '') $search_status = 1; // always display active customer first - $search_name = GETPOST("search_name", 'alpha'); - $search_address = GETPOST("search_address", 'alpha'); - $search_poste = GETPOST("search_poste", 'alpha'); + $search_name = GETPOST("search_name", 'alpha'); + $search_address = GETPOST("search_address", 'alpha'); + $search_poste = GETPOST("search_poste", 'alpha'); $search_roles = GETPOST("search_roles", 'array'); - $socialnetworks = getArrayOfSocialNetworks(); + $socialnetworks = getArrayOfSocialNetworks(); - $searchAddressPhoneDBFields = array( - //Address - 't.address', - 't.zip', - 't.town', + $searchAddressPhoneDBFields = array( + //Address + 't.address', + 't.zip', + 't.town', - //Phone - 't.phone', - 't.phone_perso', - 't.phone_mobile', + //Phone + 't.phone', + 't.phone_perso', + 't.phone_mobile', - //Fax - 't.fax', + //Fax + 't.fax', - //E-mail - 't.email', - ); - //Social media - foreach ($socialnetworks as $key => $value) { - if ($value['active']) { - $searchAddressPhoneDBFields['t.'.$key] = "t.socialnetworks->'$.".$key."'"; - } - } + //E-mail + 't.email', + ); + //Social media + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + $searchAddressPhoneDBFields['t.'.$key] = "t.socialnetworks->'$.".$key."'"; + } + } - if (!$sortorder) $sortorder = "ASC"; - if (!$sortfield) $sortfield = "t.lastname"; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "t.lastname"; - if (!empty($conf->clicktodial->enabled)) - { - $user->fetch_clicktodial(); // lecture des infos de clicktodial du user - } + if (!empty($conf->clicktodial->enabled)) + { + $user->fetch_clicktodial(); // lecture des infos de clicktodial du user + } - $contactstatic = new Contact($db); + $contactstatic = new Contact($db); - $extrafields->fetch_name_optionals_label($contactstatic->table_element); + $extrafields->fetch_name_optionals_label($contactstatic->table_element); - $contactstatic->fields = array( - 'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), - 'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20), - 'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30), - 'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40), - 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), - ); + $contactstatic->fields = array( + 'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), + 'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20), + 'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30), + 'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40), + 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), + ); - // Definition of fields for list - $arrayfields = array( - 't.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'position'=>1), - 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), - 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), - 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), - 'sc.role'=>array('label'=>"ContactByDefaultFor", 'checked'=>1, 'position'=>40), - 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'), - ); - // Extra fields - if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) - { - foreach ($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) - { - if (!empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) { + // Definition of fields for list + $arrayfields = array( + 't.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'position'=>1), + 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), + 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), + 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), + 'sc.role'=>array('label'=>"ContactByDefaultFor", 'checked'=>1, 'position'=>40), + 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'), + ); + // Extra fields + if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) + { + foreach ($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>1000 + $extrafields->attributes[$contactstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key])); } - } - } + } + } - // Initialize array of search criterias - $search = array(); - foreach ($arrayfields as $key => $val) - { - $queryName = 'search_'.substr($key, 2); - if (GETPOST($queryName, 'alpha')) { - $search[substr($key, 2)] = GETPOST($queryName, 'alpha'); - } - } - $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_'); + // Initialize array of search criterias + $search = array(); + foreach ($arrayfields as $key => $val) + { + $queryName = 'search_'.substr($key, 2); + if (GETPOST($queryName, 'alpha')) { + $search[substr($key, 2)] = GETPOST($queryName, 'alpha'); + } + } + $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_'); - // 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 - { - $search_status = ''; - $search_name = ''; - $search_roles = array(); - $search_address = ''; - $search_poste = ''; - $search = array(); - $search_array_options = array(); + // 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 + { + $search_status = ''; + $search_name = ''; + $search_roles = array(); + $search_address = ''; + $search_poste = ''; + $search = array(); + $search_array_options = array(); - foreach ($contactstatic->fields as $key => $val) + foreach ($contactstatic->fields as $key => $val) { $search[$key] = ''; } - } + } - $contactstatic->fields = dol_sort_array($contactstatic->fields, 'position'); - $arrayfields = dol_sort_array($arrayfields, 'position'); + $contactstatic->fields = dol_sort_array($contactstatic->fields, 'position'); + $arrayfields = dol_sort_array($arrayfields, 'position'); - $newcardbutton = ''; - if ($user->rights->societe->contact->creer) - { - $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); - $newcardbutton .= dolGetButtonTitle($addcontact, '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); - } + $newcardbutton = ''; + if ($user->rights->societe->contact->creer) + { + $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + $newcardbutton .= dolGetButtonTitle($addcontact, '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); + } - print "\n"; + print "\n"; - $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany")); - print load_fiche_titre($title, $newcardbutton, ''); + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany")); + print load_fiche_titre($title, $newcardbutton, ''); - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - //if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + //if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print "\n".''."\n"; + print "\n".'
'."\n"; - $param = "socid=".urlencode($object->id); - if ($search_status != '') $param .= '&search_status='.urlencode($search_status); - if (count($search_roles) > 0) $param .= implode('&search_roles[]=', $search_roles); - if ($search_name != '') $param .= '&search_name='.urlencode($search_name); - if ($search_poste != '') $param .= '&search_poste='.urlencode($search_poste); - if ($search_address != '') $param .= '&search_address='.urlencode($search_address); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + $param = "socid=".urlencode($object->id); + if ($search_status != '') $param .= '&search_status='.urlencode($search_status); + if (count($search_roles) > 0) $param .= implode('&search_roles[]=', $search_roles); + if ($search_name != '') $param .= '&search_name='.urlencode($search_name); + if ($search_poste != '') $param .= '&search_poste='.urlencode($search_poste); + if ($search_address != '') $param .= '&search_address='.urlencode($search_address); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - // Add $param from extra fields - $extrafieldsobjectkey = $contactstatic->table_element; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + // Add $param from extra fields + $extrafieldsobjectkey = $contactstatic->table_element; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - $sql = "SELECT t.rowid, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.socialnetworks, t.statut, t.photo,"; - $sql .= " t.civility as civility_id, t.address, t.zip, t.town"; - $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; - $sql .= " WHERE t.fk_soc = ".$object->id; - if ($search_status != '' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); - if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name); - if ($search_poste) $sql .= natural_search('t.poste', $search_poste); - if ($search_address) { + $sql = "SELECT t.rowid, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.socialnetworks, t.statut, t.photo,"; + $sql .= " t.civility as civility_id, t.address, t.zip, t.town"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; + $sql .= " WHERE t.fk_soc = ".$object->id; + if ($search_status != '' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); + if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name); + if ($search_poste) $sql .= natural_search('t.poste', $search_poste); + if ($search_address) { $sql .= natural_search($searchAddressPhoneDBFields, $search_address); } if (count($search_roles) > 0) { $sql .= " AND t.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } - // Add where from extra fields - $extrafieldsobjectkey = $contactstatic->table_element; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; - if ($sortfield == "t.name") $sql .= " ORDER BY t.lastname $sortorder, t.firstname $sortorder"; - else $sql .= " ORDER BY $sortfield $sortorder"; + // Add where from extra fields + $extrafieldsobjectkey = $contactstatic->table_element; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + if ($sortfield == "t.name") $sql .= " ORDER BY t.lastname $sortorder, t.firstname $sortorder"; + else $sql .= " ORDER BY $sortfield $sortorder"; - dol_syslog('core/lib/company.lib.php :: show_contacts', LOG_DEBUG); - $result = $db->query($sql); - if (!$result) dol_print_error($db); + dol_syslog('core/lib/company.lib.php :: show_contacts', LOG_DEBUG); + $result = $db->query($sql); + if (!$result) dol_print_error($db); - $num = $db->num_rows($result); + $num = $db->num_rows($result); - // Fields title search - // -------------------------------------------------------------------- - print ''; - foreach ($contactstatic->fields as $key => $val) - { - $align = ''; - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; - if ($key == 'status' || $key == 'statut') $align .= ($align ? ' ' : '').'center'; - if (!empty($arrayfields['t.'.$key]['checked']) || !empty($arrayfields['sc.'.$key]['checked'])) - { - print ''; - } - } - // Extra fields - $extrafieldsobjectkey = $contactstatic->table_element; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields title search + // -------------------------------------------------------------------- + print ''; + foreach ($contactstatic->fields as $key => $val) + { + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status' || $key == 'statut') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked']) || !empty($arrayfields['sc.'.$key]['checked'])) + { + print ''; + } + } + // Extra fields + $extrafieldsobjectkey = $contactstatic->table_element; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields); - $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Action column - print ''; - print ''."\n"; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + print ''."\n"; - // Fields title label - // -------------------------------------------------------------------- - print ''; - foreach ($contactstatic->fields as $key => $val) - { - $align = ''; - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; - if ($key == 'status' || $key == 'statut') $align .= ($align ? ' ' : '').'center'; - if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($val['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; - if ($key == 'role') $align .= ($align ? ' ' : '').'left'; - if (!empty($arrayfields['sc.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], '', '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; - } - } - // Extra fields - $extrafieldsobjectkey = $contactstatic->table_element; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields + // Fields title label + // -------------------------------------------------------------------- + print ''; + foreach ($contactstatic->fields as $key => $val) + { + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status' || $key == 'statut') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($val['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; + if ($key == 'role') $align .= ($align ? ' ' : '').'left'; + if (!empty($arrayfields['sc.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], '', '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; + } + } + // Extra fields + $extrafieldsobjectkey = $contactstatic->table_element; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; - print ''."\n"; + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; + print ''."\n"; - $i = -1; + $i = -1; if ($num || (GETPOST('button_search') || GETPOST('button_search.x') || GETPOST('button_search_x'))) - { - $i = 0; + { + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($result); + while ($i < $num) + { + $obj = $db->fetch_object($result); - $contactstatic->id = $obj->rowid; - $contactstatic->ref = $obj->ref; - $contactstatic->statut = $obj->statut; - $contactstatic->lastname = $obj->lastname; - $contactstatic->firstname = $obj->firstname; - $contactstatic->civility_id = $obj->civility_id; - $contactstatic->civility_code = $obj->civility_id; - $contactstatic->poste = $obj->poste; - $contactstatic->address = $obj->address; - $contactstatic->zip = $obj->zip; - $contactstatic->town = $obj->town; - $contactstatic->phone_pro = $obj->phone_pro; - $contactstatic->phone_mobile = $obj->phone_mobile; - $contactstatic->phone_perso = $obj->phone_perso; - $contactstatic->email = $obj->email; - $contactstatic->web = $obj->web; - $contactstatic->socialnetworks = $obj->socialnetworks; - $contactstatic->photo = $obj->photo; + $contactstatic->id = $obj->rowid; + $contactstatic->ref = $obj->ref; + $contactstatic->statut = $obj->statut; + $contactstatic->lastname = $obj->lastname; + $contactstatic->firstname = $obj->firstname; + $contactstatic->civility_id = $obj->civility_id; + $contactstatic->civility_code = $obj->civility_id; + $contactstatic->poste = $obj->poste; + $contactstatic->address = $obj->address; + $contactstatic->zip = $obj->zip; + $contactstatic->town = $obj->town; + $contactstatic->phone_pro = $obj->phone_pro; + $contactstatic->phone_mobile = $obj->phone_mobile; + $contactstatic->phone_perso = $obj->phone_perso; + $contactstatic->email = $obj->email; + $contactstatic->web = $obj->web; + $contactstatic->socialnetworks = $obj->socialnetworks; + $contactstatic->photo = $obj->photo; - $country_code = getCountry($obj->country_id, 2); - $contactstatic->country_code = $country_code; + $country_code = getCountry($obj->country_id, 2); + $contactstatic->country_code = $country_code; - $contactstatic->setGenderFromCivility(); - $contactstatic->fetch_optionals(); + $contactstatic->setGenderFromCivility(); + $contactstatic->fetch_optionals(); - $resultRole = $contactstatic->fetchRoles(); - if ($resultRole < 0) { - setEventMessages(null, $contactstatic->errors, 'errors'); - } + $resultRole = $contactstatic->fetchRoles(); + if ($resultRole < 0) { + setEventMessages(null, $contactstatic->errors, 'errors'); + } - if (is_array($contactstatic->array_options)) - { - foreach ($contactstatic->array_options as $key => $val) - { - $obj->$key = $val; - } - } + if (is_array($contactstatic->array_options)) + { + foreach ($contactstatic->array_options as $key => $val) + { + $obj->$key = $val; + } + } - print ''; + print ''; - // ID - if (!empty($arrayfields['t.rowid']['checked'])) - { - print ''; - } + // ID + if (!empty($arrayfields['t.rowid']['checked'])) + { + print ''; + } // Photo - Name - if (!empty($arrayfields['t.name']['checked'])) - { - print ''; - } + } // Job position - if (!empty($arrayfields['t.poste']['checked'])) - { - print ''; - } + if (!empty($arrayfields['t.poste']['checked'])) + { + print ''; + } - // Address - Phone - Email - if (!empty($arrayfields['t.address']['checked'])) - { - print ''; - } + // Address - Phone - Email + if (!empty($arrayfields['t.address']['checked'])) + { + print ''; + } - // Role - if (!empty($arrayfields['sc.role']['checked'])) - { - print ''; - } + // Role + if (!empty($arrayfields['sc.role']['checked'])) + { + print ''; + } - // Status - if (!empty($arrayfields['t.statut']['checked'])) - { - print ''; - } + // Status + if (!empty($arrayfields['t.statut']['checked'])) + { + print ''; + } - // Extra fields - $extrafieldsobjectkey = $contactstatic->table_element; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Extra fields + $extrafieldsobjectkey = $contactstatic->table_element; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Actions + // Actions print ''; + print ''; - print "\n"; - $i++; - } - } else { + print "\n"; + $i++; + } + } else { $colspan = 1; foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; - } - print "\n
'; - if (in_array($key, array('statut'))) { - print $form->selectarray('search_status', array('-1'=>'', '0'=>$contactstatic->LibStatut(0, 1), '1'=>$contactstatic->LibStatut(1, 1)), $search_status); - } elseif (in_array($key, array('role'))) { - print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles); - } else { - print ''; - } - print '
'; + if (in_array($key, array('statut'))) { + print $form->selectarray('search_status', array('-1'=>'', '0'=>$contactstatic->LibStatut(0, 1), '1'=>$contactstatic->LibStatut(1, 1)), $search_status); + } elseif (in_array($key, array('role'))) { + print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles); + } else { + print ''; + } + print ''; - print $form->showFilterButtons(); - print '
'; + print $form->showFilterButtons(); + print '
'; - print $contactstatic->id; - print ''; + print $contactstatic->id; + print ''; - print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, 1); + if (!empty($arrayfields['t.name']['checked'])) + { + print ''; + print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, 1); print $contactstatic->getNomUrl(0, '', 0, '&backtopage='.urlencode($backtopage)); print ''; - if ($obj->poste) print $obj->poste; - print ''; + if ($obj->poste) print $obj->poste; + print ''; - print $contactstatic->getBannerAddress('contact', $object); - print ''; + print $contactstatic->getBannerAddress('contact', $object); + print ''; - print $formcompany->showRoles("roles", $contactstatic, 'view'); - print ''; + print $formcompany->showRoles("roles", $contactstatic, 'view'); + print ''.$contactstatic->getLibStatut(5).''.$contactstatic->getLibStatut(5).''; // Add to agenda - if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) - { - print ''; - print img_object($langs->trans("Event"), "action"); - print '   '; - } + if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + { + print ''; + print img_object($langs->trans("Event"), "action"); + print '   '; + } - // Edit - if ($user->rights->societe->contact->creer) - { - print ''; - print img_edit(); - print ''; - } + // Edit + if ($user->rights->societe->contact->creer) + { + print ''; + print img_edit(); + print ''; + } - print '
'.$langs->trans("None").'
\n"; + } + print "\n\n"; print '
'; - print '
'."\n"; + print ''."\n"; - return $i; + return $i; } @@ -1242,12 +1242,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') */ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '') { - global $user, $conf; + global $user, $conf; - $out = show_actions_done($conf, $langs, $db, $filterobj, $objcon, 1, $actioncode, 'todo'); + $out = show_actions_done($conf, $langs, $db, $filterobj, $objcon, 1, $actioncode, 'todo'); - if ($noprint) return $out; - else print $out; + if ($noprint) return $out; + else print $out; } /** @@ -1270,333 +1270,333 @@ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprin */ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC', $module = '') { - global $user, $conf; - global $form; + global $user, $conf; + global $form; - global $param, $massactionbutton; - $start_year = GETPOST('dateevent_startyear'); - $start_month = GETPOST('dateevent_startmonth'); - $start_day = GETPOST('dateevent_startday'); - $end_year = GETPOST('dateevent_endyear'); - $end_month = GETPOST('dateevent_endmonth'); - $end_day = GETPOST('dateevent_endday'); - if (!empty($start_year) && !empty($start_month) && !empty($start_day)) { - $search_start = $start_year.'-'.$start_month.'-'.$start_day; - $tms_start = strtotime($search_start); - } - if (!empty($end_year) && !empty($end_month) && !empty($end_day)) { - $search_end = $end_year.'-'.$end_month.'-'.$end_day.' 23:59:59'; - $tms_end = strtotime($search_end); - } - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { - $search_start = ''; - $tms_start = ''; - $search_end = ''; - $tms_end = ''; - } - dol_include_once('/comm/action/class/actioncomm.class.php'); + global $param, $massactionbutton; + $start_year = GETPOST('dateevent_startyear'); + $start_month = GETPOST('dateevent_startmonth'); + $start_day = GETPOST('dateevent_startday'); + $end_year = GETPOST('dateevent_endyear'); + $end_month = GETPOST('dateevent_endmonth'); + $end_day = GETPOST('dateevent_endday'); + if (!empty($start_year) && !empty($start_month) && !empty($start_day)) { + $search_start = $start_year.'-'.$start_month.'-'.$start_day; + $tms_start = strtotime($search_start); + } + if (!empty($end_year) && !empty($end_month) && !empty($end_day)) { + $search_end = $end_year.'-'.$end_month.'-'.$end_day.' 23:59:59'; + $tms_end = strtotime($search_end); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers + { + $search_start = ''; + $tms_start = ''; + $search_end = ''; + $tms_end = ''; + } + dol_include_once('/comm/action/class/actioncomm.class.php'); - // Check parameters - if (!is_object($filterobj) && !is_object($objcon)) dol_print_error('', 'BadParameter'); + // Check parameters + if (!is_object($filterobj) && !is_object($objcon)) dol_print_error('', 'BadParameter'); - $out = ''; - $histo = array(); - $numaction = 0; - $now = dol_now('tzuser'); + $out = ''; + $histo = array(); + $numaction = 0; + $now = dol_now('tzuser'); - // Open DSI -- Fix order by -- Begin - $sortfield_list = explode(',', $sortfield); - $sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent'); - $sortfield_new_list = array(); - foreach ($sortfield_list as $sortfield_value) { - $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)]; - } - $sortfield_new = implode(',', $sortfield_new_list); + // Open DSI -- Fix order by -- Begin + $sortfield_list = explode(',', $sortfield); + $sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent'); + $sortfield_new_list = array(); + foreach ($sortfield_list as $sortfield_value) { + $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)]; + } + $sortfield_new = implode(',', $sortfield_new_list); - $sql = ''; + $sql = ''; - if (!empty($conf->agenda->enabled)) - { - // Recherche histo sur actioncomm - if (is_object($objcon) && $objcon->id > 0) { - $sql = "SELECT DISTINCT a.id, a.label as label,"; - } else { - $sql = "SELECT a.id, a.label as label,"; - } - $sql .= " a.datep as dp,"; - $sql .= " a.datep2 as dp2,"; - $sql .= " a.percent as percent, 'action' as type,"; - $sql .= " a.fk_element, a.elementtype,"; - $sql .= " a.fk_contact,"; - $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; - $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; - if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) $sql .= ", sp.lastname, sp.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Project') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", m.lastname, m.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref"; - elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) $sql .= ", o.ref"; + if (!empty($conf->agenda->enabled)) + { + // Recherche histo sur actioncomm + if (is_object($objcon) && $objcon->id > 0) { + $sql = "SELECT DISTINCT a.id, a.label as label,"; + } else { + $sql = "SELECT a.id, a.label as label,"; + } + $sql .= " a.datep as dp,"; + $sql .= " a.datep2 as dp2,"; + $sql .= " a.percent as percent, 'action' as type,"; + $sql .= " a.fk_element, a.elementtype,"; + $sql .= " a.fk_contact,"; + $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; + $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; + if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) $sql .= ", sp.lastname, sp.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Project') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", m.lastname, m.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref"; + elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) $sql .= ", o.ref"; - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; - $force_filter_contact = false; - if (is_object($objcon) && $objcon->id > 0) { - $force_filter_contact = true; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; - $sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".$objcon->id; - } + $force_filter_contact = false; + if (is_object($objcon) && $objcon->id > 0) { + $force_filter_contact = true; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; + $sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".$objcon->id; + } - if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; - $sql .= " ON er.resource_type = 'dolresource'"; - $sql .= " AND er.element_id = a.id"; - $sql .= " AND er.resource_id = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Project') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", ".MAIN_DB_PREFIX."product as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o"; - elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) $sql .= ", ".MAIN_DB_PREFIX.$filterobj->table_element." as o"; + if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " ON er.resource_type = 'dolresource'"; + $sql .= " AND er.element_id = a.id"; + $sql .= " AND er.resource_id = ".$filterobj->id; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Project') { /* Nothing */ } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", ".MAIN_DB_PREFIX."product as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o"; + elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) $sql .= ", ".MAIN_DB_PREFIX.$filterobj->table_element." as o"; - $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; - if ($force_filter_contact === false) { - if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id; - elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ } - elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') - { - $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') - { - $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') - { - $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') - { - $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') - { - $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') - { - $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) - { - // Generic case - $sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ? '@'.$module : '')."'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } - } + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; + if ($force_filter_contact === false) { + if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id; + elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { /* Nothing */ } + elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') + { + $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') + { + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') + { + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') + { + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') + { + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') + { + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element) + { + // Generic case + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ? '@'.$module : '')."'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + } + } - if (! empty($search_start) && ! empty($search_end)) { - $sql .= " AND ((a.datep BETWEEN '$search_start' AND '$search_end') OR (a.datep2 BETWEEN '$search_start' AND '$search_end'))"; - } - elseif (empty($search_start) && ! empty($search_end)) { - $sql .= " AND ((a.datep <= '$search_end') OR (a.datep2 <= '$search_end'))"; - } - elseif (! empty($search_start) && empty($search_end)) { - $sql .= " AND ((a.datep >= '$search_start') OR (a.datep2 >= '$search_start'))"; - } + if (! empty($search_start) && ! empty($search_end)) { + $sql .= " AND ((a.datep BETWEEN '$search_start' AND '$search_end') OR (a.datep2 BETWEEN '$search_start' AND '$search_end'))"; + } + elseif (empty($search_start) && ! empty($search_end)) { + $sql .= " AND ((a.datep <= '$search_end') OR (a.datep2 <= '$search_end'))"; + } + elseif (! empty($search_start) && empty($search_end)) { + $sql .= " AND ((a.datep >= '$search_start') OR (a.datep2 >= '$search_start'))"; + } - if (is_array($actioncode) && ! empty($actioncode)) { - $sql .= ' AND ('; - foreach ($actioncode as $key => $code) { - if ($key != 0) $sql .= "OR ("; - if (! empty($code)) addEventTypeSQL($sql, $code, $donetodo, $now, $filters, ""); - if ($key != 0) $sql .= ")"; - } - $sql .= ')'; - } - elseif (! empty($actioncode)) addEventTypeSQL($sql, $actioncode, $donetodo, $now, $filters); + if (is_array($actioncode) && ! empty($actioncode)) { + $sql .= ' AND ('; + foreach ($actioncode as $key => $code) { + if ($key != 0) $sql .= "OR ("; + if (! empty($code)) addEventTypeSQL($sql, $code, $donetodo, $now, $filters, ""); + if ($key != 0) $sql .= ")"; + } + $sql .= ')'; + } + elseif (! empty($actioncode)) addEventTypeSQL($sql, $actioncode, $donetodo, $now, $filters); - if (is_array($actioncode)) { - foreach ($actioncode as $code) { - $sql2 = addMailingEventTypeSQL($code, $objcon, $filterobj); - if (! empty($sql2)) { - if (! empty($sql)) $sql = $sql." UNION ".$sql2; - elseif (empty($sql)) $sql = $sql2; - break; - } - } - } - else { - $sql2 = addMailingEventTypeSQL($actioncode, $objcon, $filterobj); - if (! empty($sql) && ! empty($sql2)) { - $sql = $sql." UNION ".$sql2; - } - elseif (empty($sql) && ! empty($sql2)) { - $sql = $sql2; - } - } - } + if (is_array($actioncode)) { + foreach ($actioncode as $code) { + $sql2 = addMailingEventTypeSQL($code, $objcon, $filterobj); + if (! empty($sql2)) { + if (! empty($sql)) $sql = $sql." UNION ".$sql2; + elseif (empty($sql)) $sql = $sql2; + break; + } + } + } + else { + $sql2 = addMailingEventTypeSQL($actioncode, $objcon, $filterobj); + if (! empty($sql) && ! empty($sql2)) { + $sql = $sql." UNION ".$sql2; + } + elseif (empty($sql) && ! empty($sql2)) { + $sql = $sql2; + } + } + } - //TODO Add limit in nb of results - if ($sql) - { - $sql .= $db->order($sortfield_new, $sortorder); - dol_syslog("company.lib::show_actions_done", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + //TODO Add limit in nb of results + if ($sql) + { + $sql .= $db->order($sortfield_new, $sortorder); + dol_syslog("company.lib::show_actions_done", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - if ($obj->type == 'action') { - $contactaction = new ActionComm($db); - $contactaction->id = $obj->id; - $result = $contactaction->fetchResources(); - if ($result < 0) { - dol_print_error($db); - setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); - } + if ($obj->type == 'action') { + $contactaction = new ActionComm($db); + $contactaction->id = $obj->id; + $result = $contactaction->fetchResources(); + if ($result < 0) { + dol_print_error($db); + setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); + } - //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - $tododone = ''; - if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo'; + //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + $tododone = ''; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo'; - $histo[$numaction] = array( - 'type'=>$obj->type, - 'tododone'=>$tododone, - 'id'=>$obj->id, - 'datestart'=>$db->jdate($obj->dp), - 'dateend'=>$db->jdate($obj->dp2), - 'note'=>$obj->label, - 'percent'=>$obj->percent, + $histo[$numaction] = array( + 'type'=>$obj->type, + 'tododone'=>$tododone, + 'id'=>$obj->id, + 'datestart'=>$db->jdate($obj->dp), + 'dateend'=>$db->jdate($obj->dp2), + 'note'=>$obj->label, + 'percent'=>$obj->percent, - 'userid'=>$obj->user_id, - 'login'=>$obj->user_login, - 'userfirstname'=>$obj->user_firstname, - 'userlastname'=>$obj->user_lastname, - 'userphoto'=>$obj->user_photo, + 'userid'=>$obj->user_id, + 'login'=>$obj->user_login, + 'userfirstname'=>$obj->user_firstname, + 'userlastname'=>$obj->user_lastname, + 'userphoto'=>$obj->user_photo, - 'contact_id'=>$obj->fk_contact, - 'socpeopleassigned' => $contactaction->socpeopleassigned, - 'lastname'=>$obj->lastname, - 'firstname'=>$obj->firstname, - 'fk_element'=>$obj->fk_element, - 'elementtype'=>$obj->elementtype, - // Type of event - 'acode'=>$obj->acode, - 'alabel'=>$obj->alabel, - 'libelle'=>$obj->alabel, // deprecated - 'apicto'=>$obj->apicto - ); - } else { - $histo[$numaction] = array( - 'type'=>$obj->type, - 'tododone'=>'done', - 'id'=>$obj->id, - 'datestart'=>$db->jdate($obj->dp), - 'dateend'=>$db->jdate($obj->dp2), - 'note'=>$obj->label, - 'percent'=>$obj->percent, - 'acode'=>$obj->acode, + 'contact_id'=>$obj->fk_contact, + 'socpeopleassigned' => $contactaction->socpeopleassigned, + 'lastname'=>$obj->lastname, + 'firstname'=>$obj->firstname, + 'fk_element'=>$obj->fk_element, + 'elementtype'=>$obj->elementtype, + // Type of event + 'acode'=>$obj->acode, + 'alabel'=>$obj->alabel, + 'libelle'=>$obj->alabel, // deprecated + 'apicto'=>$obj->apicto + ); + } else { + $histo[$numaction] = array( + 'type'=>$obj->type, + 'tododone'=>'done', + 'id'=>$obj->id, + 'datestart'=>$db->jdate($obj->dp), + 'dateend'=>$db->jdate($obj->dp2), + 'note'=>$obj->label, + 'percent'=>$obj->percent, + 'acode'=>$obj->acode, - 'userid'=>$obj->user_id, - 'login'=>$obj->user_login, - 'userfirstname'=>$obj->user_firstname, - 'userlastname'=>$obj->user_lastname, - 'userphoto'=>$obj->user_photo - ); - } + 'userid'=>$obj->user_id, + 'login'=>$obj->user_login, + 'userfirstname'=>$obj->user_firstname, + 'userlastname'=>$obj->user_lastname, + 'userphoto'=>$obj->user_photo + ); + } - $numaction++; - $i++; - } - } else { - dol_print_error($db); - } - } + $numaction++; + $i++; + } + } else { + dol_print_error($db); + } + } - if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) - { - $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; + if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) + { + $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $formactions = new FormActions($db); + $formactions = new FormActions($db); - $actionstatic = new ActionComm($db); - $userstatic = new User($db); - $contactstatic = new Contact($db); + $actionstatic = new ActionComm($db); + $userstatic = new User($db); + $contactstatic = new Contact($db); - $out .= '
'; - if ($objcon && get_class($objcon) == 'Contact' && - (is_null($filterobj) || get_class($filterobj) == 'Societe')) - { - $out .= ''; - } else { - $out .= ''; - } - if ($filterobj && get_class($filterobj) == 'Societe') $out .= ''; + $out .= ''; + if ($objcon && get_class($objcon) == 'Contact' && + (is_null($filterobj) || get_class($filterobj) == 'Societe')) + { + $out .= ''; + } else { + $out .= ''; + } + if ($filterobj && get_class($filterobj) == 'Societe') $out .= ''; - $out .= "\n"; + $out .= "\n"; - $out .= '
'; - $out .= ''; + $out .= '
'; + $out .= '
'; - $out .= ''; - if ($donetodo) - { - $out .= ''; - } - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - // Action column - $out .= ''; - $out .= ''; - - $out .= ''; + $out .= ''; if ($donetodo) { - $tmp = ''; - if (get_class($filterobj) == 'Societe') $tmp .= ''; - $tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); - $tmp .= ($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : ''); - $tmp .= ($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : ''); - //$out.=$langs->trans("ActionsToDoShort").' / '.$langs->trans("ActionsDoneShort"); - if (get_class($filterobj) == 'Societe') $tmp .= ''; - $out .= getTitleFieldOfList($tmp); + $out .= ''; + } + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + // Action column + $out .= ''; + $out .= ''; + + $out .= ''; + if ($donetodo) + { + $tmp = ''; + if (get_class($filterobj) == 'Societe') $tmp .= ''; + $tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); + $tmp .= ($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : ''); + $tmp .= ($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : ''); + //$out.=$langs->trans("ActionsToDoShort").' / '.$langs->trans("ActionsDoneShort"); + if (get_class($filterobj) == 'Societe') $tmp .= ''; + $out .= getTitleFieldOfList($tmp); } $out .= getTitleFieldOfList($langs->trans("Ref"), 0, $_SERVER["PHP_SELF"], 'a.id', '', $param, '', $sortfield, $sortorder); $out .= getTitleFieldOfList($langs->trans("Owner")); - $out .= getTitleFieldOfList($langs->trans("Type")); + $out .= getTitleFieldOfList($langs->trans("Type")); $out .= getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - $out .= getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder); - $out .= getTitleFieldOfList($langs->trans("RelatedObjects"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder); + $out .= getTitleFieldOfList($langs->trans("RelatedObjects"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); $out .= getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); $out .= getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder); $out .= getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); @@ -1606,133 +1606,133 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $caction = new CActionComm($db); $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); - foreach ($histo as $key => $value) - { + foreach ($histo as $key => $value) + { $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo $actionstatic->type_picto = $histo[$key]['apicto']; $actionstatic->type_code = $histo[$key]['acode']; - $out .= ''; + $out .= ''; - // Done or todo - if ($donetodo) - { - $out .= ''; - } + // Done or todo + if ($donetodo) + { + $out .= ''; + } - // Ref - $out .= ''; + // Ref + $out .= ''; - // Author of event - $out .= ''; + // Author of event + $out .= ''; - // Type - $out .= ''; + // Type + $out .= ''; - // Title - $out .= ''; + // Title + $out .= ''; - // Date - $out .= '\n"; + // Date + $out .= '\n"; - // Title of event - //$out.=''; + // Title of event + //$out.=''; - // Linked object - $out .= ''; + // Linked object + $out .= ''; - // Contact(s) for action - if (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) - { - $contactstatic->lastname = $histo[$key]['lastname']; - $contactstatic->firstname = $histo[$key]['firstname']; - $contactstatic->id = $histo[$key]['contact_id']; - $out .= ''; - } elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) { + // Contact(s) for action + if (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) + { + $contactstatic->lastname = $histo[$key]['lastname']; + $contactstatic->firstname = $histo[$key]['firstname']; + $contactstatic->id = $histo[$key]['contact_id']; + $out .= ''; + } elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) { $out .= ''; } else { - $out .= ''; - } + $out .= ''; + } - // Status - $out .= ''; + // Status + $out .= ''; - // Actions - $out .= ''; + // Actions + $out .= ''; - $out .= "\n"; - $i++; - } - $out .= "
'; - $out .= $formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, (empty($conf->global->AGENDA_USE_MULTISELECT_TYPE) ? 0 : 1), 1); - $out .= ''.$form->selectDateToDate($tms_start, $tms_end, 'dateevent', 1).''; - $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); - $out .= $searchpicto; - $out .= '
'; + $out .= $formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, (empty($conf->global->AGENDA_USE_MULTISELECT_TYPE) ? 0 : 1), 1); + $out .= ''.$form->selectDateToDate($tms_start, $tms_end, 'dateevent', 1).''; + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + $out .= $searchpicto; + $out .= '
'; - $out .= ''; + $out .= ''; - if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { - $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; - $out .= $histo[$key]['id']; - $out .= ''; - } else { - $out .= $actionstatic->getNomUrl(1, -1); - } - $out .= ''; + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { + $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; + $out .= $histo[$key]['id']; + $out .= ''; + } else { + $out .= $actionstatic->getNomUrl(1, -1); + } + $out .= ''; - //$userstatic->id=$histo[$key]['userid']; - //$userstatic->login=$histo[$key]['login']; - //$out.=$userstatic->getLoginUrl(1); - if ($histo[$key]['userid'] > 0) - { - $userstatic->fetch($histo[$key]['userid']); // TODO Introduce a cache on users fetched - $out .= $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); - } - $out .= ''; + //$userstatic->id=$histo[$key]['userid']; + //$userstatic->login=$histo[$key]['login']; + //$out.=$userstatic->getLoginUrl(1); + if ($histo[$key]['userid'] > 0) + { + $userstatic->fetch($histo[$key]['userid']); // TODO Introduce a cache on users fetched + $out .= $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); + } + $out .= ''; - // TODO Code common with code into showactions - $imgpicto = ''; - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actionstatic->type_picto) { - $imgpicto .= img_picto('', $actionstatic->type_picto); - } - else { - if ($actionstatic->type_code == 'AC_RDV') $imgpicto .= img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actionstatic->type_code == 'AC_TEL') $imgpicto .= img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actionstatic->type_code == 'AC_FAX') $imgpicto .= img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actionstatic->type_code == 'AC_EMAIL' || $actionstatic->type_code == 'AC_EMAIL_IN') $imgpicto .= img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actionstatic->type_code == 'AC_INT') $imgpicto .= img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') $imgpicto = img_picto('', 'object_conversation', '', false, 0, 0, '', 'paddingright').' '; - elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) $imgpicto .= img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; - } - } - $out .= $imgpicto; - $labeltype = $actionstatic->type_code; - if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH'; - if ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') { - $labeltype = $langs->trans("Message"); - } else { - if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; - if ($actionstatic->type_code == 'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) $labeltype .= ' - '.$arraylist[$actionstatic->code]; // Use code in priority on type_code - } - $out .= dol_trunc($labeltype, 28); - $out .= ''; + // TODO Code common with code into showactions + $imgpicto = ''; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actionstatic->type_picto) { + $imgpicto .= img_picto('', $actionstatic->type_picto); + } + else { + if ($actionstatic->type_code == 'AC_RDV') $imgpicto .= img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actionstatic->type_code == 'AC_TEL') $imgpicto .= img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actionstatic->type_code == 'AC_FAX') $imgpicto .= img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actionstatic->type_code == 'AC_EMAIL' || $actionstatic->type_code == 'AC_EMAIL_IN') $imgpicto .= img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actionstatic->type_code == 'AC_INT') $imgpicto .= img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') $imgpicto = img_picto('', 'object_conversation', '', false, 0, 0, '', 'paddingright').' '; + elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) $imgpicto .= img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; + } + } + $out .= $imgpicto; + $labeltype = $actionstatic->type_code; + if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH'; + if ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') { + $labeltype = $langs->trans("Message"); + } else { + if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; + if ($actionstatic->type_code == 'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) $labeltype .= ' - '.$arraylist[$actionstatic->code]; // Use code in priority on type_code + } + $out .= dol_trunc($labeltype, 28); + $out .= ''; - if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') - { - $transcode = $langs->trans("Action".$histo[$key]['acode']); - $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); - //$actionstatic->libelle=$libelle; - $libelle = $histo[$key]['note']; - $actionstatic->id = $histo[$key]['id']; - $out .= dol_trunc($libelle, 120); - } - if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') - { - $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; - $transcode = $langs->trans("Action".$histo[$key]['acode']); - $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing'); - $out .= dol_trunc($libelle, 120); - } - $out .= ''; + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') + { + $transcode = $langs->trans("Action".$histo[$key]['acode']); + $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); + //$actionstatic->libelle=$libelle; + $libelle = $histo[$key]['note']; + $actionstatic->id = $histo[$key]['id']; + $out .= dol_trunc($libelle, 120); + } + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') + { + $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; + $transcode = $langs->trans("Action".$histo[$key]['acode']); + $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing'); + $out .= dol_trunc($libelle, 120); + } + $out .= ''; - $out .= dol_print_date($histo[$key]['datestart'], 'dayhour', 'tzuserrel'); - if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) - { - $tmpa = dol_getdate($histo[$key]['datestart'], true); - $tmpb = dol_getdate($histo[$key]['dateend'], true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour', 'tzuserrel'); - else $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour', 'tzuserrel'); - } - $late = 0; - if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; - if ($histo[$key]['percent'] == 0 && !$histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; - if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) $late = 1; - if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && !$histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; - if ($late) $out .= img_warning($langs->trans("Late")).' '; - $out .= "'; + $out .= dol_print_date($histo[$key]['datestart'], 'dayhour', 'tzuserrel'); + if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) + { + $tmpa = dol_getdate($histo[$key]['datestart'], true); + $tmpb = dol_getdate($histo[$key]['dateend'], true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour', 'tzuserrel'); + else $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour', 'tzuserrel'); + } + $late = 0; + if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] == 0 && !$histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && !$histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($late) $out .= img_warning($langs->trans("Late")).' '; + $out .= "'.dol_trunc($histo[$key]['note'], 40).''.dol_trunc($histo[$key]['note'], 40).''; - if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) - { - $out .= dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1); - } else $out .= ' '; - $out .= ''; + if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) + { + $out .= dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1); + } else $out .= ' '; + $out .= ''.$contactstatic->getNomUrl(1, '', 10).''.$contactstatic->getNomUrl(1, '', 10).''; $contact = new Contact($db); foreach ($histo[$key]['socpeopleassigned'] as $cid => $value) { @@ -1752,26 +1752,26 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } $out .= '  '.$actionstatic->LibStatut($histo[$key]['percent'], 3, 0, $histo[$key]['datestart']).''.$actionstatic->LibStatut($histo[$key]['percent'], 3, 0, $histo[$key]['datestart']).'
\n"; - $out .= "
\n"; + $out .= "\n"; + $i++; + } + $out .= "\n"; + $out .= "\n"; - $out .= '
'; - } + $out .= ''; + } - if ($noprint) return $out; - else print $out; + if ($noprint) return $out; + else print $out; } /** @@ -1869,11 +1869,11 @@ function show_subsidiaries($conf, $langs, $db, $object) */ function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDOR = "AND") { - global $conf, $db; - // Condition on actioncode + global $conf, $db; + // Condition on actioncode if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { + { if ($actioncode == 'AC_NON_AUTO') $sql .= " $sqlANDOR c.type != 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " $sqlANDOR c.type = 'systemauto'"; else { @@ -1887,11 +1887,11 @@ function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDO else $sql .= " $sqlANDOR c.code = '".$db->escape($actioncode)."'"; } - if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); + if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); - return $sql; + return $sql; } /** @@ -1904,26 +1904,26 @@ function addEventTypeSQL(&$sql, $actioncode, $donetodo, $now, $filters, $sqlANDO */ function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) { - global $conf, $langs, $db; - // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. - if (!empty($conf->mailing->enabled) && !empty($objcon->email) - && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) { - $langs->load("mails"); + global $conf, $langs, $db; + // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. + if (!empty($conf->mailing->enabled) && !empty($objcon->email) + && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) { + $langs->load("mails"); - $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; - $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id"; - $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; - $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref"; - $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; - $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. - $sql2 .= " AND mc.statut = 1"; - $sql2 .= " AND u.rowid = m.fk_user_valid"; - $sql2 .= " AND mc.fk_mailing=m.rowid"; - return $sql2; - } + $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; + $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id"; + $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; + $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; + $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. + $sql2 .= " AND mc.statut = 1"; + $sql2 .= " AND u.rowid = m.fk_user_valid"; + $sql2 .= " AND mc.fk_mailing=m.rowid"; + return $sql2; + } } diff --git a/htdocs/core/lib/expedition.lib.php b/htdocs/core/lib/expedition.lib.php index ef687ef1131..b575247e84b 100644 --- a/htdocs/core/lib/expedition.lib.php +++ b/htdocs/core/lib/expedition.lib.php @@ -60,9 +60,9 @@ function expedition_prepare_head(Expedition $object) complete_head_from_modules($conf, $langs, $object, $head, $h, 'order'); - complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove'); - return $head; + return $head; } /** @@ -95,18 +95,18 @@ function expedition_admin_prepare_head() if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { - $head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFields"); - $head[$h][2] = 'attributes_shipment'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][2] = 'attributes_shipment'; + $h++; } if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { - $head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFieldsLines"); - $head[$h][2] = 'attributeslines_shipment'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsLines"); + $head[$h][2] = 'attributeslines_shipment'; + $h++; } if (!empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 596a38346ae..fb6f25eee4b 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -958,11 +958,11 @@ function dolCheckVirus($src_file) if (!class_exists('AntiVir')) { require_once DOL_DOCUMENT_ROOT.'/core/class/antivir.class.php'; } - $antivir=new AntiVir($db); + $antivir = new AntiVir($db); $result = $antivir->dol_avscan_file($src_file); if ($result < 0) // If virus or error, we stop here { - $reterrors=$antivir->errors; + $reterrors = $antivir->errors; return $reterrors; } } @@ -1049,7 +1049,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable { // $upload_dir ends with a slash, so be must be sure the medias dir to compare to ends with slash too. $publicmediasdirwithslash = $conf->medias->multidir_output[$conf->entity]; - if (! preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash.='/'; + if (!preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash .= '/'; if (strpos($upload_dir, $publicmediasdirwithslash) !== 0) { // We never add .noexe on files into media directory $file_name .= '.noexe'; @@ -2771,7 +2771,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (preg_match('/^specimen/i', $original_file)) $accessallowed = 1; // If link to a file called specimen. Test must be done before changing $original_file int full path. if ($fuser->admin) $accessallowed = 1; // If user is admin $tmpmodulepart = explode('-', $modulepart); - if (! empty($tmpmodulepart[1])) { + if (!empty($tmpmodulepart[1])) { $modulepart = $tmpmodulepart[0]; $original_file = $tmpmodulepart[1].'/'.$original_file; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 563a30dbbeb..5d96b31488b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -357,7 +357,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null } if (!empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { - if (!empty($_GET['action']) && (preg_match('/^create/', $_GET['action']) || preg_match('/^presend/', $_GET['action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) + if (!empty($_GET['action']) && (preg_match('/^create/', $_GET['action']) || preg_match('/^presend/', $_GET['action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { // Now search in setup to overwrite default values if (!empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' @@ -629,22 +629,22 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null if (!function_exists('dol_getprefix')) { - /** - * Return a prefix to use for this Dolibarr instance, for session/cookie names or email id. - * The prefix is unique for instance and avoid conflict between multi-instances, even when having two instances with same root dir - * or two instances in same virtual servers. - * - * @param string $mode '' (prefix for session name) or 'email' (prefix for email id) - * @return string A calculated prefix - */ - function dol_getprefix($mode = '') - { - global $conf; + /** + * Return a prefix to use for this Dolibarr instance, for session/cookie names or email id. + * The prefix is unique for instance and avoid conflict between multi-instances, even when having two instances with same root dir + * or two instances in same virtual servers. + * + * @param string $mode '' (prefix for session name) or 'email' (prefix for email id) + * @return string A calculated prefix + */ + function dol_getprefix($mode = '') + { + global $conf; // If prefix is for email if ($mode == 'email') { - if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) // If MAIL_PREFIX_FOR_EMAIL_ID is set (a value initialized with a random value is recommended) + if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) // If MAIL_PREFIX_FOR_EMAIL_ID is set (a value initialized with a random value is recommended) { if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; elseif (isset($_SERVER["SERVER_NAME"])) return $_SERVER["SERVER_NAME"]; @@ -907,7 +907,7 @@ function dol_string_unaccent($str) return rawurldecode($string); } else { // See http://www.ascii-code.com/ - $string = strtr( + $string = strtr( $str, "\xC0\xC1\xC2\xC3\xC4\xC5\xC7 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1 @@ -1057,7 +1057,7 @@ function dol_strtoupper($utf8_string) */ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = '', $restricttologhandler = '', $logcontext = null) { - global $conf, $user, $debugbar; + global $conf, $user, $debugbar; // If syslog module enabled if (empty($conf->syslog->enabled)) return; @@ -1091,9 +1091,9 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = // If adding log inside HTML page is required if ((!empty($_REQUEST['logtohtml']) && !empty($conf->global->MAIN_ENABLE_LOG_TO_HTML)) - || (!empty($user->rights->debugbar->read) && is_object($debugbar))) + || (!empty($user->rights->debugbar->read) && is_object($debugbar))) { - $conf->logbuffer[] = dol_print_date(time(), "%Y-%m-%d %H:%M:%S")." ".$logLevels[$level]." ".$message; + $conf->logbuffer[] = dol_print_date(time(), "%Y-%m-%d %H:%M:%S")." ".$logLevels[$level]." ".$message; } //TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output @@ -1523,7 +1523,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi if (!$phototoshow) // Show No photo link (picto of object) { - $morehtmlleft .= '
'; + $morehtmlleft .= '
'; if ($object->element == 'action') { $width = 80; @@ -1872,23 +1872,23 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang $reg = array(); if (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 { - dol_print_error("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]); - return ''; + dol_print_error("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]); + return ''; } elseif (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) // Still available to solve problems in extrafields of type date { - // This part of code should not be used. - dol_syslog("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"], LOG_WARNING); - //if (function_exists('debug_print_backtrace')) debug_print_backtrace(); - // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' - $syear = (!empty($reg[1]) ? $reg[1] : ''); - $smonth = (!empty($reg[2]) ? $reg[2] : ''); - $sday = (!empty($reg[3]) ? $reg[3] : ''); - $shour = (!empty($reg[4]) ? $reg[4] : ''); - $smin = (!empty($reg[5]) ? $reg[5] : ''); - $ssec = (!empty($reg[6]) ? $reg[6] : ''); + // This part of code should not be used. + dol_syslog("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"], LOG_WARNING); + //if (function_exists('debug_print_backtrace')) debug_print_backtrace(); + // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' + $syear = (!empty($reg[1]) ? $reg[1] : ''); + $smonth = (!empty($reg[2]) ? $reg[2] : ''); + $sday = (!empty($reg[3]) ? $reg[3] : ''); + $shour = (!empty($reg[4]) ? $reg[4] : ''); + $smin = (!empty($reg[5]) ? $reg[5] : ''); + $ssec = (!empty($reg[6]) ? $reg[6] : ''); - $time = dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear, true); - $ret = adodb_strftime($format, $time + $offsettz + $offsetdst, $to_gmt); + $time = dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear, true); + $ret = adodb_strftime($format, $time + $offsettz + $offsetdst, $to_gmt); } else { // Date is a timestamps if ($time < 100000000000) // Protection against bad date values @@ -2233,23 +2233,23 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, */ function getArrayOfSocialNetworks() { - global $conf, $db; - $sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; - $sql .= " WHERE entity=".$conf->entity; - $socialnetworks = array(); - $resql = $db->query($sql); - if ($resql) { - while ($obj = $db->fetch_object($resql)) { - $socialnetworks[$obj->code] = array( - 'rowid' => $obj->rowid, - 'label' => $obj->label, - 'url' => $obj->url, - 'icon' => $obj->icon, - 'active' => $obj->active, - ); - } - } - return $socialnetworks; + global $conf, $db; + $sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; + $sql .= " WHERE entity=".$conf->entity; + $socialnetworks = array(); + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $socialnetworks[$obj->code] = array( + 'rowid' => $obj->rowid, + 'label' => $obj->label, + 'url' => $obj->url, + 'icon' => $obj->icon, + 'active' => $obj->active, + ); + } + } + return $socialnetworks; } /** @@ -2436,7 +2436,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli } } elseif (strtoupper($countrycode) == "MU") { - //Maurice + //Maurice if (dol_strlen($phone) == 11) {//ex: +230_ABC_DE_FG $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); @@ -2566,10 +2566,10 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli } } elseif (strtoupper($countrycode) == "AU") { - //Australie + //Australie if (dol_strlen($phone) == 12) { - //ex: +61_A_BCDE_FGHI + //ex: +61_A_BCDE_FGHI $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4); } } @@ -3004,39 +3004,39 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fullpathpicto = $picto; $reg = array(); if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { - $morecss .= ($morecss ? ' ' : '').$reg[1]; - $moreatt = str_replace('class="'.$reg[1].'"', '', $moreatt); + $morecss .= ($morecss ? ' ' : '').$reg[1]; + $moreatt = str_replace('class="'.$reg[1].'"', '', $moreatt); } } else { $pictowithouttext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto); if (empty($srconly) && in_array($pictowithouttext, array( - '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', - 'accountancy', 'address', 'bank_account', 'barcode', 'bank', 'bill', 'bookmark', 'bom', 'building', - 'cash-register', 'category', 'check', 'clock', 'close_title', 'company', 'contact', 'contract', 'cubes', - 'delete', 'dolly', 'dollyrevert', 'edit', 'ellipsis-h', 'email', 'external-link-alt', 'external-link-square-alt', - 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'help', - 'intervention', 'label', 'language', 'list', 'listlight', 'lot', - 'map-marker-alt', 'money-bill-alt', 'mrp', 'note', - 'object_accounting', 'object_action', 'object_account', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom', - 'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_dolly', 'object_dollyrevert', 'object_generic', 'object_folder', - 'object_list-alt', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser', - 'object_cash-register', 'object_company', 'object_contact', 'object_contract', 'object_donation', 'object_dynamicprice', - 'object_globe', 'object_holiday', 'object_hrm', 'object_invoice', 'object_intervention', 'object_label', - 'object_margin', 'object_money-bill-alt', 'object_multicurrency', 'object_order', 'object_payment', - 'object_lot', 'object_mrp', 'object_payment', 'object_product', 'object_propal', - 'object_other', 'object_paragraph', 'object_poll', 'object_printer', 'object_project', 'object_projectpub', 'object_propal', 'object_resource', 'object_rss', 'object_projecttask', - 'object_recruitmentjobposition', 'object_recruitmentcandidature', - 'object_shipment', 'object_share-alt', 'object_supplier_invoice', 'object_supplier_invoicea', 'object_supplier_invoiced', 'object_supplier_order', 'object_supplier_proposal', 'object_service', 'object_stock', - 'object_technic', 'object_ticket', 'object_trip', 'object_user', 'object_group', 'object_member', - 'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website', - 'off', 'on', 'order', - 'paiment', 'play', 'playdisabled', 'poll', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip', + '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', + 'accountancy', 'address', 'bank_account', 'barcode', 'bank', 'bill', 'bookmark', 'bom', 'building', + 'cash-register', 'category', 'check', 'clock', 'close_title', 'company', 'contact', 'contract', 'cubes', + 'delete', 'dolly', 'dollyrevert', 'edit', 'ellipsis-h', 'email', 'external-link-alt', 'external-link-square-alt', + 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'help', + 'intervention', 'label', 'language', 'list', 'listlight', 'lot', + 'map-marker-alt', 'money-bill-alt', 'mrp', 'note', + 'object_accounting', 'object_action', 'object_account', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom', + 'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_dolly', 'object_dollyrevert', 'object_generic', 'object_folder', + 'object_list-alt', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser', + 'object_cash-register', 'object_company', 'object_contact', 'object_contract', 'object_donation', 'object_dynamicprice', + 'object_globe', 'object_holiday', 'object_hrm', 'object_invoice', 'object_intervention', 'object_label', + 'object_margin', 'object_money-bill-alt', 'object_multicurrency', 'object_order', 'object_payment', + 'object_lot', 'object_mrp', 'object_payment', 'object_product', 'object_propal', + 'object_other', 'object_paragraph', 'object_poll', 'object_printer', 'object_project', 'object_projectpub', 'object_propal', 'object_resource', 'object_rss', 'object_projecttask', + 'object_recruitmentjobposition', 'object_recruitmentcandidature', + 'object_shipment', 'object_share-alt', 'object_supplier_invoice', 'object_supplier_invoicea', 'object_supplier_invoiced', 'object_supplier_order', 'object_supplier_proposal', 'object_service', 'object_stock', + 'object_technic', 'object_ticket', 'object_trip', 'object_user', 'object_group', 'object_member', + 'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website', + 'off', 'on', 'order', + 'paiment', 'play', 'playdisabled', 'poll', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip', 'setup', 'share-alt', 'sign-out', 'split', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', - 'home', 'hrm', 'companies', 'products', 'commercial', 'invoicing', 'pencil-ruler', 'preview', 'project', 'projectpub', 'supplier_invoice', 'members', 'ticket', 'generic', - 'error', 'warning', 'supplier_proposal', 'supplier_order', 'supplier_invoice', - 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda' + 'home', 'hrm', 'companies', 'products', 'commercial', 'invoicing', 'pencil-ruler', 'preview', 'project', 'projectpub', 'supplier_invoice', 'members', 'ticket', 'generic', + 'error', 'warning', 'supplier_proposal', 'supplier_order', 'supplier_invoice', + 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda' ) )) { $fakey = $pictowithouttext; @@ -3051,41 +3051,41 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $pictowithouttext = str_replace('object_', '', $pictowithouttext); - $arrayconvpictotofa = array( - 'account'=>'university', 'accountancy'=>'money-check-alt', 'action'=>'calendar-alt', 'address'=> 'address-book', - 'bank_account'=>'university', 'bill'=>'file-invoice-dollar', 'billa'=>'file-excel', 'supplier_invoicea'=>'file-excel', 'billd'=>'file-medical', 'supplier_invoiced'=>'file-medical', 'bom'=>'cubes', - 'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'conversation'=>'comments', 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd', - 'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins', - 'accounting'=>'chart-line', 'category'=>'tag', 'dollyrevert'=>'dolly', - 'hrm'=>'user-tie', 'margin'=>'calculator', 'members'=>'users', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode', - 'email'=>'at', - 'edit'=>'pencil-alt', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle', - 'generic'=>'file', 'holiday'=>'umbrella-beach', 'label'=>'layer-group', - 'member'=>'users', 'mrp'=>'cubes', 'trip'=>'wallet', 'group'=>'users', - 'sign-out'=>'sign-out-alt', - 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star', 'bookmark'=>'star', - 'bank'=>'university', 'close_title'=>'window-close', 'delete'=>'trash', 'edit'=>'pencil-alt', 'filter'=>'filter', - 'list-alt'=>'list-alt', 'calendar'=>'calendar-alt', 'calendarweek'=>'calendar-week', 'calendarmonth'=>'calendar-alt', 'calendarday'=>'calendar-day', 'calendarperuser'=>'table', - 'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'multicurrency'=>'dollar-sign', 'order'=>'file-invoice', - 'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle', - 'other'=>'square', - 'playdisabled'=>'play', 'poll'=>'check-double', 'preview'=>'binoculars', 'project'=>'sitemap', 'projectpub'=>'sitemap', 'projecttask'=>'tasks', 'propal'=>'file-signature', - 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', - 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', - 'payment'=>'money-check-alt', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'printer'=>'print', 'product'=>'cube', 'service'=>'concierge-bell', - 'resource'=>'laptop-house', - 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt', - 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', - 'title_agenda'=>'calendar-alt', - 'uparrow'=>'mail-forward', 'vcard'=>'address-card', - 'jabber'=>'comment-o', - 'website'=>'globe-americas' - ); + $arrayconvpictotofa = array( + 'account'=>'university', 'accountancy'=>'money-check-alt', 'action'=>'calendar-alt', 'address'=> 'address-book', + 'bank_account'=>'university', 'bill'=>'file-invoice-dollar', 'billa'=>'file-excel', 'supplier_invoicea'=>'file-excel', 'billd'=>'file-medical', 'supplier_invoiced'=>'file-medical', 'bom'=>'cubes', + 'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'conversation'=>'comments', 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd', + 'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins', + 'accounting'=>'chart-line', 'category'=>'tag', 'dollyrevert'=>'dolly', + 'hrm'=>'user-tie', 'margin'=>'calculator', 'members'=>'users', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode', + 'email'=>'at', + 'edit'=>'pencil-alt', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle', + 'generic'=>'file', 'holiday'=>'umbrella-beach', 'label'=>'layer-group', + 'member'=>'users', 'mrp'=>'cubes', 'trip'=>'wallet', 'group'=>'users', + 'sign-out'=>'sign-out-alt', + 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star', 'bookmark'=>'star', + 'bank'=>'university', 'close_title'=>'window-close', 'delete'=>'trash', 'edit'=>'pencil-alt', 'filter'=>'filter', + 'list-alt'=>'list-alt', 'calendar'=>'calendar-alt', 'calendarweek'=>'calendar-week', 'calendarmonth'=>'calendar-alt', 'calendarday'=>'calendar-day', 'calendarperuser'=>'table', + 'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'multicurrency'=>'dollar-sign', 'order'=>'file-invoice', + 'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle', + 'other'=>'square', + 'playdisabled'=>'play', 'poll'=>'check-double', 'preview'=>'binoculars', 'project'=>'sitemap', 'projectpub'=>'sitemap', 'projecttask'=>'tasks', 'propal'=>'file-signature', + 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', + 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', + 'payment'=>'money-check-alt', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'printer'=>'print', 'product'=>'cube', 'service'=>'concierge-bell', + 'resource'=>'laptop-house', + 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt', + 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', + 'title_agenda'=>'calendar-alt', + 'uparrow'=>'mail-forward', 'vcard'=>'address-card', + 'jabber'=>'comment-o', + 'website'=>'globe-americas' + ); if ($pictowithouttext == 'off') { - $fakey = 'fa-square'; + $fakey = 'fa-square'; $fasize = '1.3em'; } elseif ($pictowithouttext == 'on') { - $fakey = 'fa-check-square'; + $fakey = 'fa-check-square'; $fasize = '1.3em'; } elseif ($pictowithouttext == 'listlight') { $fakey = 'fa-download'; @@ -3094,12 +3094,12 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fakey = 'fa-print'; $fasize = '1.2em'; } elseif ($pictowithouttext == 'note') { - $fakey = 'fa-sticky-note'; + $fakey = 'fa-sticky-note'; $marginleftonlyshort = 1; } elseif (in_array($pictowithouttext, array('1uparrow', '1downarrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected'))) { - $convertarray = array('1uparrow'=>'caret-up', '1downarrow'=>'caret-down', '1leftarrow'=>'caret-left', '1rightarrow'=>'caret-right', '1uparrow_selected'=>'caret-up', '1downarrow_selected'=>'caret-down', '1leftarrow_selected'=>'caret-left', '1rightarrow_selected'=>'caret-right'); - $fakey = 'fa-'.$convertarray[$pictowithouttext]; - if (preg_match('/selected/', $pictowithouttext)) $facolor = '#888'; + $convertarray = array('1uparrow'=>'caret-up', '1downarrow'=>'caret-down', '1leftarrow'=>'caret-left', '1rightarrow'=>'caret-right', '1uparrow_selected'=>'caret-up', '1downarrow_selected'=>'caret-down', '1leftarrow_selected'=>'caret-left', '1rightarrow_selected'=>'caret-right'); + $fakey = 'fa-'.$convertarray[$pictowithouttext]; + if (preg_match('/selected/', $pictowithouttext)) $facolor = '#888'; $marginleftonlyshort = 1; } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) { @@ -3162,20 +3162,20 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ } // This snippet only needed since function img_edit accepts only one additional parameter: no separate one for css only. - // class/style need to be extracted to avoid duplicate class/style validation errors when $moreatt is added to the end of the attributes. - $reg = array(); + // class/style need to be extracted to avoid duplicate class/style validation errors when $moreatt is added to the end of the attributes. + $reg = array(); if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { - $morecss .= ($morecss ? ' ' : '').$reg[1]; - $moreatt = str_replace('class="'.$reg[1].'"', '', $moreatt); - } - if (preg_match('/style="([^"]+)"/', $moreatt, $reg)) { - $morestyle = ' '.$reg[1]; - $moreatt = str_replace('style="'.$reg[1].'"', '', $moreatt); - } - $moreatt = trim($moreatt); + $morecss .= ($morecss ? ' ' : '').$reg[1]; + $moreatt = str_replace('class="'.$reg[1].'"', '', $moreatt); + } + if (preg_match('/style="([^"]+)"/', $moreatt, $reg)) { + $morestyle = ' '.$reg[1]; + $moreatt = str_replace('style="'.$reg[1].'"', '', $moreatt); + } + $moreatt = trim($moreatt); - $enabledisablehtml = ''; + $enabledisablehtml = ''; if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $enabledisablehtml .= $titlealt; } @@ -3224,7 +3224,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ return $fullpathpicto; } // tag title is used for tooltip on , tag alt can be used with very simple text on image for blind people - return ''.dol_escape_htmltag($alt).''; // Alt is used for accessibility, title for popup + return ''.dol_escape_htmltag($alt).''; // Alt is used for accessibility, title for popup } /** @@ -3832,7 +3832,7 @@ function dol_print_error($db = '', $error = '', $errors = null) $langs->load("main"); } // Load translation files required by the page - $langs->loadLangs(array('main', 'errors')); + $langs->loadLangs(array('main', 'errors')); if ($_SERVER['DOCUMENT_ROOT']) // Mode web { @@ -3868,7 +3868,7 @@ function dol_print_error($db = '', $error = '', $errors = null) if (!empty($conf->modules)) { - $out .= "".$langs->trans("Modules").": ".join(', ', $conf->modules)."
\n"; + $out .= "".$langs->trans("Modules").": ".join(', ', $conf->modules)."
\n"; } if (is_object($db)) @@ -4542,7 +4542,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ $listoflanguagesbefore = array('nl_NL'); if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) { - $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code); + $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code); } else { $tmpcur = $outlangs->getCurrencySymbol($currency_code); $cursymbolafter .= ($tmpcur == $currency_code ? ' '.$tmpcur : $tmpcur); @@ -5368,7 +5368,7 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart) // We will enhance here a common way of forging path for document storage // Here, object->id, object->ref and modulepart are required. //var_dump($modulepart); - if (in_array($modulepart, array('thirdparty', 'contact', 'member', 'propal', 'proposal', 'commande', 'order', 'facture', 'invoice', + if (in_array($modulepart, array('thirdparty', 'contact', 'member', 'propal', 'proposal', 'commande', 'order', 'facture', 'invoice', 'supplier_order', 'supplier_proposal', 'shipment', 'contract', 'expensereport', 'ficheinter'))) { $path = ($object->ref ? $object->ref : $object->id); @@ -5875,18 +5875,18 @@ function dol_textishtml($msg, $option = 0) */ function dol_concatdesc($text1, $text2, $forxml = false, $invert = false) { - if (!empty($invert)) - { - $tmp = $text1; - $text1 = $text2; - $text2 = $tmp; - } + if (!empty($invert)) + { + $tmp = $text1; + $text1 = $text2; + $text2 = $tmp; + } - $ret = ''; - $ret .= (!dol_textishtml($text1) && dol_textishtml($text2)) ? dol_nl2br(dol_escape_htmltag($text1, 0, 1, '', 1), 0, $forxml) : $text1; - $ret .= (!empty($text1) && !empty($text2)) ? ((dol_textishtml($text1) || dol_textishtml($text2)) ? ($forxml ? "
\n" : "
\n") : "\n") : ""; - $ret .= (dol_textishtml($text1) && !dol_textishtml($text2)) ? dol_nl2br(dol_escape_htmltag($text2, 0, 1, '', 1), 0, $forxml) : $text2; - return $ret; + $ret = ''; + $ret .= (!dol_textishtml($text1) && dol_textishtml($text2)) ? dol_nl2br(dol_escape_htmltag($text1, 0, 1, '', 1), 0, $forxml) : $text1; + $ret .= (!empty($text1) && !empty($text2)) ? ((dol_textishtml($text1) || dol_textishtml($text2)) ? ($forxml ? "
\n" : "
\n") : "\n") : ""; + $ret .= (dol_textishtml($text1) && !dol_textishtml($text2)) ? dol_nl2br(dol_escape_htmltag($text2, 0, 1, '', 1), 0, $forxml) : $text2; + return $ret; } @@ -5917,11 +5917,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, ) ); - $substitutionarray = array_merge($substitutionarray, array( + $substitutionarray = array_merge($substitutionarray, array( '__USER_ID__' => (string) $user->id, '__USER_LOGIN__' => (string) $user->login, - '__USER_EMAIL__' => (string) $user->email, - '__USER_LASTNAME__' => (string) $user->lastname, + '__USER_EMAIL__' => (string) $user->email, + '__USER_LASTNAME__' => (string) $user->lastname, '__USER_FIRSTNAME__' => (string) $user->firstname, '__USER_FULLNAME__' => (string) $user->getFullName($outputlangs), '__USER_SUPERVISOR_ID__' => (string) ($user->fk_user ? $user->fk_user : '0'), @@ -5931,7 +5931,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, } if ((empty($exclude) || !in_array('mycompany', $exclude)) && is_object($mysoc)) { - $substitutionarray = array_merge($substitutionarray, array( + $substitutionarray = array_merge($substitutionarray, array( '__MYCOMPANY_NAME__' => $mysoc->name, '__MYCOMPANY_EMAIL__' => $mysoc->email, '__MYCOMPANY_PROFID1__' => $mysoc->idprof1, @@ -5947,8 +5947,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, '__MYCOMPANY_TOWN__' => $mysoc->town, '__MYCOMPANY_COUNTRY__' => $mysoc->country, '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id, - '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code, - '__MYCOMPANY_CURRENCY_CODE__' => $conf->currency + '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code, + '__MYCOMPANY_CURRENCY_CODE__' => $conf->currency )); } @@ -6031,7 +6031,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (!empty($conf->expedition->enabled) && (!is_object($object) || $object->element == 'shipping')) { - $substitutionarray['__SHIPPINGTRACKNUM__'] = 'Shipping tacking number'; + $substitutionarray['__SHIPPINGTRACKNUM__'] = 'Shipping tacking number'; $substitutionarray['__SHIPPINGTRACKNUMURL__'] = 'Shipping tracking url'; } } else { @@ -6286,7 +6286,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $tmp4 = dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $tmp5 = dol_get_next_month($tmp['mon'], $tmp['year']); - $substitutionarray = array_merge($substitutionarray, array( + $substitutionarray = array_merge($substitutionarray, array( '__DAY__' => (string) $tmp['mday'], '__DAY_TEXT__' => $outputlangs->trans('Day'.$tmp['wday']), // Monday '__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'].'Min'), // Mon @@ -6515,11 +6515,11 @@ function dolGetFirstLastname($firstname, $lastname, $nameorder = -1) $ret .= $lastname; } elseif ($nameorder == 2 || $nameorder == 3) { - $ret .= $firstname; - if (empty($ret) && $nameorder == 3) - { - $ret .= $lastname; - } + $ret .= $firstname; + if (empty($ret) && $nameorder == 3) + { + $ret .= $lastname; + } } else { $ret .= $lastname; if ($firstname && $lastname) $ret .= ' '; @@ -6821,12 +6821,12 @@ function dol_sort_array(&$array, $index, $order = 'asc', $natsort = 0, $case_sen } } - if (!$natsort) { - ($order == 'asc') ? asort($temp) : arsort($temp); - } else { - ($case_sensitive) ? natsort($temp) : natcasesort($temp); - if ($order != 'asc') $temp = array_reverse($temp, true); - } + if (!$natsort) { + ($order == 'asc') ? asort($temp) : arsort($temp); + } else { + ($case_sensitive) ? natsort($temp) : natcasesort($temp); + if ($order != 'asc') $temp = array_reverse($temp, true); + } $sorted = array(); @@ -7256,18 +7256,18 @@ function getLanguageCodeFromCountryCode($countrycode) if (function_exists('locale_get_primary_language') && function_exists('locale_get_region')) // Need extension php-intl { - foreach ($locales as $locale) - { - $locale_language = locale_get_primary_language($locale); - $locale_region = locale_get_region($locale); - if (strtoupper($countrycode) == $locale_region) - { - //var_dump($locale.'-'.$locale_language.'-'.$locale_region); - return strtolower($locale_language).'_'.strtoupper($locale_region); - } - } + foreach ($locales as $locale) + { + $locale_language = locale_get_primary_language($locale); + $locale_region = locale_get_region($locale); + if (strtoupper($countrycode) == $locale_region) + { + //var_dump($locale.'-'.$locale_language.'-'.$locale_region); + return strtolower($locale_language).'_'.strtoupper($locale_region); + } + } } else { - dol_syslog("Warning Exention php-intl is not available", LOG_WARNING); + dol_syslog("Warning Exention php-intl is not available", LOG_WARNING); } return null; @@ -7377,7 +7377,7 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, if ($reshook > 0) { $head = $hookmanager->resArray; - $h = count($head); + $h = count($head); } } } @@ -7560,15 +7560,15 @@ function printCommonFooter($zone = 'private') // Add Xdebug coverage of code if (defined('XDEBUGCOVERAGE')) { - print_r(xdebug_get_code_coverage()); + print_r(xdebug_get_code_coverage()); } // Add DebugBar data - if (!empty($user->rights->debugbar->read) && is_object($debugbar)) - { - $debugbar['time']->stopMeasure('pageaftermaster'); - print ''."\n"; - print $debugbar->getRenderer()->render(); + if (!empty($user->rights->debugbar->read) && is_object($debugbar)) + { + $debugbar['time']->stopMeasure('pageaftermaster'); + print ''."\n"; + print $debugbar->getRenderer()->render(); } elseif (count($conf->logbuffer)) // If there is some logs in buffer to show { print "\n"; @@ -7736,30 +7736,30 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) if ($mode == -3) $newres .= ' OR '.$field.' IS NULL'; } elseif ($mode == 4) { - $tmparray = explode(',', trim($crit)); - if (count($tmparray)) - { - $listofcodes = ''; - foreach ($tmparray as $val) - { - if ($val) - { - $newres .= ($i2 > 0 ? ' OR (' : '(').$field.' LIKE \''.$db->escape(trim($val)).',%\''; - $newres .= ' OR '.$field.' = \''.$db->escape(trim($val)).'\''; - $newres .= ' OR '.$field.' LIKE \'%,'.$db->escape(trim($val)).'\''; - $newres .= ' OR '.$field.' LIKE \'%,'.$db->escape(trim($val)).',%\''; - $newres .= ')'; - $i2++; - } - } - } + $tmparray = explode(',', trim($crit)); + if (count($tmparray)) + { + $listofcodes = ''; + foreach ($tmparray as $val) + { + if ($val) + { + $newres .= ($i2 > 0 ? ' OR (' : '(').$field.' LIKE \''.$db->escape(trim($val)).',%\''; + $newres .= ' OR '.$field.' = \''.$db->escape(trim($val)).'\''; + $newres .= ' OR '.$field.' LIKE \'%,'.$db->escape(trim($val)).'\''; + $newres .= ' OR '.$field.' LIKE \'%,'.$db->escape(trim($val)).',%\''; + $newres .= ')'; + $i2++; + } + } + } } else // $mode=0 { $tmpcrits = explode('|', $crit); $i3 = 0; foreach ($tmpcrits as $tmpcrit) { - if ($tmpcrit !== '0' && empty($tmpcrit)) continue; + if ($tmpcrit !== '0' && empty($tmpcrit)) continue; $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); @@ -7937,19 +7937,19 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) if (preg_match('/\.tsv$/i', $tmpfile)) { $mime = 'text/tab-separated-values'; $imgmime = 'text.png'; $famime = 'file-text-o'; } if (preg_match('/\.(cf|conf|log)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $famime = 'file-text-o'; } if (preg_match('/\.ini$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'ini'; $famime = 'file-text-o'; } - if (preg_match('/\.md$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'md'; $famime = 'file-text-o'; } + if (preg_match('/\.md$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'md'; $famime = 'file-text-o'; } if (preg_match('/\.css$/i', $tmpfile)) { $mime = 'text/css'; $imgmime = 'css.png'; $srclang = 'css'; $famime = 'file-text-o'; } // Certificate files if (preg_match('/\.(crt|cer|key|pub)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $famime = 'file-text-o'; } // XML based (HTML/XML/XAML) if (preg_match('/\.(html|htm|shtml)$/i', $tmpfile)) { $mime = 'text/html'; $imgmime = 'html.png'; $srclang = 'html'; $famime = 'file-text-o'; } if (preg_match('/\.(xml|xhtml)$/i', $tmpfile)) { $mime = 'text/xml'; $imgmime = 'other.png'; $srclang = 'xml'; $famime = 'file-text-o'; } - if (preg_match('/\.xaml$/i', $tmpfile)) { $mime = 'text/xml'; $imgmime = 'other.png'; $srclang = 'xaml'; $famime = 'file-text-o'; } + if (preg_match('/\.xaml$/i', $tmpfile)) { $mime = 'text/xml'; $imgmime = 'other.png'; $srclang = 'xaml'; $famime = 'file-text-o'; } // Languages if (preg_match('/\.bas$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'bas'; $famime = 'file-code-o'; } if (preg_match('/\.(c)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'c'; $famime = 'file-code-o'; } if (preg_match('/\.(cpp)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'cpp'; $famime = 'file-code-o'; } - if (preg_match('/\.cs$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'cs'; $famime = 'file-code-o'; } + if (preg_match('/\.cs$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'cs'; $famime = 'file-code-o'; } if (preg_match('/\.(h)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'h'; $famime = 'file-code-o'; } if (preg_match('/\.(java|jsp)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'java'; $famime = 'file-code-o'; } if (preg_match('/\.php([0-9]{1})?$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'php.png'; $srclang = 'php'; $famime = 'file-code-o'; } @@ -8079,7 +8079,7 @@ function getDictvalue($tablename, $field, $id, $checkentity = false, $rowidfield */ function colorIsLight($stringcolor) { - $stringcolor = str_replace('#', '', $stringcolor); + $stringcolor = str_replace('#', '', $stringcolor); $res = -1; if (!empty($stringcolor)) { @@ -8162,28 +8162,28 @@ function roundUpToNextMultiple($n, $x = 5) */ function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '', $params = array()) { - $attr = array( - 'class'=>'badge '.(!empty($mode) ? ' badge-'.$mode : '').(!empty($type) ? ' badge-'.$type : '').(empty($params['css']) ? '' : ' '.$params['css']) - ); + $attr = array( + 'class'=>'badge '.(!empty($mode) ? ' badge-'.$mode : '').(!empty($type) ? ' badge-'.$type : '').(empty($params['css']) ? '' : ' '.$params['css']) + ); - if (empty($html)) { - $html = $label; - } + if (empty($html)) { + $html = $label; + } - if (!empty($url)) { - $attr['href'] = $url; - } + if (!empty($url)) { + $attr['href'] = $url; + } - if ($mode === 'dot') { - $attr['class'] .= ' classfortooltip'; - $attr['title'] = $html; - $attr['aria-label'] = $label; - $html = ''; - } + if ($mode === 'dot') { + $attr['class'] .= ' classfortooltip'; + $attr['title'] = $html; + $attr['aria-label'] = $label; + $html = ''; + } - // Override attr - if (!empty($params['attr']) && is_array($params['attr'])) { - foreach ($params['attr']as $key => $value) { + // Override attr + if (!empty($params['attr']) && is_array($params['attr'])) { + foreach ($params['attr']as $key => $value) { if ($key == 'class') { $attr['class'] .= ' '.$value; } elseif ($key == 'classOverride') { @@ -8191,24 +8191,24 @@ function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = ' } else { $attr[$key] = $value; } - } - } + } + } - // TODO: add hook + // TODO: add hook - // escape all attribute - $attr = array_map('dol_escape_htmltag', $attr); + // escape all attribute + $attr = array_map('dol_escape_htmltag', $attr); - $TCompiledAttr = array(); - foreach ($attr as $key => $value) { - $TCompiledAttr[] = $key.'="'.$value.'"'; - } + $TCompiledAttr = array(); + foreach ($attr as $key => $value) { + $TCompiledAttr[] = $key.'="'.$value.'"'; + } - $compiledAttributes = !empty($TCompiledAttr) ?implode(' ', $TCompiledAttr) : ''; + $compiledAttributes = !empty($TCompiledAttr) ?implode(' ', $TCompiledAttr) : ''; - $tag = !empty($url) ? 'a' : 'span'; + $tag = !empty($url) ? 'a' : 'span'; - return '<'.$tag.' '.$compiledAttributes.'>'.$html.''; + return '<'.$tag.' '.$compiledAttributes.'>'.$html.''; } @@ -8226,82 +8226,82 @@ function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = ' */ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $statusType = 'status0', $displayMode = 0, $url = '', $params = array()) { - global $conf; + global $conf; - $return = ''; - $dolGetBadgeParams = array(); + $return = ''; + $dolGetBadgeParams = array(); - if (!empty($params['badgeParams'])) { - $dolGetBadgeParams = $params['badgeParams']; - } + if (!empty($params['badgeParams'])) { + $dolGetBadgeParams = $params['badgeParams']; + } - // TODO : add a hook - if ($displayMode == 0) { - $return = !empty($html) ? $html : (empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)); - } elseif ($displayMode == 1) { - $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort); - } // Use status with images (for backward compatibility) - elseif (!empty($conf->global->MAIN_STATUS_USES_IMAGES)) { - $return = ''; - $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ? '' : '').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ? '' : ''); - $htmlLabelShort = (in_array($displayMode, array(1, 2, 5)) ? '' : '').(!empty($html) ? $html : (!empty($statusLabelShort) ? $statusLabelShort : $statusLabel)).(in_array($displayMode, array(1, 2, 5)) ? '' : ''); + // TODO : add a hook + if ($displayMode == 0) { + $return = !empty($html) ? $html : (empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)); + } elseif ($displayMode == 1) { + $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort); + } // Use status with images (for backward compatibility) + elseif (!empty($conf->global->MAIN_STATUS_USES_IMAGES)) { + $return = ''; + $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ? '' : '').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ? '' : ''); + $htmlLabelShort = (in_array($displayMode, array(1, 2, 5)) ? '' : '').(!empty($html) ? $html : (!empty($statusLabelShort) ? $statusLabelShort : $statusLabel)).(in_array($displayMode, array(1, 2, 5)) ? '' : ''); - // For small screen, we always use the short label instead of long label. - if (!empty($conf->dol_optimize_smallscreen)) - { - if ($displayMode == 0) $displayMode = 1; - elseif ($displayMode == 4) $displayMode = 2; - elseif ($displayMode == 6) $displayMode = 5; - } + // For small screen, we always use the short label instead of long label. + if (!empty($conf->dol_optimize_smallscreen)) + { + if ($displayMode == 0) $displayMode = 1; + elseif ($displayMode == 4) $displayMode = 2; + elseif ($displayMode == 6) $displayMode = 5; + } - // For backward compatibility. Image's filename are still in French, so we use this array to convert - $statusImg = array( - 'status0' => 'statut0', - 'status1' => 'statut1', - 'status2' => 'statut2', - 'status3' => 'statut3', - 'status4' => 'statut4', - 'status5' => 'statut5', - 'status6' => 'statut6', - 'status7' => 'statut7', - 'status8' => 'statut8', - 'status9' => 'statut9' - ); + // For backward compatibility. Image's filename are still in French, so we use this array to convert + $statusImg = array( + 'status0' => 'statut0', + 'status1' => 'statut1', + 'status2' => 'statut2', + 'status3' => 'statut3', + 'status4' => 'statut4', + 'status5' => 'statut5', + 'status6' => 'statut6', + 'status7' => 'statut7', + 'status8' => 'statut8', + 'status9' => 'statut9' + ); - if (!empty($statusImg[$statusType])) { - $htmlImg = img_picto($statusLabel, $statusImg[$statusType]); - } else { - $htmlImg = img_picto($statusLabel, $statusType); - } + if (!empty($statusImg[$statusType])) { + $htmlImg = img_picto($statusLabel, $statusImg[$statusType]); + } else { + $htmlImg = img_picto($statusLabel, $statusType); + } - if ($displayMode === 2) { - $return = $htmlImg.' '.$htmlLabelShort; - } elseif ($displayMode === 3) { - $return = $htmlImg; - } elseif ($displayMode === 4) { - $return = $htmlImg.' '.$htmlLabel; - } elseif ($displayMode === 5) { - $return = $htmlLabelShort.' '.$htmlImg; - } else { // $displayMode >= 6 - $return = $htmlLabel.' '.$htmlImg; - } - } // Use new badge - elseif (empty($conf->global->MAIN_STATUS_USES_IMAGES) && !empty($displayMode)) { - $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort); + if ($displayMode === 2) { + $return = $htmlImg.' '.$htmlLabelShort; + } elseif ($displayMode === 3) { + $return = $htmlImg; + } elseif ($displayMode === 4) { + $return = $htmlImg.' '.$htmlLabel; + } elseif ($displayMode === 5) { + $return = $htmlLabelShort.' '.$htmlImg; + } else { // $displayMode >= 6 + $return = $htmlLabel.' '.$htmlImg; + } + } // Use new badge + elseif (empty($conf->global->MAIN_STATUS_USES_IMAGES) && !empty($displayMode)) { + $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort); $dolGetBadgeParams['attr']['class'] = 'badge-status'; $dolGetBadgeParams['attr']['title'] = $statusLabel; - if ($displayMode == 3) { - $return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), '', $statusType, 'dot', $url, $dolGetBadgeParams); - } elseif ($displayMode === 5) { - $return = dolGetBadge($statusLabelShort, $html, $statusType, '', $url, $dolGetBadgeParams); - } else { - $return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), $html, $statusType, '', $url, $dolGetBadgeParams); - } - } + if ($displayMode == 3) { + $return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), '', $statusType, 'dot', $url, $dolGetBadgeParams); + } elseif ($displayMode === 5) { + $return = dolGetBadge($statusLabelShort, $html, $statusType, '', $url, $dolGetBadgeParams); + } else { + $return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), $html, $statusType, '', $url, $dolGetBadgeParams); + } + } - return $return; + return $return; } @@ -8319,63 +8319,63 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st */ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = '', $id = '', $userRight = 1, $params = array()) { - $class = 'butAction'; - if ($actionType == 'danger' || $actionType == 'delete') { - $class = 'butActionDelete'; - } + $class = 'butAction'; + if ($actionType == 'danger' || $actionType == 'delete') { + $class = 'butActionDelete'; + } - $attr = array( - 'class' => $class - ,'href' => empty($url) ? '' : $url - ); + $attr = array( + 'class' => $class + ,'href' => empty($url) ? '' : $url + ); - if (empty($html)) { - $html = $label; - } else { - $attr['aria-label'] = $label; - } + if (empty($html)) { + $html = $label; + } else { + $attr['aria-label'] = $label; + } - if (empty($userRight)) { - $attr['class'] = 'butActionRefused'; - $attr['href'] = ''; - } + if (empty($userRight)) { + $attr['class'] = 'butActionRefused'; + $attr['href'] = ''; + } - if (!empty($id)) { - $attr['id'] = $id; - } + if (!empty($id)) { + $attr['id'] = $id; + } - // Override attr - if (!empty($params['attr']) && is_array($params['attr'])) { - foreach ($params['attr'] as $key => $value) { - if ($key == 'class') { - $attr['class'] .= ' '.$value; - } elseif ($key == 'classOverride') { - $attr['class'] = $value; - } else { - $attr[$key] = $value; - } - } - } + // Override attr + if (!empty($params['attr']) && is_array($params['attr'])) { + foreach ($params['attr'] as $key => $value) { + if ($key == 'class') { + $attr['class'] .= ' '.$value; + } elseif ($key == 'classOverride') { + $attr['class'] = $value; + } else { + $attr[$key] = $value; + } + } + } - if (isset($attr['href']) && empty($attr['href'])) { - unset($attr['href']); - } + if (isset($attr['href']) && empty($attr['href'])) { + unset($attr['href']); + } - // TODO : add a hook + // TODO : add a hook - // escape all attribute - $attr = array_map('dol_escape_htmltag', $attr); + // escape all attribute + $attr = array_map('dol_escape_htmltag', $attr); - $TCompiledAttr = array(); - foreach ($attr as $key => $value) { - $TCompiledAttr[] = $key.'="'.$value.'"'; - } + $TCompiledAttr = array(); + foreach ($attr as $key => $value) { + $TCompiledAttr[] = $key.'="'.$value.'"'; + } - $compiledAttributes = !empty($TCompiledAttr) ?implode(' ', $TCompiledAttr) : ''; + $compiledAttributes = !empty($TCompiledAttr) ?implode(' ', $TCompiledAttr) : ''; - $tag = !empty($attr['href']) ? 'a' : 'span'; + $tag = !empty($attr['href']) ? 'a' : 'span'; - return '
<'.$tag.' '.$compiledAttributes.'>'.$html.'
'; + return '
<'.$tag.' '.$compiledAttributes.'>'.$html.'
'; } /** @@ -8392,85 +8392,85 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = */ function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $url = '', $id = '', $status = 1, $params = array()) { - global $langs, $conf, $user; + global $langs, $conf, $user; - // Actually this conf is used in css too for external module compatibility and smooth transition to this function - if (!empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (!$user->admin) && $status <= 0) { - return ''; - } + // Actually this conf is used in css too for external module compatibility and smooth transition to this function + if (!empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (!$user->admin) && $status <= 0) { + return ''; + } - $class = 'btnTitle'; - if ($iconClass == 'fa fa-plus-circle') $class .= ' btnTitlePlus'; + $class = 'btnTitle'; + if ($iconClass == 'fa fa-plus-circle') $class .= ' btnTitlePlus'; - if (!empty($params['morecss'])) $class .= ' '.$params['morecss']; + if (!empty($params['morecss'])) $class .= ' '.$params['morecss']; - $attr = array( - 'class' => $class - ,'href' => empty($url) ? '' : $url - ); + $attr = array( + 'class' => $class + ,'href' => empty($url) ? '' : $url + ); - if (!empty($helpText)) { - $attr['title'] = dol_escape_htmltag($helpText); - } + if (!empty($helpText)) { + $attr['title'] = dol_escape_htmltag($helpText); + } - if ($status <= 0) { - $attr['class'] .= ' refused'; + if ($status <= 0) { + $attr['class'] .= ' refused'; - $attr['href'] = ''; + $attr['href'] = ''; - if ($status == -1) { // disable - $attr['title'] = dol_escape_htmltag($langs->transnoentitiesnoconv("FeatureDisabled")); - } elseif ($status == 0) { // Not enough permissions - $attr['title'] = dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")); - } - } + if ($status == -1) { // disable + $attr['title'] = dol_escape_htmltag($langs->transnoentitiesnoconv("FeatureDisabled")); + } elseif ($status == 0) { // Not enough permissions + $attr['title'] = dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")); + } + } - if (!empty($attr['title'])) { - $attr['class'] .= ' classfortooltip'; - } + if (!empty($attr['title'])) { + $attr['class'] .= ' classfortooltip'; + } - if (!empty($id)) { - $attr['id'] = $id; - } + if (!empty($id)) { + $attr['id'] = $id; + } - // Override attr - if (!empty($params['attr']) && is_array($params['attr'])) { - foreach ($params['attr'] as $key => $value) { - if ($key == 'class') { - $attr['class'] .= ' '.$value; - } elseif ($key == 'classOverride') { - $attr['class'] = $value; - } else { - $attr[$key] = $value; - } - } - } + // Override attr + if (!empty($params['attr']) && is_array($params['attr'])) { + foreach ($params['attr'] as $key => $value) { + if ($key == 'class') { + $attr['class'] .= ' '.$value; + } elseif ($key == 'classOverride') { + $attr['class'] = $value; + } else { + $attr[$key] = $value; + } + } + } - if (isset($attr['href']) && empty($attr['href'])) { - unset($attr['href']); - } + if (isset($attr['href']) && empty($attr['href'])) { + unset($attr['href']); + } - // TODO : add a hook + // TODO : add a hook - // escape all attribute - $attr = array_map('dol_escape_htmltag', $attr); + // escape all attribute + $attr = array_map('dol_escape_htmltag', $attr); - $TCompiledAttr = array(); - foreach ($attr as $key => $value) { - $TCompiledAttr[] = $key.'="'.$value.'"'; - } + $TCompiledAttr = array(); + foreach ($attr as $key => $value) { + $TCompiledAttr[] = $key.'="'.$value.'"'; + } - $compiledAttributes = (empty($TCompiledAttr) ? '' : implode(' ', $TCompiledAttr)); + $compiledAttributes = (empty($TCompiledAttr) ? '' : implode(' ', $TCompiledAttr)); - $tag = (empty($attr['href']) ? 'span' : 'a'); + $tag = (empty($attr['href']) ? 'span' : 'a'); - $button = ''; - $button .= '<'.$tag.' '.$compiledAttributes.' >'; - $button .= ''; - $button .= ''.$label.''; - $button .= ''; + $button = ''; + $button .= '<'.$tag.' '.$compiledAttributes.' >'; + $button .= ''; + $button .= ''.$label.''; + $button .= ''; - return $button; + return $button; } /** @@ -8635,12 +8635,12 @@ function fetchObjectByElement($element_id, $element_type, $element_ref = '') */ function isAFileWithExecutableContent($filename) { - if (preg_match('/\.(htm|html|js|phar|php|php\d+|phtml|pht|pl|py|cgi|ksh|sh|shtml|bash|bat|cmd|wpk|exe|dmg)$/i', $filename)) - { - return true; - } + if (preg_match('/\.(htm|html|js|phar|php|php\d+|phtml|pht|pl|py|cgi|ksh|sh|shtml|bash|bat|cmd|wpk|exe|dmg)$/i', $filename)) + { + return true; + } - return false; + return false; } /** diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 787a5471b18..ddeb4df4dea 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -39,34 +39,34 @@ */ function jsUnEscape($source) { - $decodedStr = ""; - $pos = 0; - $len = strlen($source); - while ($pos < $len) { - $charAt = substr($source, $pos, 1); - if ($charAt == '%') { - $pos++; - $charAt = substr($source, $pos, 1); - if ($charAt == 'u') { - // we got a unicode character - $pos++; - $unicodeHexVal = substr($source, $pos, 4); - $unicode = hexdec($unicodeHexVal); - $entity = "&#".$unicode.';'; - $decodedStr .= utf8_encode($entity); - $pos += 4; - } else { - // we have an escaped ascii character - $hexVal = substr($source, $pos, 2); - $decodedStr .= chr(hexdec($hexVal)); - $pos += 2; - } - } else { - $decodedStr .= $charAt; - $pos++; - } - } - return dol_html_entity_decode($decodedStr, ENT_COMPAT); + $decodedStr = ""; + $pos = 0; + $len = strlen($source); + while ($pos < $len) { + $charAt = substr($source, $pos, 1); + if ($charAt == '%') { + $pos++; + $charAt = substr($source, $pos, 1); + if ($charAt == 'u') { + // we got a unicode character + $pos++; + $unicodeHexVal = substr($source, $pos, 4); + $unicode = hexdec($unicodeHexVal); + $entity = "&#".$unicode.';'; + $decodedStr .= utf8_encode($entity); + $pos += 4; + } else { + // we have an escaped ascii character + $hexVal = substr($source, $pos, 2); + $decodedStr .= chr(hexdec($hexVal)); + $pos += 2; + } + } else { + $decodedStr .= $charAt; + $pos++; + } + } + return dol_html_entity_decode($decodedStr, ENT_COMPAT); } @@ -79,37 +79,37 @@ function jsUnEscape($source) */ function dolGetModulesDirs($subdir = '') { - global $conf; + global $conf; - $modulesdir = array(); + $modulesdir = array(); - foreach ($conf->file->dol_document_root as $type => $dirroot) - { - // Default core/modules dir - if ($type === 'main') { - $modulesdir[$dirroot.'/core/modules'.$subdir.'/'] = $dirroot.'/core/modules'.$subdir.'/'; - } + foreach ($conf->file->dol_document_root as $type => $dirroot) + { + // Default core/modules dir + if ($type === 'main') { + $modulesdir[$dirroot.'/core/modules'.$subdir.'/'] = $dirroot.'/core/modules'.$subdir.'/'; + } - // Scan dir from external modules - $handle = @opendir($dirroot); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/disabled/', $file)) continue; // We discard module if it contains disabled into name. + // Scan dir from external modules + $handle = @opendir($dirroot); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/disabled/', $file)) continue; // We discard module if it contains disabled into name. - if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') - { - if (is_dir($dirroot.'/'.$file.'/core/modules'.$subdir.'/')) - { - $modulesdir[$dirroot.'/'.$file.'/core/modules'.$subdir.'/'] = $dirroot.'/'.$file.'/core/modules'.$subdir.'/'; - } - } - } - closedir($handle); - } - } - return $modulesdir; + if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') + { + if (is_dir($dirroot.'/'.$file.'/core/modules'.$subdir.'/')) + { + $modulesdir[$dirroot.'/'.$file.'/core/modules'.$subdir.'/'] = $dirroot.'/'.$file.'/core/modules'.$subdir.'/'; + } + } + } + closedir($handle); + } + } + return $modulesdir; } @@ -121,16 +121,16 @@ function dolGetModulesDirs($subdir = '') */ function dol_getDefaultFormat(Translate $outputlangs = null) { - global $langs; + global $langs; - $selected = 'EUA4'; - if (!$outputlangs) { - $outputlangs = $langs; - } + $selected = 'EUA4'; + if (!$outputlangs) { + $outputlangs = $langs; + } - if ($outputlangs->defaultlang == 'ca_CA') $selected = 'CAP4'; // Canada - if ($outputlangs->defaultlang == 'en_US') $selected = 'USLetter'; // US - return $selected; + if ($outputlangs->defaultlang == 'ca_CA') $selected = 'CAP4'; // Canada + if ($outputlangs->defaultlang == 'en_US') $selected = 'USLetter'; // US + return $selected; } /** @@ -143,42 +143,42 @@ function dol_getDefaultFormat(Translate $outputlangs = null) */ function dol_print_file($langs, $filename, $searchalt = 0) { - global $conf; + global $conf; - // Test if file is in lang directory - foreach ($langs->dir as $searchdir) - { - $formfile = ($searchdir."/langs/".$langs->defaultlang."/".$filename); - dol_syslog('functions2::dol_print_file search file '.$formfile, LOG_DEBUG); - if (is_readable($formfile)) - { - $content = file_get_contents($formfile); - $isutf8 = utf8_check($content); - if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content); - else print $content; - return true; - } else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); + // Test if file is in lang directory + foreach ($langs->dir as $searchdir) + { + $formfile = ($searchdir."/langs/".$langs->defaultlang."/".$filename); + dol_syslog('functions2::dol_print_file search file '.$formfile, LOG_DEBUG); + if (is_readable($formfile)) + { + $content = file_get_contents($formfile); + $isutf8 = utf8_check($content); + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content); + else print $content; + return true; + } else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); - if ($searchalt) { - // Test si fichier dans repertoire de la langue alternative - if ($langs->defaultlang != "en_US") $formfilealt = $searchdir."/langs/en_US/".$filename; - else $formfilealt = $searchdir."/langs/fr_FR/".$filename; - dol_syslog('functions2::dol_print_file search alt file '.$formfilealt, LOG_DEBUG); - //print 'getcwd='.getcwd().' htmlfilealt='.$formfilealt.' X '.file_exists(getcwd().'/'.$formfilealt); - if (is_readable($formfilealt)) - { - $content = file_get_contents($formfilealt); - $isutf8 = utf8_check($content); - if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content); - else print $content; - return true; - } else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); - } - } + if ($searchalt) { + // Test si fichier dans repertoire de la langue alternative + if ($langs->defaultlang != "en_US") $formfilealt = $searchdir."/langs/en_US/".$filename; + else $formfilealt = $searchdir."/langs/fr_FR/".$filename; + dol_syslog('functions2::dol_print_file search alt file '.$formfilealt, LOG_DEBUG); + //print 'getcwd='.getcwd().' htmlfilealt='.$formfilealt.' X '.file_exists(getcwd().'/'.$formfilealt); + if (is_readable($formfilealt)) + { + $content = file_get_contents($formfilealt); + $isutf8 = utf8_check($content); + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content); + else print $content; + return true; + } else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); + } + } - return false; + return false; } /** @@ -191,279 +191,279 @@ function dol_print_file($langs, $filename, $searchalt = 0) */ function dol_print_object_info($object, $usetable = 0) { - global $langs, $db; + global $langs, $db; - // Load translation files required by the page - $langs->loadLangs(array('other', 'admin')); + // Load translation files required by the page + $langs->loadLangs(array('other', 'admin')); - include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - $deltadateforserver = getServerTimeZoneInt('now'); - $deltadateforclient = ((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); - //$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); - $deltadateforuser = round($deltadateforclient - $deltadateforserver); - //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser; + $deltadateforserver = getServerTimeZoneInt('now'); + $deltadateforclient = ((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); + //$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); + $deltadateforuser = round($deltadateforclient - $deltadateforserver); + //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser; - if ($usetable) print ''; + if ($usetable) print '
'; - // Import key - if (!empty($object->import_key)) - { - if ($usetable) print ''; - else print '
'; - } + // Import key + if (!empty($object->import_key)) + { + if ($usetable) print ''; + else print '
'; + } - // User creation (old method using already loaded object and not id is kept for backward compatibility) - if (!empty($object->user_creation) || !empty($object->user_creation_id)) - { - if ($usetable) print ''; - else print '
'; - } - - // Date creation - if (!empty($object->date_creation)) - { - if ($usetable) print ''; - else print '
'; - } - - // User change (old method using already loaded object and not id is kept for backward compatibility) - if (!empty($object->user_modification) || !empty($object->user_modification_id)) - { - if ($usetable) print ''; - else print '
'; - } - - // Date change - if (!empty($object->date_modification)) - { - if ($usetable) print ''; - else print '
'; - } - - // User validation (old method using already loaded object and not id is kept for backward compatibility) - if (!empty($object->user_validation) || !empty($object->user_validation_id)) - { - if ($usetable) print ''; - else print '
'; - } + else print $langs->trans("Unknown"); + } + if ($usetable) print ''; + else print '
'; + } - // Date validation - if (!empty($object->date_validation)) - { - if ($usetable) print ''; - else print '
'; - } + // Date creation + if (!empty($object->date_creation)) + { + if ($usetable) print ''; + else print '
'; + } - // User approve (old method using already loaded object and not id is kept for backward compatibility) - if (!empty($object->user_approve) || !empty($object->user_approve_id)) - { - if ($usetable) print ''; - else print '
'; - } + else print $langs->trans("Unknown"); + } + if ($usetable) print ''; + else print '
'; + } - // Date approve - if (!empty($object->date_approve)) - { - if ($usetable) print ''; - else print '
'; - } + // Date change + if (!empty($object->date_modification)) + { + if ($usetable) print ''; + else print '
'; + } - // User approve - if (!empty($object->user_approve_id2)) - { - if ($usetable) print ''; - else print '
'; - } + // User validation (old method using already loaded object and not id is kept for backward compatibility) + if (!empty($object->user_validation) || !empty($object->user_validation_id)) + { + if ($usetable) print ''; + else print '
'; + } - // Date approve - if (!empty($object->date_approve2)) - { - if ($usetable) print ''; - else print '
'; - } + // Date validation + if (!empty($object->date_validation)) + { + if ($usetable) print ''; + else print '
'; + } - // User close - if (!empty($object->user_cloture)) - { - if ($usetable) print ''; + else print '
'; + } + + // Date approve + if (!empty($object->date_approve)) + { + if ($usetable) print ''; + else print '
'; + } + + // User approve + if (!empty($object->user_approve_id2)) + { + if ($usetable) print ''; + else print '
'; + } + + // Date approve + if (!empty($object->date_approve2)) + { + if ($usetable) print ''; + else print '
'; + } + + // User close + if (!empty($object->user_cloture)) + { + if ($usetable) print ''; - else print '
'; - } + else print $langs->trans("Unknown"); + } + if ($usetable) print ''; + else print '
'; + } - // Date close - if (!empty($object->date_cloture)) - { - if ($usetable) print ''; - else print '
'; - } + // Date close + if (!empty($object->date_cloture)) + { + if ($usetable) print ''; + else print '
'; + } - // User conciliate - if (!empty($object->user_rappro)) - { - if ($usetable) print ''; - else print '
'; - } + else print $langs->trans("Unknown"); + } + if ($usetable) print ''; + else print '
'; + } - // Date conciliate - if (!empty($object->date_rappro)) - { - if ($usetable) print ''; - else print '
'; - } + // Date conciliate + if (!empty($object->date_rappro)) + { + if ($usetable) print ''; + else print '
'; + } - // Date send - if (!empty($object->date_envoi)) - { - if ($usetable) print ''; - else print '
'; - } + // Date send + if (!empty($object->date_envoi)) + { + if ($usetable) print ''; + else print '
'; + } - if ($usetable) print '
'; - print $langs->trans("ImportedWithSet"); - if ($usetable) print ''; - else print ': '; - print $object->import_key; - if ($usetable) print '
'; + print $langs->trans("ImportedWithSet"); + if ($usetable) print ''; + else print ': '; + print $object->import_key; + if ($usetable) print '
'; - print $langs->trans("CreatedBy"); - if ($usetable) print ''; - else print ': '; - if (is_object($object->user_creation)) - { - if ($object->user_creation->id) print $object->user_creation->getNomUrl(1, '', 0, 0, 0); - else print $langs->trans("Unknown"); - } else { - $userstatic = new User($db); - $userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation); - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); - else print $langs->trans("Unknown"); - } - if ($usetable) print '
'; - print $langs->trans("DateCreation"); - if ($usetable) print ''; - else print ': '; - print dol_print_date($object->date_creation, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_creation + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); - if ($usetable) print '
'; - print $langs->trans("ModifiedBy"); - if ($usetable) print ''; - else print ': '; - if (is_object($object->user_modification)) - { - if ($object->user_modification->id) print $object->user_modification->getNomUrl(1, '', 0, 0, 0); - else print $langs->trans("Unknown"); - } else { - $userstatic = new User($db); - $userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification); - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); - else print $langs->trans("Unknown"); - } - if ($usetable) print '
'; - print $langs->trans("DateLastModification"); - if ($usetable) print ''; - else print ': '; - print dol_print_date($object->date_modification, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_modification + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); - if ($usetable) print '
'; - print $langs->trans("ValidatedBy"); - if ($usetable) print ''; - else print ': '; - if (is_object($object->user_validation)) - { - if ($object->user_validation->id) print $object->user_validation->getNomUrl(1, '', 0, 0, 0); - else print $langs->trans("Unknown"); - } else { - $userstatic = new User($db); - $userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation); + // User creation (old method using already loaded object and not id is kept for backward compatibility) + if (!empty($object->user_creation) || !empty($object->user_creation_id)) + { + if ($usetable) print '
'; + print $langs->trans("CreatedBy"); + if ($usetable) print ''; + else print ': '; + if (is_object($object->user_creation)) + { + if ($object->user_creation->id) print $object->user_creation->getNomUrl(1, '', 0, 0, 0); + else print $langs->trans("Unknown"); + } else { + $userstatic = new User($db); + $userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); - else print $langs->trans("Unknown"); - } - if ($usetable) print '
'; - print $langs->trans("DateValidation"); - if ($usetable) print ''; - else print ': '; - print dol_print_date($object->date_validation, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_validation + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); - if ($usetable) print '
'; + print $langs->trans("DateCreation"); + if ($usetable) print ''; + else print ': '; + print dol_print_date($object->date_creation, 'dayhour'); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_creation + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($usetable) print '
'; - print $langs->trans("ApprovedBy"); - if ($usetable) print ''; - else print ': '; - if (is_object($object->user_approve)) - { - if ($object->user_approve->id) print $object->user_approve->getNomUrl(1, '', 0, 0, 0); - else print $langs->trans("Unknown"); - } else { - $userstatic = new User($db); - $userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve); + // User change (old method using already loaded object and not id is kept for backward compatibility) + if (!empty($object->user_modification) || !empty($object->user_modification_id)) + { + if ($usetable) print '
'; + print $langs->trans("ModifiedBy"); + if ($usetable) print ''; + else print ': '; + if (is_object($object->user_modification)) + { + if ($object->user_modification->id) print $object->user_modification->getNomUrl(1, '', 0, 0, 0); + else print $langs->trans("Unknown"); + } else { + $userstatic = new User($db); + $userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); - else print $langs->trans("Unknown"); - } - if ($usetable) print '
'; - print $langs->trans("DateApprove"); - if ($usetable) print ''; - else print ': '; - print dol_print_date($object->date_approve, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_approve + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); - if ($usetable) print '
'; + print $langs->trans("DateLastModification"); + if ($usetable) print ''; + else print ': '; + print dol_print_date($object->date_modification, 'dayhour'); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_modification + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($usetable) print '
'; - print $langs->trans("ApprovedBy"); - if ($usetable) print ''; - else print ': '; - $userstatic = new User($db); - $userstatic->fetch($object->user_approve_id2); - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); - else print $langs->trans("Unknown"); - if ($usetable) print '
'; + print $langs->trans("ValidatedBy"); + if ($usetable) print ''; + else print ': '; + if (is_object($object->user_validation)) + { + if ($object->user_validation->id) print $object->user_validation->getNomUrl(1, '', 0, 0, 0); + else print $langs->trans("Unknown"); + } else { + $userstatic = new User($db); + $userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation); + if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); + else print $langs->trans("Unknown"); + } + if ($usetable) print '
'; - print $langs->trans("DateApprove2"); - if ($usetable) print ''; - else print ': '; - print dol_print_date($object->date_approve2, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_approve2 + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); - if ($usetable) print '
'; + print $langs->trans("DateValidation"); + if ($usetable) print ''; + else print ': '; + print dol_print_date($object->date_validation, 'dayhour'); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_validation + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($usetable) print '
'; - print $langs->trans("ClosedBy"); - if ($usetable) print ''; - else print ': '; - if (is_object($object->user_cloture)) - { + // User approve (old method using already loaded object and not id is kept for backward compatibility) + if (!empty($object->user_approve) || !empty($object->user_approve_id)) + { + if ($usetable) print '
'; + print $langs->trans("ApprovedBy"); + if ($usetable) print ''; + else print ': '; + if (is_object($object->user_approve)) + { + if ($object->user_approve->id) print $object->user_approve->getNomUrl(1, '', 0, 0, 0); + else print $langs->trans("Unknown"); + } else { + $userstatic = new User($db); + $userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve); + if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); + else print $langs->trans("Unknown"); + } + if ($usetable) print '
'; + print $langs->trans("DateApprove"); + if ($usetable) print ''; + else print ': '; + print dol_print_date($object->date_approve, 'dayhour'); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_approve + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($usetable) print '
'; + print $langs->trans("ApprovedBy"); + if ($usetable) print ''; + else print ': '; + $userstatic = new User($db); + $userstatic->fetch($object->user_approve_id2); + if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); + else print $langs->trans("Unknown"); + if ($usetable) print '
'; + print $langs->trans("DateApprove2"); + if ($usetable) print ''; + else print ': '; + print dol_print_date($object->date_approve2, 'dayhour'); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_approve2 + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($usetable) print '
'; + print $langs->trans("ClosedBy"); + if ($usetable) print ''; + else print ': '; + if (is_object($object->user_cloture)) + { if ($object->user_cloture->id) print $object->user_cloture->getNomUrl(1, '', 0, 0, 0); - else print $langs->trans("Unknown"); - } else { - $userstatic = new User($db); - $userstatic->fetch($object->user_cloture); + else print $langs->trans("Unknown"); + } else { + $userstatic = new User($db); + $userstatic->fetch($object->user_cloture); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); - else print $langs->trans("Unknown"); - } - if ($usetable) print '
'; - print $langs->trans("DateClosing"); - if ($usetable) print ''; - else print ': '; - print dol_print_date($object->date_cloture, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_cloture + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); - if ($usetable) print '
'; + print $langs->trans("DateClosing"); + if ($usetable) print ''; + else print ': '; + print dol_print_date($object->date_cloture, 'dayhour'); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_cloture + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($usetable) print '
'; - print $langs->trans("ConciliatedBy"); - if ($usetable) print ''; - else print ': '; - if (is_object($object->user_rappro)) - { + // User conciliate + if (!empty($object->user_rappro)) + { + if ($usetable) print '
'; + print $langs->trans("ConciliatedBy"); + if ($usetable) print ''; + else print ': '; + if (is_object($object->user_rappro)) + { if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(1, '', 0, 0, 0); - else print $langs->trans("Unknown"); - } else { - $userstatic = new User($db); - $userstatic->fetch($object->user_rappro); + else print $langs->trans("Unknown"); + } else { + $userstatic = new User($db); + $userstatic->fetch($object->user_rappro); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); - else print $langs->trans("Unknown"); - } - if ($usetable) print '
'; - print $langs->trans("DateConciliating"); - if ($usetable) print ''; - else print ': '; - print dol_print_date($object->date_rappro, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_rappro + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); - if ($usetable) print '
'; + print $langs->trans("DateConciliating"); + if ($usetable) print ''; + else print ': '; + print dol_print_date($object->date_rappro, 'dayhour'); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_rappro + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($usetable) print '
'; - print $langs->trans("DateLastSend"); - if ($usetable) print ''; - else print ': '; - print dol_print_date($object->date_envoi, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_envoi + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); - if ($usetable) print '
'; + print $langs->trans("DateLastSend"); + if ($usetable) print ''; + else print ': '; + print dol_print_date($object->date_envoi, 'dayhour'); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_envoi + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($usetable) print '
'; + if ($usetable) print ''; } @@ -489,8 +489,8 @@ function dolAddEmailTrackId($email, $trackingid) */ function isValidMailDomain($mail) { - list($user, $domain) = explode("@", $mail, 2); - return checkdnsrr($domain, "MX"); + list($user, $domain) = explode("@", $mail, 2); + return checkdnsrr($domain, "MX"); } /** @@ -508,38 +508,38 @@ function isValidMailDomain($mail) */ function isValidUrl($url, $http = 0, $pass = 0, $port = 0, $path = 0, $query = 0, $anchor = 0) { - $ValidUrl = 0; - $urlregex = ''; + $ValidUrl = 0; + $urlregex = ''; - // SCHEME - if ($http) $urlregex .= "^(http:\/\/|https:\/\/)"; + // SCHEME + if ($http) $urlregex .= "^(http:\/\/|https:\/\/)"; - // USER AND PASS - if ($pass) $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)"; + // USER AND PASS + if ($pass) $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)"; - // HOSTNAME OR IP - //$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*"; // x allowed (ex. http://localhost, http://routerlogin) - //$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)+"; // x.x - $urlregex .= "([a-z0-9+\$_\\\:-])+(\.[a-z0-9+\$_-][a-z0-9+\$_-]+)*"; // x ou x.xx (2 x ou plus) - //use only one of the above + // HOSTNAME OR IP + //$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*"; // x allowed (ex. http://localhost, http://routerlogin) + //$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)+"; // x.x + $urlregex .= "([a-z0-9+\$_\\\:-])+(\.[a-z0-9+\$_-][a-z0-9+\$_-]+)*"; // x ou x.xx (2 x ou plus) + //use only one of the above - // PORT - if ($port) $urlregex .= "(\:[0-9]{2,5})"; - // PATH - if ($path) $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/"; - // GET Query - if ($query) $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@\/&%=+\$_.-]*)"; - // ANCHOR - if ($anchor) $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)$"; + // PORT + if ($port) $urlregex .= "(\:[0-9]{2,5})"; + // PATH + if ($path) $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/"; + // GET Query + if ($query) $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@\/&%=+\$_.-]*)"; + // ANCHOR + if ($anchor) $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)$"; - // check - if (preg_match('/'.$urlregex.'/i', $url)) - { - $ValidUrl = 1; - } - //print $urlregex.' - '.$url.' - '.$ValidUrl; + // check + if (preg_match('/'.$urlregex.'/i', $url)) + { + $ValidUrl = 1; + } + //print $urlregex.' - '.$url.' - '.$ValidUrl; - return $ValidUrl; + return $ValidUrl; } /** @@ -550,21 +550,21 @@ function isValidUrl($url, $http = 0, $pass = 0, $port = 0, $path = 0, $query = 0 */ function isValidVATID($company) { - if ($company->isInEEC()) // Syntax check rules for EEC countries - { - /* Disabled because some companies can have an address in Irland and a vat number in France. + if ($company->isInEEC()) // Syntax check rules for EEC countries + { + /* Disabled because some companies can have an address in Irland and a vat number in France. $vatprefix = $company->country_code; if ($vatprefix == 'GR') $vatprefix = '(EL|GR)'; elseif ($vatprefix == 'MC') $vatprefix = 'FR'; // Monaco is using french VAT numbers else $vatprefix = preg_quote($vatprefix, '/');*/ - $vatprefix = '[a-zA-Z][a-zA-Z]'; - if (!preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,14}$/i', str_replace(' ', '', $company->tva_intra))) - { - return 0; - } - } + $vatprefix = '[a-zA-Z][a-zA-Z]'; + if (!preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,14}$/i', str_replace(' ', '', $company->tva_intra))) + { + return 0; + } + } - return 1; + return 1; } /** @@ -576,34 +576,34 @@ function isValidVATID($company) */ function clean_url($url, $http = 1) { - // Fixed by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/fix-cleaning-url.html) - // To include the minus sign in a char class, we must not escape it but put it at the end of the class - // Also, there's no need of escape a dot sign in a class - if (preg_match('/^(https?:[\\/]+)?([0-9A-Z.-]+\.[A-Z]{2,4})(:[0-9]+)?/i', $url, $regs)) - { - $proto = $regs[1]; - $domain = $regs[2]; - $port = isset($regs[3]) ? $regs[3] : ''; - //print $url." -> ".$proto." - ".$domain." - ".$port; - //$url = dol_string_nospecial(trim($url)); - $url = trim($url); + // Fixed by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/fix-cleaning-url.html) + // To include the minus sign in a char class, we must not escape it but put it at the end of the class + // Also, there's no need of escape a dot sign in a class + if (preg_match('/^(https?:[\\/]+)?([0-9A-Z.-]+\.[A-Z]{2,4})(:[0-9]+)?/i', $url, $regs)) + { + $proto = $regs[1]; + $domain = $regs[2]; + $port = isset($regs[3]) ? $regs[3] : ''; + //print $url." -> ".$proto." - ".$domain." - ".$port; + //$url = dol_string_nospecial(trim($url)); + $url = trim($url); - // Si http: defini on supprime le http (Si https on ne supprime pas) - $newproto = $proto; - if ($http == 0) - { - if (preg_match('/^http:[\\/]+/i', $url)) - { - $url = preg_replace('/^http:[\\/]+/i', '', $url); - $newproto = ''; - } - } + // Si http: defini on supprime le http (Si https on ne supprime pas) + $newproto = $proto; + if ($http == 0) + { + if (preg_match('/^http:[\\/]+/i', $url)) + { + $url = preg_replace('/^http:[\\/]+/i', '', $url); + $newproto = ''; + } + } - // On passe le nom de domaine en minuscule - $CleanUrl = preg_replace('/^'.preg_quote($proto.$domain, '/').'/i', $newproto.strtolower($domain), $url); + // On passe le nom de domaine en minuscule + $CleanUrl = preg_replace('/^'.preg_quote($proto.$domain, '/').'/i', $newproto.strtolower($domain), $url); - return $CleanUrl; - } else return $url; + return $CleanUrl; + } else return $url; } @@ -662,12 +662,12 @@ function dolObfuscateEmail($mail, $replace = "*", $nbreplace = 8, $nbdisplaymail */ function array2tr($data, $troptions = '', $tdoptions = '') { - $text = ''; - foreach ($data as $key => $item) { - $text .= ''.$item.''; - } - $text .= ''; - return $text; + $text = ''; + foreach ($data as $key => $item) { + $text .= ''.$item.''; + } + $text .= ''; + return $text; } /** @@ -682,20 +682,20 @@ function array2tr($data, $troptions = '', $tdoptions = '') */ function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = '', $tdoptions = '') { - $text = ''; - if ($tableMarkup) $text = ''; - foreach ($data as $key => $item) { - if (is_array($item)) { - $text .= array2tr($item, $troptions, $tdoptions); - } else { - $text .= ''; - $text .= ''; - $text .= ''; - $text .= ''; - } - } - if ($tableMarkup) $text .= '
'.$key.''.$item.'
'; - return $text; + $text = ''; + if ($tableMarkup) $text = ''; + foreach ($data as $key => $item) { + if (is_array($item)) { + $text .= array2tr($item, $troptions, $tdoptions); + } else { + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + } + } + if ($tableMarkup) $text .= '
'.$key.''.$item.'
'; + return $text; } /** @@ -716,434 +716,434 @@ function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = ' */ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $date = '', $mode = 'next', $bentityon = true, $objuser = null, $forceentity = null) { - global $conf, $user; + global $conf, $user; - if (!is_object($objsoc)) $valueforccc = $objsoc; - elseif ($table == "commande_fournisseur" || $table == "facture_fourn") $valueforccc = dol_string_unaccent($objsoc->code_fournisseur); - else $valueforccc = dol_string_unaccent($objsoc->code_client); + if (!is_object($objsoc)) $valueforccc = $objsoc; + elseif ($table == "commande_fournisseur" || $table == "facture_fourn") $valueforccc = dol_string_unaccent($objsoc->code_fournisseur); + else $valueforccc = dol_string_unaccent($objsoc->code_client); - $sharetable = $table; - if ($table == 'facture' || $table == 'invoice') $sharetable = 'invoicenumber'; // for getEntity function + $sharetable = $table; + if ($table == 'facture' || $table == 'invoice') $sharetable = 'invoicenumber'; // for getEntity function - // Clean parameters - if ($date == '') $date = dol_now(); // We use local year and month of PHP server to search numbers - // but we should use local year and month of user + // Clean parameters + if ($date == '') $date = dol_now(); // We use local year and month of PHP server to search numbers + // but we should use local year and month of user - // For debugging - //dol_syslog("mask=".$mask, LOG_DEBUG); - //include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); - //$mask='FA{yy}{mm}-{0000@99}'; - //$date=dol_mktime(12, 0, 0, 1, 1, 1900); - //$date=dol_stringtotime('20130101'); + // For debugging + //dol_syslog("mask=".$mask, LOG_DEBUG); + //include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); + //$mask='FA{yy}{mm}-{0000@99}'; + //$date=dol_mktime(12, 0, 0, 1, 1, 1900); + //$date=dol_stringtotime('20130101'); - $hasglobalcounter = false; - // Extract value for mask counter, mask raz and mask offset - if (preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $mask, $reg)) - { - $masktri = $reg[1].(!empty($reg[2]) ? $reg[2] : '').(!empty($reg[3]) ? $reg[3] : ''); - $maskcounter = $reg[1]; - $hasglobalcounter = true; - } else { - // setting some defaults so the rest of the code won't fail if there is a third party counter - $masktri = '00000'; - $maskcounter = '00000'; - } + $hasglobalcounter = false; + // Extract value for mask counter, mask raz and mask offset + if (preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $mask, $reg)) + { + $masktri = $reg[1].(!empty($reg[2]) ? $reg[2] : '').(!empty($reg[3]) ? $reg[3] : ''); + $maskcounter = $reg[1]; + $hasglobalcounter = true; + } else { + // setting some defaults so the rest of the code won't fail if there is a third party counter + $masktri = '00000'; + $maskcounter = '00000'; + } - $maskraz = -1; - $maskoffset = 0; - $resetEveryMonth = false; - if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) return 'ErrorCounterMustHaveMoreThan3Digits'; + $maskraz = -1; + $maskoffset = 0; + $resetEveryMonth = false; + if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) return 'ErrorCounterMustHaveMoreThan3Digits'; - // Extract value for third party mask counter - if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef)) - { - $maskrefclient = $regClientRef[1].$regClientRef[2]; - $maskrefclient_maskclientcode = $regClientRef[1]; - $maskrefclient_maskcounter = $regClientRef[2]; - $maskrefclient_maskoffset = 0; //default value of maskrefclient_counter offset - $maskrefclient_clientcode = substr($valueforccc, 0, dol_strlen($maskrefclient_maskclientcode)); //get n first characters of client code where n is length in mask - $maskrefclient_clientcode = str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT); //padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode - $maskrefclient_clientcode = dol_string_nospecial($maskrefclient_clientcode); //sanitize maskrefclient_clientcode for sql insert and sql select like - if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; - } else $maskrefclient = ''; + // Extract value for third party mask counter + if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef)) + { + $maskrefclient = $regClientRef[1].$regClientRef[2]; + $maskrefclient_maskclientcode = $regClientRef[1]; + $maskrefclient_maskcounter = $regClientRef[2]; + $maskrefclient_maskoffset = 0; //default value of maskrefclient_counter offset + $maskrefclient_clientcode = substr($valueforccc, 0, dol_strlen($maskrefclient_maskclientcode)); //get n first characters of client code where n is length in mask + $maskrefclient_clientcode = str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT); //padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode + $maskrefclient_clientcode = dol_string_nospecial($maskrefclient_clientcode); //sanitize maskrefclient_clientcode for sql insert and sql select like + if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; + } else $maskrefclient = ''; - // fail if there is neither a global nor a third party counter - if (!$hasglobalcounter && ($maskrefclient_maskcounter == '')) - { - return 'ErrorBadMask'; - } + // fail if there is neither a global nor a third party counter + if (!$hasglobalcounter && ($maskrefclient_maskcounter == '')) + { + return 'ErrorBadMask'; + } - // Extract value for third party type - if (preg_match('/\{(t+)\}/i', $mask, $regType)) - { - $masktype = $regType[1]; - $masktype_value = substr(preg_replace('/^TE_/', '', $objsoc->typent_code), 0, dol_strlen($regType[1])); // get n first characters of thirdpaty typent_code (where n is length in mask) - $masktype_value = str_pad($masktype_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask - } else { - $masktype = ''; - $masktype_value = ''; - } + // Extract value for third party type + if (preg_match('/\{(t+)\}/i', $mask, $regType)) + { + $masktype = $regType[1]; + $masktype_value = substr(preg_replace('/^TE_/', '', $objsoc->typent_code), 0, dol_strlen($regType[1])); // get n first characters of thirdpaty typent_code (where n is length in mask) + $masktype_value = str_pad($masktype_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask + } else { + $masktype = ''; + $masktype_value = ''; + } - // Extract value for user - if (preg_match('/\{(u+)\}/i', $mask, $regType)) - { - $lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; - if (is_object($objuser)) $lastname = $objuser->lastname; + // Extract value for user + if (preg_match('/\{(u+)\}/i', $mask, $regType)) + { + $lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + if (is_object($objuser)) $lastname = $objuser->lastname; - $maskuser = $regType[1]; - $maskuser_value = substr($lastname, 0, dol_strlen($regType[1])); // get n first characters of user firstname (where n is length in mask) - $maskuser_value = str_pad($maskuser_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask - } else { - $maskuser = ''; - $maskuser_value = ''; - } + $maskuser = $regType[1]; + $maskuser_value = substr($lastname, 0, dol_strlen($regType[1])); // get n first characters of user firstname (where n is length in mask) + $maskuser_value = str_pad($maskuser_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask + } else { + $maskuser = ''; + $maskuser_value = ''; + } - // Personalized field {XXX-1} à {XXX-9} - $maskperso = array(); - $maskpersonew = array(); - $tmpmask = $mask; - while (preg_match('/\{([A-Z]+)\-([1-9])\}/', $tmpmask, $regKey)) - { - $maskperso[$regKey[1]] = '{'.$regKey[1].'-'.$regKey[2].'}'; - $maskpersonew[$regKey[1]] = str_pad('', $regKey[2], '_', STR_PAD_RIGHT); - $tmpmask = preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew[$regKey[1]], $tmpmask); - } + // Personalized field {XXX-1} à {XXX-9} + $maskperso = array(); + $maskpersonew = array(); + $tmpmask = $mask; + while (preg_match('/\{([A-Z]+)\-([1-9])\}/', $tmpmask, $regKey)) + { + $maskperso[$regKey[1]] = '{'.$regKey[1].'-'.$regKey[2].'}'; + $maskpersonew[$regKey[1]] = str_pad('', $regKey[2], '_', STR_PAD_RIGHT); + $tmpmask = preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew[$regKey[1]], $tmpmask); + } - if (strstr($mask, 'user_extra_')) - { + if (strstr($mask, 'user_extra_')) + { $start = "{user_extra_"; $end = "\}"; $extra = get_string_between($mask, "user_extra_", "}"); if (!empty($user->array_options['options_'.$extra])) { $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); } - } - $maskwithonlyymcode = $mask; - $maskwithonlyymcode = preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $maskcounter, $maskwithonlyymcode); - $maskwithonlyymcode = preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode); - $maskwithonlyymcode = preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode); - $maskwithonlyymcode = preg_replace('/\{(t+)\}/i', $masktype_value, $maskwithonlyymcode); - $maskwithonlyymcode = preg_replace('/\{(u+)\}/i', $maskuser_value, $maskwithonlyymcode); - foreach ($maskperso as $key => $val) - { - $maskwithonlyymcode = preg_replace('/'.preg_quote($val, '/').'/i', $maskpersonew[$key], $maskwithonlyymcode); - } - $maskwithnocode = $maskwithonlyymcode; - $maskwithnocode = preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode); - $maskwithnocode = preg_replace('/\{yy\}/i', 'yy', $maskwithnocode); - $maskwithnocode = preg_replace('/\{y\}/i', 'y', $maskwithnocode); - $maskwithnocode = preg_replace('/\{mm\}/i', 'mm', $maskwithnocode); - // Now maskwithnocode = 0000ddmmyyyyccc for example - // and maskcounter = 0000 for example - //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n
"; - //var_dump($reg); + } + $maskwithonlyymcode = $mask; + $maskwithonlyymcode = preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $maskcounter, $maskwithonlyymcode); + $maskwithonlyymcode = preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode); + $maskwithonlyymcode = preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode); + $maskwithonlyymcode = preg_replace('/\{(t+)\}/i', $masktype_value, $maskwithonlyymcode); + $maskwithonlyymcode = preg_replace('/\{(u+)\}/i', $maskuser_value, $maskwithonlyymcode); + foreach ($maskperso as $key => $val) + { + $maskwithonlyymcode = preg_replace('/'.preg_quote($val, '/').'/i', $maskpersonew[$key], $maskwithonlyymcode); + } + $maskwithnocode = $maskwithonlyymcode; + $maskwithnocode = preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode); + $maskwithnocode = preg_replace('/\{yy\}/i', 'yy', $maskwithnocode); + $maskwithnocode = preg_replace('/\{y\}/i', 'y', $maskwithnocode); + $maskwithnocode = preg_replace('/\{mm\}/i', 'mm', $maskwithnocode); + // Now maskwithnocode = 0000ddmmyyyyccc for example + // and maskcounter = 0000 for example + //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n
"; + //var_dump($reg); - // If an offset is asked - if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]); - if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]); + // If an offset is asked + if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]); + if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]); - // Define $sqlwhere - $sqlwhere = ''; - $yearoffset = 0; // Use year of current $date by default - $yearoffsettype = false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x + // Define $sqlwhere + $sqlwhere = ''; + $yearoffset = 0; // Use year of current $date by default + $yearoffsettype = false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x - // If a restore to zero after a month is asked we check if there is already a value for this year. - if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $yearoffsettype = preg_replace('/^@/', '', $reg[2]); - if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $yearoffsettype = preg_replace('/^@/', '', $reg[3]); + // If a restore to zero after a month is asked we check if there is already a value for this year. + if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $yearoffsettype = preg_replace('/^@/', '', $reg[2]); + if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $yearoffsettype = preg_replace('/^@/', '', $reg[3]); - //print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype; - if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) - $maskraz = $yearoffsettype; // For backward compatibility - elseif ($yearoffsettype === '0' || (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) - $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START; - //print "maskraz=".$maskraz; // -1=no reset + //print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype; + if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) + $maskraz = $yearoffsettype; // For backward compatibility + elseif ($yearoffsettype === '0' || (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) + $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START; + //print "maskraz=".$maskraz; // -1=no reset - if ($maskraz > 0) { // A reset is required - if ($maskraz == 99) { - $maskraz = date('m', $date); - $resetEveryMonth = true; - } - if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; + if ($maskraz > 0) { // A reset is required + if ($maskraz == 99) { + $maskraz = date('m', $date); + $resetEveryMonth = true; + } + if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; - // Define posy, posm and reg - if ($maskraz > 1) // if reset is not first month, we need month and year into mask - { - if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 3; } elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 3; $posm = 2; } else return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; + // Define posy, posm and reg + if ($maskraz > 1) // if reset is not first month, we need month and year into mask + { + if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 3; } elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 3; $posm = 2; } else return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; - if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit'; - } else // if reset is for a specific month in year, we need year - { - if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 3; $posm = 2; } elseif (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 3; } elseif (preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 0; } else return 'ErrorCantUseRazIfNoYearInMask'; - } - // Define length - $yearlen = $posy ?dol_strlen($reg[$posy]) : 0; - $monthlen = $posm ?dol_strlen($reg[$posm]) : 0; - // Define pos - $yearpos = (dol_strlen($reg[1]) + 1); - $monthpos = ($yearpos + $yearlen); - if ($posy == 3 && $posm == 2) { // if month is before year - $monthpos = (dol_strlen($reg[1]) + 1); - $yearpos = ($monthpos + $monthlen); - } - //print "xxx ".$maskwithonlyymcode." maskraz=".$maskraz." posy=".$posy." yearlen=".$yearlen." yearpos=".$yearpos." posm=".$posm." monthlen=".$monthlen." monthpos=".$monthpos." yearoffsettype=".$yearoffsettype." resetEveryMonth=".$resetEveryMonth."\n"; + if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit'; + } else // if reset is for a specific month in year, we need year + { + if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 3; $posm = 2; } elseif (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 3; } elseif (preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 0; } else return 'ErrorCantUseRazIfNoYearInMask'; + } + // Define length + $yearlen = $posy ?dol_strlen($reg[$posy]) : 0; + $monthlen = $posm ?dol_strlen($reg[$posm]) : 0; + // Define pos + $yearpos = (dol_strlen($reg[1]) + 1); + $monthpos = ($yearpos + $yearlen); + if ($posy == 3 && $posm == 2) { // if month is before year + $monthpos = (dol_strlen($reg[1]) + 1); + $yearpos = ($monthpos + $monthlen); + } + //print "xxx ".$maskwithonlyymcode." maskraz=".$maskraz." posy=".$posy." yearlen=".$yearlen." yearpos=".$yearpos." posm=".$posm." monthlen=".$monthlen." monthpos=".$monthpos." yearoffsettype=".$yearoffsettype." resetEveryMonth=".$resetEveryMonth."\n"; - // Define $yearcomp and $monthcomp (that will be use in the select where to search max number) - $monthcomp = $maskraz; - $yearcomp = 0; + // Define $yearcomp and $monthcomp (that will be use in the select where to search max number) + $monthcomp = $maskraz; + $yearcomp = 0; - if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') // $yearoffsettype is - or + - { - $currentyear = date("Y", $date); - $fiscaldate = dol_mktime('0', '0', '0', $maskraz, '1', $currentyear); - $newyeardate = dol_mktime('0', '0', '0', '1', '1', $currentyear); - $nextnewyeardate = dol_mktime('0', '0', '0', '1', '1', $currentyear + 1); - //echo 'currentyear='.$currentyear.' date='.dol_print_date($date, 'day').' fiscaldate='.dol_print_date($fiscaldate, 'day').'
'; + if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') // $yearoffsettype is - or + + { + $currentyear = date("Y", $date); + $fiscaldate = dol_mktime('0', '0', '0', $maskraz, '1', $currentyear); + $newyeardate = dol_mktime('0', '0', '0', '1', '1', $currentyear); + $nextnewyeardate = dol_mktime('0', '0', '0', '1', '1', $currentyear + 1); + //echo 'currentyear='.$currentyear.' date='.dol_print_date($date, 'day').' fiscaldate='.dol_print_date($fiscaldate, 'day').'
'; - // If after or equal of current fiscal date - if ($date >= $fiscaldate) - { - // If before of next new year date - if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset = 1; - } // If after or equal of current new year date - elseif ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset = -1; - } // For backward compatibility - elseif (date("m", $date) < $maskraz && empty($resetEveryMonth)) { $yearoffset = -1; } // If current month lower that month of return to zero, year is previous year + // If after or equal of current fiscal date + if ($date >= $fiscaldate) + { + // If before of next new year date + if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset = 1; + } // If after or equal of current new year date + elseif ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset = -1; + } // For backward compatibility + elseif (date("m", $date) < $maskraz && empty($resetEveryMonth)) { $yearoffset = -1; } // If current month lower that month of return to zero, year is previous year - if ($yearlen == 4) $yearcomp = sprintf("%04d", date("Y", $date) + $yearoffset); - elseif ($yearlen == 2) $yearcomp = sprintf("%02d", date("y", $date) + $yearoffset); - elseif ($yearlen == 1) $yearcomp = substr(date("y", $date), 2, 1) + $yearoffset; - if ($monthcomp > 1 && empty($resetEveryMonth)) // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) - { - if ($yearlen == 4) $yearcomp1 = sprintf("%04d", date("Y", $date) + $yearoffset + 1); - elseif ($yearlen == 2) $yearcomp1 = sprintf("%02d", date("y", $date) + $yearoffset + 1); + if ($yearlen == 4) $yearcomp = sprintf("%04d", date("Y", $date) + $yearoffset); + elseif ($yearlen == 2) $yearcomp = sprintf("%02d", date("y", $date) + $yearoffset); + elseif ($yearlen == 1) $yearcomp = substr(date("y", $date), 2, 1) + $yearoffset; + if ($monthcomp > 1 && empty($resetEveryMonth)) // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) + { + if ($yearlen == 4) $yearcomp1 = sprintf("%04d", date("Y", $date) + $yearoffset + 1); + elseif ($yearlen == 2) $yearcomp1 = sprintf("%02d", date("y", $date) + $yearoffset + 1); - $sqlwhere .= "("; - $sqlwhere .= " (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; - $sqlwhere .= " AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") >= '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; - $sqlwhere .= " OR"; - $sqlwhere .= " (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp1."'"; - $sqlwhere .= " AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') "; - $sqlwhere .= ')'; - } elseif ($resetEveryMonth) + $sqlwhere .= "("; + $sqlwhere .= " (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; + $sqlwhere .= " AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") >= '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; + $sqlwhere .= " OR"; + $sqlwhere .= " (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp1."'"; + $sqlwhere .= " AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') "; + $sqlwhere .= ')'; + } elseif ($resetEveryMonth) { $sqlwhere .= "(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; - $sqlwhere .= " AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; + $sqlwhere .= " AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; } else // reset is done on january - { - $sqlwhere .= '(SUBSTRING('.$field.', '.$yearpos.', '.$yearlen.") = '".$yearcomp."')"; - } - } - //print "sqlwhere=".$sqlwhere." yearcomp=".$yearcomp."
\n"; // sqlwhere and yearcomp defined only if we ask a reset - //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."
\n"; + { + $sqlwhere .= '(SUBSTRING('.$field.', '.$yearpos.', '.$yearlen.") = '".$yearcomp."')"; + } + } + //print "sqlwhere=".$sqlwhere." yearcomp=".$yearcomp."
\n"; // sqlwhere and yearcomp defined only if we ask a reset + //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."
\n"; - // Define $sqlstring - if (function_exists('mb_strrpos')) - { - $posnumstart = mb_strrpos($maskwithnocode, $maskcounter, 'UTF-8'); + // Define $sqlstring + if (function_exists('mb_strrpos')) + { + $posnumstart = mb_strrpos($maskwithnocode, $maskcounter, 'UTF-8'); } else { - $posnumstart = strrpos($maskwithnocode, $maskcounter); + $posnumstart = strrpos($maskwithnocode, $maskcounter); } // Pos of counter in final string (from 0 to ...) - if ($posnumstart < 0) return 'ErrorBadMaskFailedToLocatePosOfSequence'; - $sqlstring = 'SUBSTRING('.$field.', '.($posnumstart + 1).', '.dol_strlen($maskcounter).')'; + if ($posnumstart < 0) return 'ErrorBadMaskFailedToLocatePosOfSequence'; + $sqlstring = 'SUBSTRING('.$field.', '.($posnumstart + 1).', '.dol_strlen($maskcounter).')'; - // Define $maskLike - $maskLike = dol_string_nospecial($mask); - $maskLike = str_replace("%", "_", $maskLike); + // Define $maskLike + $maskLike = dol_string_nospecial($mask); + $maskLike = str_replace("%", "_", $maskLike); - // Replace protected special codes with matching number of _ as wild card caracter - $maskLike = preg_replace('/\{yyyy\}/i', '____', $maskLike); - $maskLike = preg_replace('/\{yy\}/i', '__', $maskLike); - $maskLike = preg_replace('/\{y\}/i', '_', $maskLike); - $maskLike = preg_replace('/\{mm\}/i', '__', $maskLike); - $maskLike = preg_replace('/\{dd\}/i', '__', $maskLike); - $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'), str_pad("", dol_strlen($maskcounter), "_"), $maskLike); - if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), str_pad("", dol_strlen($maskrefclient), "_"), $maskLike); - if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'), $masktype_value, $maskLike); - if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'), $maskuser_value, $maskLike); - foreach ($maskperso as $key => $val) - { - $maskLike = str_replace(dol_string_nospecial($maskperso[$key]), $maskpersonew[$key], $maskLike); - } + // Replace protected special codes with matching number of _ as wild card caracter + $maskLike = preg_replace('/\{yyyy\}/i', '____', $maskLike); + $maskLike = preg_replace('/\{yy\}/i', '__', $maskLike); + $maskLike = preg_replace('/\{y\}/i', '_', $maskLike); + $maskLike = preg_replace('/\{mm\}/i', '__', $maskLike); + $maskLike = preg_replace('/\{dd\}/i', '__', $maskLike); + $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'), str_pad("", dol_strlen($maskcounter), "_"), $maskLike); + if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), str_pad("", dol_strlen($maskrefclient), "_"), $maskLike); + if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'), $masktype_value, $maskLike); + if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'), $maskuser_value, $maskLike); + foreach ($maskperso as $key => $val) + { + $maskLike = str_replace(dol_string_nospecial($maskperso[$key]), $maskpersonew[$key], $maskLike); + } - // Get counter in database - $counter = 0; - $sql = "SELECT MAX(".$sqlstring.") as val"; - $sql .= " FROM ".MAIN_DB_PREFIX.$table; - $sql .= " WHERE ".$field." LIKE '".$maskLike."'"; + // Get counter in database + $counter = 0; + $sql = "SELECT MAX(".$sqlstring.") as val"; + $sql .= " FROM ".MAIN_DB_PREFIX.$table; + $sql .= " WHERE ".$field." LIKE '".$maskLike."'"; $sql .= " AND ".$field." NOT LIKE '(PROV%)'"; - if ($bentityon) // only if entity enable - $sql .= " AND entity IN (".getEntity($sharetable).")"; - elseif (!empty($forceentity)) - $sql .= " AND entity IN (".$forceentity.")"; - if ($where) $sql .= $where; - if ($sqlwhere) $sql .= ' AND '.$sqlwhere; + if ($bentityon) // only if entity enable + $sql .= " AND entity IN (".getEntity($sharetable).")"; + elseif (!empty($forceentity)) + $sql .= " AND entity IN (".$forceentity.")"; + if ($where) $sql .= $where; + if ($sqlwhere) $sql .= ' AND '.$sqlwhere; - //print $sql.'
'; - dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - $counter = $obj->val; - } else dol_print_error($db); + //print $sql.'
'; + dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $counter = $obj->val; + } else dol_print_error($db); - // Check if we must force counter to maskoffset - if (empty($counter)) $counter = $maskoffset; - elseif (preg_match('/[^0-9]/i', $counter)) - { - $counter = 0; - dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR); - } elseif ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter = $maskoffset; + // Check if we must force counter to maskoffset + if (empty($counter)) $counter = $maskoffset; + elseif (preg_match('/[^0-9]/i', $counter)) + { + $counter = 0; + dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR); + } elseif ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter = $maskoffset; - if ($mode == 'last') // We found value for counter = last counter value. Now need to get corresponding ref of invoice. - { - $counterpadded = str_pad($counter, dol_strlen($maskcounter), "0", STR_PAD_LEFT); + if ($mode == 'last') // We found value for counter = last counter value. Now need to get corresponding ref of invoice. + { + $counterpadded = str_pad($counter, dol_strlen($maskcounter), "0", STR_PAD_LEFT); - // Define $maskLike - $maskLike = dol_string_nospecial($mask); - $maskLike = str_replace("%", "_", $maskLike); - // Replace protected special codes with matching number of _ as wild card caracter - $maskLike = preg_replace('/\{yyyy\}/i', '____', $maskLike); - $maskLike = preg_replace('/\{yy\}/i', '__', $maskLike); - $maskLike = preg_replace('/\{y\}/i', '_', $maskLike); - $maskLike = preg_replace('/\{mm\}/i', '__', $maskLike); - $maskLike = preg_replace('/\{dd\}/i', '__', $maskLike); - $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'), $counterpadded, $maskLike); - if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), str_pad("", dol_strlen($maskrefclient), "_"), $maskLike); - if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'), $masktype_value, $maskLike); - if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'), $maskuser_value, $maskLike); + // Define $maskLike + $maskLike = dol_string_nospecial($mask); + $maskLike = str_replace("%", "_", $maskLike); + // Replace protected special codes with matching number of _ as wild card caracter + $maskLike = preg_replace('/\{yyyy\}/i', '____', $maskLike); + $maskLike = preg_replace('/\{yy\}/i', '__', $maskLike); + $maskLike = preg_replace('/\{y\}/i', '_', $maskLike); + $maskLike = preg_replace('/\{mm\}/i', '__', $maskLike); + $maskLike = preg_replace('/\{dd\}/i', '__', $maskLike); + $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'), $counterpadded, $maskLike); + if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), str_pad("", dol_strlen($maskrefclient), "_"), $maskLike); + if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'), $masktype_value, $maskLike); + if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'), $maskuser_value, $maskLike); - $ref = ''; - $sql = "SELECT ".$field." as ref"; - $sql .= " FROM ".MAIN_DB_PREFIX.$table; - $sql .= " WHERE ".$field." LIKE '".$maskLike."'"; - $sql .= " AND ".$field." NOT LIKE '%PROV%'"; - if ($bentityon) // only if entity enable - $sql .= " AND entity IN (".getEntity($sharetable).")"; - elseif (!empty($forceentity)) - $sql .= " AND entity IN (".$forceentity.")"; - if ($where) $sql .= $where; - if ($sqlwhere) $sql .= ' AND '.$sqlwhere; + $ref = ''; + $sql = "SELECT ".$field." as ref"; + $sql .= " FROM ".MAIN_DB_PREFIX.$table; + $sql .= " WHERE ".$field." LIKE '".$maskLike."'"; + $sql .= " AND ".$field." NOT LIKE '%PROV%'"; + if ($bentityon) // only if entity enable + $sql .= " AND entity IN (".getEntity($sharetable).")"; + elseif (!empty($forceentity)) + $sql .= " AND entity IN (".$forceentity.")"; + if ($where) $sql .= $where; + if ($sqlwhere) $sql .= ' AND '.$sqlwhere; - dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - if ($obj) $ref = $obj->ref; - } else dol_print_error($db); + dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $ref = $obj->ref; + } else dol_print_error($db); - $numFinal = $ref; - } elseif ($mode == 'next') - { - $counter++; + $numFinal = $ref; + } elseif ($mode == 'next') + { + $counter++; - // If value for $counter has a length higher than $maskcounter chars - if ($counter >= pow(10, dol_strlen($maskcounter))) - { - $counter = 'ErrorMaxNumberReachForThisMask'; - } + // If value for $counter has a length higher than $maskcounter chars + if ($counter >= pow(10, dol_strlen($maskcounter))) + { + $counter = 'ErrorMaxNumberReachForThisMask'; + } - if (!empty($maskrefclient_maskcounter)) - { - //print "maskrefclient_maskcounter=".$maskrefclient_maskcounter." maskwithnocode=".$maskwithnocode." maskrefclient=".$maskrefclient."\n
"; + if (!empty($maskrefclient_maskcounter)) + { + //print "maskrefclient_maskcounter=".$maskrefclient_maskcounter." maskwithnocode=".$maskwithnocode." maskrefclient=".$maskrefclient."\n
"; - // Define $sqlstring - $maskrefclient_posnumstart = strpos($maskwithnocode, $maskrefclient_maskcounter, strpos($maskwithnocode, $maskrefclient)); // Pos of counter in final string (from 0 to ...) - if ($maskrefclient_posnumstart <= 0) return 'ErrorBadMask'; - $maskrefclient_sqlstring = 'SUBSTRING('.$field.', '.($maskrefclient_posnumstart + 1).', '.dol_strlen($maskrefclient_maskcounter).')'; - //print "x".$sqlstring; + // Define $sqlstring + $maskrefclient_posnumstart = strpos($maskwithnocode, $maskrefclient_maskcounter, strpos($maskwithnocode, $maskrefclient)); // Pos of counter in final string (from 0 to ...) + if ($maskrefclient_posnumstart <= 0) return 'ErrorBadMask'; + $maskrefclient_sqlstring = 'SUBSTRING('.$field.', '.($maskrefclient_posnumstart + 1).', '.dol_strlen($maskrefclient_maskcounter).')'; + //print "x".$sqlstring; - // Define $maskrefclient_maskLike - $maskrefclient_maskLike = dol_string_nospecial($mask); - $maskrefclient_maskLike = str_replace("%", "_", $maskrefclient_maskLike); - // Replace protected special codes with matching number of _ as wild card caracter - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{yyyy}'), '____', $maskrefclient_maskLike); - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{yy}'), '__', $maskrefclient_maskLike); - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{y}'), '_', $maskrefclient_maskLike); - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{mm}'), '__', $maskrefclient_maskLike); - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{dd}'), '__', $maskrefclient_maskLike); - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'), str_pad("", dol_strlen($maskcounter), "_"), $maskrefclient_maskLike); - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), $maskrefclient_clientcode.str_pad("", dol_strlen($maskrefclient_maskcounter), "_"), $maskrefclient_maskLike); + // Define $maskrefclient_maskLike + $maskrefclient_maskLike = dol_string_nospecial($mask); + $maskrefclient_maskLike = str_replace("%", "_", $maskrefclient_maskLike); + // Replace protected special codes with matching number of _ as wild card caracter + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{yyyy}'), '____', $maskrefclient_maskLike); + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{yy}'), '__', $maskrefclient_maskLike); + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{y}'), '_', $maskrefclient_maskLike); + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{mm}'), '__', $maskrefclient_maskLike); + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{dd}'), '__', $maskrefclient_maskLike); + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'), str_pad("", dol_strlen($maskcounter), "_"), $maskrefclient_maskLike); + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), $maskrefclient_clientcode.str_pad("", dol_strlen($maskrefclient_maskcounter), "_"), $maskrefclient_maskLike); - // Get counter in database - $maskrefclient_counter = 0; - $maskrefclient_sql = "SELECT MAX(".$maskrefclient_sqlstring.") as val"; - $maskrefclient_sql .= " FROM ".MAIN_DB_PREFIX.$table; - //$sql.= " WHERE ".$field." not like '(%'"; - $maskrefclient_sql .= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; - if ($bentityon) // only if entity enable - $maskrefclient_sql .= " AND entity IN (".getEntity($sharetable).")"; - elseif (!empty($forceentity)) - $sql .= " AND entity IN (".$forceentity.")"; - if ($where) $maskrefclient_sql .= $where; //use the same optional where as general mask - if ($sqlwhere) $maskrefclient_sql .= ' AND '.$sqlwhere; //use the same sqlwhere as general mask - $maskrefclient_sql .= ' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode, $maskrefclient) + 1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; + // Get counter in database + $maskrefclient_counter = 0; + $maskrefclient_sql = "SELECT MAX(".$maskrefclient_sqlstring.") as val"; + $maskrefclient_sql .= " FROM ".MAIN_DB_PREFIX.$table; + //$sql.= " WHERE ".$field." not like '(%'"; + $maskrefclient_sql .= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; + if ($bentityon) // only if entity enable + $maskrefclient_sql .= " AND entity IN (".getEntity($sharetable).")"; + elseif (!empty($forceentity)) + $sql .= " AND entity IN (".$forceentity.")"; + if ($where) $maskrefclient_sql .= $where; //use the same optional where as general mask + if ($sqlwhere) $maskrefclient_sql .= ' AND '.$sqlwhere; //use the same sqlwhere as general mask + $maskrefclient_sql .= ' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode, $maskrefclient) + 1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; - dol_syslog("functions2::get_next_value maskrefclient", LOG_DEBUG); - $maskrefclient_resql = $db->query($maskrefclient_sql); - if ($maskrefclient_resql) - { - $maskrefclient_obj = $db->fetch_object($maskrefclient_resql); - $maskrefclient_counter = $maskrefclient_obj->val; - } else dol_print_error($db); + dol_syslog("functions2::get_next_value maskrefclient", LOG_DEBUG); + $maskrefclient_resql = $db->query($maskrefclient_sql); + if ($maskrefclient_resql) + { + $maskrefclient_obj = $db->fetch_object($maskrefclient_resql); + $maskrefclient_counter = $maskrefclient_obj->val; + } else dol_print_error($db); - if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i', $maskrefclient_counter)) $maskrefclient_counter = $maskrefclient_maskoffset; + if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i', $maskrefclient_counter)) $maskrefclient_counter = $maskrefclient_maskoffset; $maskrefclient_counter++; - } + } - // Build numFinal - $numFinal = $mask; + // Build numFinal + $numFinal = $mask; - // We replace special codes except refclient + // We replace special codes except refclient if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year { - $numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date) + $yearoffset, $numFinal); - $numFinal = preg_replace('/\{yy\}/i', date("y", $date) + $yearoffset, $numFinal); - $numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1) + $yearoffset, $numFinal); + $numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date) + $yearoffset, $numFinal); + $numFinal = preg_replace('/\{yy\}/i', date("y", $date) + $yearoffset, $numFinal); + $numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1) + $yearoffset, $numFinal); } else // we want yyyy to be current year { - $numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date), $numFinal); - $numFinal = preg_replace('/\{yy\}/i', date("y", $date), $numFinal); - $numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1), $numFinal); + $numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date), $numFinal); + $numFinal = preg_replace('/\{yy\}/i', date("y", $date), $numFinal); + $numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1), $numFinal); } - $numFinal = preg_replace('/\{mm\}/i', date("m", $date), $numFinal); - $numFinal = preg_replace('/\{dd\}/i', date("d", $date), $numFinal); + $numFinal = preg_replace('/\{mm\}/i', date("m", $date), $numFinal); + $numFinal = preg_replace('/\{dd\}/i', date("d", $date), $numFinal); - // Now we replace the counter - $maskbefore = '{'.$masktri.'}'; - $maskafter = str_pad($counter, dol_strlen($maskcounter), "0", STR_PAD_LEFT); - //print 'x'.$maskbefore.'-'.$maskafter.'y'; - $numFinal = str_replace($maskbefore, $maskafter, $numFinal); + // Now we replace the counter + $maskbefore = '{'.$masktri.'}'; + $maskafter = str_pad($counter, dol_strlen($maskcounter), "0", STR_PAD_LEFT); + //print 'x'.$maskbefore.'-'.$maskafter.'y'; + $numFinal = str_replace($maskbefore, $maskafter, $numFinal); - // Now we replace the refclient - if ($maskrefclient) - { - //print "maskrefclient=".$maskrefclient." maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode." maskrefclient_clientcode=".$maskrefclient_clientcode."\n
";exit; - $maskrefclient_maskbefore = '{'.$maskrefclient.'}'; - $maskrefclient_maskafter = $maskrefclient_clientcode.str_pad($maskrefclient_counter, dol_strlen($maskrefclient_maskcounter), "0", STR_PAD_LEFT); - $numFinal = str_replace($maskrefclient_maskbefore, $maskrefclient_maskafter, $numFinal); - } + // Now we replace the refclient + if ($maskrefclient) + { + //print "maskrefclient=".$maskrefclient." maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode." maskrefclient_clientcode=".$maskrefclient_clientcode."\n
";exit; + $maskrefclient_maskbefore = '{'.$maskrefclient.'}'; + $maskrefclient_maskafter = $maskrefclient_clientcode.str_pad($maskrefclient_counter, dol_strlen($maskrefclient_maskcounter), "0", STR_PAD_LEFT); + $numFinal = str_replace($maskrefclient_maskbefore, $maskrefclient_maskafter, $numFinal); + } - // Now we replace the type - if ($masktype) - { - $masktype_maskbefore = '{'.$masktype.'}'; - $masktype_maskafter = $masktype_value; - $numFinal = str_replace($masktype_maskbefore, $masktype_maskafter, $numFinal); - } + // Now we replace the type + if ($masktype) + { + $masktype_maskbefore = '{'.$masktype.'}'; + $masktype_maskafter = $masktype_value; + $numFinal = str_replace($masktype_maskbefore, $masktype_maskafter, $numFinal); + } - // Now we replace the user - if ($maskuser) - { - $maskuser_maskbefore = '{'.$maskuser.'}'; - $maskuser_maskafter = $maskuser_value; - $numFinal = str_replace($maskuser_maskbefore, $maskuser_maskafter, $numFinal); - } - } + // Now we replace the user + if ($maskuser) + { + $maskuser_maskbefore = '{'.$maskuser.'}'; + $maskuser_maskafter = $maskuser_value; + $numFinal = str_replace($maskuser_maskbefore, $maskuser_maskafter, $numFinal); + } + } - dol_syslog("functions2::get_next_value return ".$numFinal, LOG_DEBUG); - return $numFinal; + dol_syslog("functions2::get_next_value return ".$numFinal, LOG_DEBUG); + return $numFinal; } /** @@ -1156,12 +1156,12 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ */ function get_string_between($string, $start, $end) { - $string = " ".$string; - $ini = strpos($string, $start); - if ($ini == 0) return ""; - $ini += strlen($start); - $len = strpos($string, $end, $ini) - $ini; - return substr($string, $ini, $len); + $string = " ".$string; + $ini = strpos($string, $start); + if ($ini == 0) return ""; + $ini += strlen($start); + $len = strpos($string, $end, $ini) - $ini; + return substr($string, $ini, $len); } /** @@ -1173,90 +1173,90 @@ function get_string_between($string, $start, $end) */ function check_value($mask, $value) { - $result = 0; + $result = 0; - $hasglobalcounter = false; - // Extract value for mask counter, mask raz and mask offset - if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) - { - $masktri = $reg[1].(isset($reg[2]) ? $reg[2] : '').(isset($reg[3]) ? $reg[3] : ''); - $maskcounter = $reg[1]; - $hasglobalcounter = true; - } else { - // setting some defaults so the rest of the code won't fail if there is a third party counter - $masktri = '00000'; - $maskcounter = '00000'; - } + $hasglobalcounter = false; + // Extract value for mask counter, mask raz and mask offset + if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) + { + $masktri = $reg[1].(isset($reg[2]) ? $reg[2] : '').(isset($reg[3]) ? $reg[3] : ''); + $maskcounter = $reg[1]; + $hasglobalcounter = true; + } else { + // setting some defaults so the rest of the code won't fail if there is a third party counter + $masktri = '00000'; + $maskcounter = '00000'; + } - $maskraz = -1; - $maskoffset = 0; - if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; + $maskraz = -1; + $maskoffset = 0; + if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; - // Extract value for third party mask counter - if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef)) - { - $maskrefclient = $regClientRef[1].$regClientRef[2]; - $maskrefclient_maskclientcode = $regClientRef[1]; - $maskrefclient_maskcounter = $regClientRef[2]; - $maskrefclient_maskoffset = 0; //default value of maskrefclient_counter offset - $maskrefclient_clientcode = substr('', 0, dol_strlen($maskrefclient_maskclientcode)); //get n first characters of client code to form maskrefclient_clientcode - $maskrefclient_clientcode = str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT); //padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode - $maskrefclient_clientcode = dol_string_nospecial($maskrefclient_clientcode); //sanitize maskrefclient_clientcode for sql insert and sql select like - if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; - } else $maskrefclient = ''; + // Extract value for third party mask counter + if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef)) + { + $maskrefclient = $regClientRef[1].$regClientRef[2]; + $maskrefclient_maskclientcode = $regClientRef[1]; + $maskrefclient_maskcounter = $regClientRef[2]; + $maskrefclient_maskoffset = 0; //default value of maskrefclient_counter offset + $maskrefclient_clientcode = substr('', 0, dol_strlen($maskrefclient_maskclientcode)); //get n first characters of client code to form maskrefclient_clientcode + $maskrefclient_clientcode = str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT); //padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode + $maskrefclient_clientcode = dol_string_nospecial($maskrefclient_clientcode); //sanitize maskrefclient_clientcode for sql insert and sql select like + if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; + } else $maskrefclient = ''; - // fail if there is neither a global nor a third party counter - if (!$hasglobalcounter && ($maskrefclient_maskcounter == '')) - { - return 'ErrorBadMask'; - } + // fail if there is neither a global nor a third party counter + if (!$hasglobalcounter && ($maskrefclient_maskcounter == '')) + { + return 'ErrorBadMask'; + } - $maskwithonlyymcode = $mask; - $maskwithonlyymcode = preg_replace('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $maskcounter, $maskwithonlyymcode); - $maskwithonlyymcode = preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode); - $maskwithonlyymcode = preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode); - $maskwithnocode = $maskwithonlyymcode; - $maskwithnocode = preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode); - $maskwithnocode = preg_replace('/\{yy\}/i', 'yy', $maskwithnocode); - $maskwithnocode = preg_replace('/\{y\}/i', 'y', $maskwithnocode); - $maskwithnocode = preg_replace('/\{mm\}/i', 'mm', $maskwithnocode); - // Now maskwithnocode = 0000ddmmyyyyccc for example - // and maskcounter = 0000 for example - //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n
"; + $maskwithonlyymcode = $mask; + $maskwithonlyymcode = preg_replace('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $maskcounter, $maskwithonlyymcode); + $maskwithonlyymcode = preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode); + $maskwithonlyymcode = preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode); + $maskwithnocode = $maskwithonlyymcode; + $maskwithnocode = preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode); + $maskwithnocode = preg_replace('/\{yy\}/i', 'yy', $maskwithnocode); + $maskwithnocode = preg_replace('/\{y\}/i', 'y', $maskwithnocode); + $maskwithnocode = preg_replace('/\{mm\}/i', 'mm', $maskwithnocode); + // Now maskwithnocode = 0000ddmmyyyyccc for example + // and maskcounter = 0000 for example + //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n
"; - // If an offset is asked - if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]); - if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]); + // If an offset is asked + if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]); + if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]); - // Define $sqlwhere + // Define $sqlwhere - // If a restore to zero after a month is asked we check if there is already a value for this year. - if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $maskraz = preg_replace('/^@/', '', $reg[2]); - if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $maskraz = preg_replace('/^@/', '', $reg[3]); - if ($maskraz >= 0) - { - if ($maskraz == 99) { - $maskraz = date('m'); - $resetEveryMonth = true; - } - if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; + // If a restore to zero after a month is asked we check if there is already a value for this year. + if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $maskraz = preg_replace('/^@/', '', $reg[2]); + if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $maskraz = preg_replace('/^@/', '', $reg[3]); + if ($maskraz >= 0) + { + if ($maskraz == 99) { + $maskraz = date('m'); + $resetEveryMonth = true; + } + if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; - // Define reg - if ($maskraz > 1 && !preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; - if ($maskraz <= 1 && !preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazIfNoYearInMask'; - //print "x".$maskwithonlyymcode." ".$maskraz; - } - //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."
\n"; + // Define reg + if ($maskraz > 1 && !preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; + if ($maskraz <= 1 && !preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazIfNoYearInMask'; + //print "x".$maskwithonlyymcode." ".$maskraz; + } + //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."
\n"; - // Check we have a number in ($posnumstart+1).', '.dol_strlen($maskcounter) - // + // Check we have a number in ($posnumstart+1).', '.dol_strlen($maskcounter) + // - // Check length - $len = dol_strlen($maskwithnocode); - if (dol_strlen($value) != $len) $result = -1; + // Check length + $len = dol_strlen($maskwithnocode); + if (dol_strlen($value) != $len) $result = -1; - // Define $maskLike - /* seems not used + // Define $maskLike + /* seems not used $maskLike = dol_string_nospecial($mask); $maskLike = str_replace("%","_",$maskLike); // Replace protected special codes with matching number of _ as wild card caracter @@ -1269,8 +1269,8 @@ function check_value($mask, $value) if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",strlen($maskrefclient),"_"),$maskLike); */ - dol_syslog("functions2::check_value result=".$result, LOG_DEBUG); - return $result; + dol_syslog("functions2::check_value result=".$result, LOG_DEBUG); + return $result; } /** @@ -1283,12 +1283,12 @@ function check_value($mask, $value) */ function binhex($bin, $pad = false, $upper = false) { - $last = dol_strlen($bin) - 1; - for ($i = 0; $i <= $last; $i++) { $x += $bin[$last - $i] * pow(2, $i); } - $x = dechex($x); - if ($pad) { while (dol_strlen($x) < intval(dol_strlen($bin)) / 4) { $x = "0$x"; } } - if ($upper) { $x = strtoupper($x); } - return $x; + $last = dol_strlen($bin) - 1; + for ($i = 0; $i <= $last; $i++) { $x += $bin[$last - $i] * pow(2, $i); } + $x = dechex($x); + if ($pad) { while (dol_strlen($x) < intval(dol_strlen($bin)) / 4) { $x = "0$x"; } } + if ($upper) { $x = strtoupper($x); } + return $x; } /** @@ -1299,13 +1299,13 @@ function binhex($bin, $pad = false, $upper = false) */ function hexbin($hexa) { - $bin = ''; - $strLength = dol_strlen($hexa); - for ($i = 0; $i < $strLength; $i++) - { - $bin .= str_pad(decbin(hexdec($hexa[$i])), 4, '0', STR_PAD_LEFT); - } - return $bin; + $bin = ''; + $strLength = dol_strlen($hexa); + for ($i = 0; $i < $strLength; $i++) + { + $bin .= str_pad(decbin(hexdec($hexa[$i])), 4, '0', STR_PAD_LEFT); + } + return $bin; } /** @@ -1316,72 +1316,72 @@ function hexbin($hexa) */ function numero_semaine($time) { - $stime = strftime('%Y-%m-%d', $time); + $stime = strftime('%Y-%m-%d', $time); - if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/i', $stime, $reg)) - { - // Date est au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS' - $annee = $reg[1]; - $mois = $reg[2]; - $jour = $reg[3]; - } + if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/i', $stime, $reg)) + { + // Date est au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS' + $annee = $reg[1]; + $mois = $reg[2]; + $jour = $reg[3]; + } - /* + /* * Norme ISO-8601: * - La semaine 1 de toute annee est celle qui contient le 4 janvier ou que la semaine 1 de toute annee est celle qui contient le 1er jeudi de janvier. * - La majorite des annees ont 52 semaines mais les annees qui commence un jeudi et les annees bissextiles commencant un mercredi en possede 53. * - Le 1er jour de la semaine est le Lundi */ - // Definition du Jeudi de la semaine - if (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) == 0) // Dimanche - $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - 3 * 24 * 60 * 60; - elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) < 4) // du Lundi au Mercredi - $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) + (4 - date("w", mktime(12, 0, 0, $mois, $jour, $annee))) * 24 * 60 * 60; - elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) > 4) // du Vendredi au Samedi - $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) - 4) * 24 * 60 * 60; - else // Jeudi - $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee); + // Definition du Jeudi de la semaine + if (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) == 0) // Dimanche + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - 3 * 24 * 60 * 60; + elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) < 4) // du Lundi au Mercredi + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) + (4 - date("w", mktime(12, 0, 0, $mois, $jour, $annee))) * 24 * 60 * 60; + elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) > 4) // du Vendredi au Samedi + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) - 4) * 24 * 60 * 60; + else // Jeudi + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee); - // Definition du premier Jeudi de l'annee - if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 0) // Dimanche - { - $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + 4 * 24 * 60 * 60; - } elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) < 4) // du Lundi au Mercredi - { - $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + (4 - date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))) * 24 * 60 * 60; - } elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) > 4) // du Vendredi au Samedi - { - $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + (7 - (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) - 4)) * 24 * 60 * 60; - } else // Jeudi - { - $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)); - } + // Definition du premier Jeudi de l'annee + if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 0) // Dimanche + { + $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + 4 * 24 * 60 * 60; + } elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) < 4) // du Lundi au Mercredi + { + $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + (4 - date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))) * 24 * 60 * 60; + } elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) > 4) // du Vendredi au Samedi + { + $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + (7 - (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) - 4)) * 24 * 60 * 60; + } else // Jeudi + { + $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)); + } - // Definition du numero de semaine: nb de jours entre "premier Jeudi de l'annee" et "Jeudi de la semaine"; - $numeroSemaine = ( - ( - date("z", mktime(12, 0, 0, date("m", $jeudiSemaine), date("d", $jeudiSemaine), date("Y", $jeudiSemaine))) - - - date("z", mktime(12, 0, 0, date("m", $premierJeudiAnnee), date("d", $premierJeudiAnnee), date("Y", $premierJeudiAnnee))) - ) / 7 - ) + 1; + // Definition du numero de semaine: nb de jours entre "premier Jeudi de l'annee" et "Jeudi de la semaine"; + $numeroSemaine = ( + ( + date("z", mktime(12, 0, 0, date("m", $jeudiSemaine), date("d", $jeudiSemaine), date("Y", $jeudiSemaine))) + - + date("z", mktime(12, 0, 0, date("m", $premierJeudiAnnee), date("d", $premierJeudiAnnee), date("Y", $premierJeudiAnnee))) + ) / 7 + ) + 1; - // Cas particulier de la semaine 53 - if ($numeroSemaine == 53) - { - // Les annees qui commence un Jeudi et les annees bissextiles commencant un Mercredi en possede 53 - if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 4 || (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 3 && date("z", mktime(12, 0, 0, 12, 31, date("Y", $jeudiSemaine))) == 365)) - { - $numeroSemaine = 53; - } else { - $numeroSemaine = 1; - } - } + // Cas particulier de la semaine 53 + if ($numeroSemaine == 53) + { + // Les annees qui commence un Jeudi et les annees bissextiles commencant un Mercredi en possede 53 + if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 4 || (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 3 && date("z", mktime(12, 0, 0, 12, 31, date("Y", $jeudiSemaine))) == 365)) + { + $numeroSemaine = 53; + } else { + $numeroSemaine = 1; + } + } - //echo $jour."-".$mois."-".$annee." (".date("d-m-Y",$premierJeudiAnnee)." - ".date("d-m-Y",$jeudiSemaine).") -> ".$numeroSemaine."
"; + //echo $jour."-".$mois."-".$annee." (".date("d-m-Y",$premierJeudiAnnee)." - ".date("d-m-Y",$jeudiSemaine).") -> ".$numeroSemaine."
"; - return sprintf("%02d", $numeroSemaine); + return sprintf("%02d", $numeroSemaine); } /** @@ -1394,28 +1394,28 @@ function numero_semaine($time) */ function weight_convert($weight, &$from_unit, $to_unit) { - /* Pour convertire 320 gr en Kg appeler + /* Pour convertire 320 gr en Kg appeler * $f = -3 * weigh_convert(320, $f, 0) retournera 0.32 * */ - while ($from_unit <> $to_unit) - { - if ($from_unit > $to_unit) - { - $weight = $weight * 10; - $from_unit = $from_unit - 1; - $weight = weight_convert($weight, $from_unit, $to_unit); - } - if ($from_unit < $to_unit) - { - $weight = $weight / 10; - $from_unit = $from_unit + 1; - $weight = weight_convert($weight, $from_unit, $to_unit); - } - } + while ($from_unit <> $to_unit) + { + if ($from_unit > $to_unit) + { + $weight = $weight * 10; + $from_unit = $from_unit - 1; + $weight = weight_convert($weight, $from_unit, $to_unit); + } + if ($from_unit < $to_unit) + { + $weight = $weight / 10; + $from_unit = $from_unit + 1; + $weight = weight_convert($weight, $from_unit, $to_unit); + } + } - return $weight; + return $weight; } /** @@ -1431,60 +1431,60 @@ function weight_convert($weight, &$from_unit, $to_unit) */ function dol_set_user_param($db, $conf, &$user, $tab) { - // Verification parametres - if (count($tab) < 1) return -1; + // Verification parametres + if (count($tab) < 1) return -1; - $db->begin(); + $db->begin(); - // We remove old parameters for all keys in $tab - $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param"; - $sql .= " WHERE fk_user = ".$user->id; - $sql .= " AND entity = ".$conf->entity; - $sql .= " AND param in ("; - $i = 0; - foreach ($tab as $key => $value) - { - if ($i > 0) $sql .= ','; - $sql .= "'".$db->escape($key)."'"; - $i++; - } - $sql .= ")"; - dol_syslog("functions2.lib::dol_set_user_param", LOG_DEBUG); + // We remove old parameters for all keys in $tab + $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param"; + $sql .= " WHERE fk_user = ".$user->id; + $sql .= " AND entity = ".$conf->entity; + $sql .= " AND param in ("; + $i = 0; + foreach ($tab as $key => $value) + { + if ($i > 0) $sql .= ','; + $sql .= "'".$db->escape($key)."'"; + $i++; + } + $sql .= ")"; + dol_syslog("functions2.lib::dol_set_user_param", LOG_DEBUG); - $resql = $db->query($sql); - if (!$resql) - { - dol_print_error($db); - $db->rollback(); - return -1; - } + $resql = $db->query($sql); + if (!$resql) + { + dol_print_error($db); + $db->rollback(); + return -1; + } - foreach ($tab as $key => $value) - { - // Set new parameters - if ($value) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_param(fk_user,entity,param,value)"; - $sql .= " VALUES (".$user->id.",".$conf->entity.","; - $sql .= " '".$db->escape($key)."','".$db->escape($value)."')"; + foreach ($tab as $key => $value) + { + // Set new parameters + if ($value) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_param(fk_user,entity,param,value)"; + $sql .= " VALUES (".$user->id.",".$conf->entity.","; + $sql .= " '".$db->escape($key)."','".$db->escape($value)."')"; - dol_syslog("functions2.lib::dol_set_user_param", LOG_DEBUG); - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - $db->rollback(); - return -1; - } - $user->conf->$key = $value; - //print "key=".$key." user->conf->key=".$user->conf->$key; - } else { - unset($user->conf->$key); - } - } + dol_syslog("functions2.lib::dol_set_user_param", LOG_DEBUG); + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + $db->rollback(); + return -1; + } + $user->conf->$key = $value; + //print "key=".$key." user->conf->key=".$user->conf->$key; + } else { + unset($user->conf->$key); + } + } - $db->commit(); - return 1; + $db->commit(); + return 1; } /** @@ -1496,15 +1496,15 @@ function dol_set_user_param($db, $conf, &$user, $tab) */ function dol_print_reduction($reduction, $langs) { - $string = ''; - if ($reduction == 100) - { - $string = $langs->transnoentities("Offered"); - } else { - $string = vatrate($reduction, true); - } + $string = ''; + if ($reduction == 100) + { + $string = $langs->transnoentities("Offered"); + } else { + $string = vatrate($reduction, true); + } - return $string; + return $string; } /** @@ -1518,7 +1518,7 @@ function version_os($option = '') { if ($option == 'smr') $osversion = php_uname('s').' '.php_uname('m').' '.php_uname('r'); else $osversion = php_uname(); - return $osversion; + return $osversion; } /** @@ -1529,7 +1529,7 @@ function version_os($option = '') */ function version_php() { - return phpversion(); + return phpversion(); } /** @@ -1540,7 +1540,7 @@ function version_php() */ function version_dolibarr() { - return DOL_VERSION; + return DOL_VERSION; } /** @@ -1550,7 +1550,7 @@ function version_dolibarr() */ function version_webserver() { - return $_SERVER["SERVER_SOFTWARE"]; + return $_SERVER["SERVER_SOFTWARE"]; } /** @@ -1563,89 +1563,89 @@ function version_webserver() */ function getListOfModels($db, $type, $maxfilenamelength = 0) { - global $conf, $langs; - $liste = array(); - $found = 0; - $dirtoscan = ''; + global $conf, $langs; + $liste = array(); + $found = 0; + $dirtoscan = ''; - $sql = "SELECT nom as id, nom as doc_template_name, libelle as label, description as description"; - $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; - $sql .= " WHERE type = '".$db->escape($type)."'"; - $sql .= " AND entity IN (0,".$conf->entity.")"; - $sql .= " ORDER BY description DESC"; + $sql = "SELECT nom as id, nom as doc_template_name, libelle as label, description as description"; + $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; + $sql .= " WHERE type = '".$db->escape($type)."'"; + $sql .= " AND entity IN (0,".$conf->entity.")"; + $sql .= " ORDER BY description DESC"; - dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $found = 1; + dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $found = 1; - $obj = $db->fetch_object($resql); + $obj = $db->fetch_object($resql); - // If this generation module needs to scan a directory, then description field is filled - // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...). - if (!empty($obj->description)) // A list of directories to scan is defined - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + // If this generation module needs to scan a directory, then description field is filled + // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...). + if (!empty($obj->description)) // A list of directories to scan is defined + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $const = $obj->description; - //irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); - $dirtoscan = preg_replace('/[\r\n]+/', ',', trim($conf->global->$const)); + $const = $obj->description; + //irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); + $dirtoscan = preg_replace('/[\r\n]+/', ',', trim($conf->global->$const)); - $listoffiles = array(); + $listoffiles = array(); - // Now we add models found in directories scanned - $listofdir = explode(',', $dirtoscan); - 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)) - { - // all type of template is allowed - $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); - if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); - } - } + // Now we add models found in directories scanned + $listofdir = explode(',', $dirtoscan); + 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)) + { + // all type of template is allowed + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); + } + } - if (count($listoffiles)) - { - foreach ($listoffiles as $record) - { - $max = ($maxfilenamelength ? $maxfilenamelength : 28); - $liste[$obj->id.':'.$record['fullname']] = dol_trunc($record['name'], $max, 'middle'); - } - } else { - $liste[0] = $obj->label.': '.$langs->trans("None"); - } - } else { - if ($type == 'member' && $obj->doc_template_name == 'standard') // Special case, if member template, we add variant per format - { - global $_Avery_Labels; - include_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; - foreach ($_Avery_Labels as $key => $val) - { - $liste[$obj->id.':'.$key] = ($obj->label ? $obj->label : $obj->doc_template_name).' '.$val['name']; - } - } else // Common usage - { - $liste[$obj->id] = $obj->label ? $obj->label : $obj->doc_template_name; - } - } - $i++; - } - } else { - dol_print_error($db); - return -1; - } + if (count($listoffiles)) + { + foreach ($listoffiles as $record) + { + $max = ($maxfilenamelength ? $maxfilenamelength : 28); + $liste[$obj->id.':'.$record['fullname']] = dol_trunc($record['name'], $max, 'middle'); + } + } else { + $liste[0] = $obj->label.': '.$langs->trans("None"); + } + } else { + if ($type == 'member' && $obj->doc_template_name == 'standard') // Special case, if member template, we add variant per format + { + global $_Avery_Labels; + include_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; + foreach ($_Avery_Labels as $key => $val) + { + $liste[$obj->id.':'.$key] = ($obj->label ? $obj->label : $obj->doc_template_name).' '.$val['name']; + } + } else // Common usage + { + $liste[$obj->id] = $obj->label ? $obj->label : $obj->doc_template_name; + } + } + $i++; + } + } else { + dol_print_error($db); + return -1; + } - if ($found) return $liste; - else return 0; + if ($found) return $liste; + else return 0; } /** @@ -1680,11 +1680,11 @@ function is_ip($ip) */ function dol_buildlogin($lastname, $firstname) { - $login = strtolower(dol_string_unaccent($firstname)); - $login .= ($login ? '.' : ''); - $login .= strtolower(dol_string_unaccent($lastname)); - $login = dol_string_nospecial($login, ''); // For special names - return $login; + $login = strtolower(dol_string_unaccent($firstname)); + $login .= ($login ? '.' : ''); + $login .= strtolower(dol_string_unaccent($lastname)); + $login = dol_string_nospecial($login, ''); // For special names + return $login; } /** @@ -1694,40 +1694,40 @@ function dol_buildlogin($lastname, $firstname) */ function getSoapParams() { - global $conf; + global $conf; - $params = array(); - $proxyuse = (empty($conf->global->MAIN_PROXY_USE) ?false:true); - $proxyhost = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_HOST); - $proxyport = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PORT); - $proxyuser = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_USER); - $proxypass = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PASS); - $timeout = (empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout - $response_timeout = (empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout - //print extension_loaded('soap'); - if ($proxyuse) - { - $params = array('connection_timeout'=>$timeout, - 'response_timeout'=>$response_timeout, - 'proxy_use' => 1, - 'proxy_host' => $proxyhost, - 'proxy_port' => $proxyport, - 'proxy_login' => $proxyuser, - 'proxy_password' => $proxypass, - 'trace' => 1 - ); - } else { - $params = array('connection_timeout'=>$timeout, - 'response_timeout'=>$response_timeout, - 'proxy_use' => 0, - 'proxy_host' => false, - 'proxy_port' => false, - 'proxy_login' => false, - 'proxy_password' => false, - 'trace' => 1 - ); - } - return $params; + $params = array(); + $proxyuse = (empty($conf->global->MAIN_PROXY_USE) ?false:true); + $proxyhost = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_HOST); + $proxyport = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PORT); + $proxyuser = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_USER); + $proxypass = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PASS); + $timeout = (empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout + $response_timeout = (empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout + //print extension_loaded('soap'); + if ($proxyuse) + { + $params = array('connection_timeout'=>$timeout, + 'response_timeout'=>$response_timeout, + 'proxy_use' => 1, + 'proxy_host' => $proxyhost, + 'proxy_port' => $proxyport, + 'proxy_login' => $proxyuser, + 'proxy_password' => $proxypass, + 'trace' => 1 + ); + } else { + $params = array('connection_timeout'=>$timeout, + 'response_timeout'=>$response_timeout, + 'proxy_use' => 0, + 'proxy_host' => false, + 'proxy_port' => false, + 'proxy_login' => false, + 'proxy_password' => false, + 'trace' => 1 + ); + } + return $params; } @@ -2027,13 +2027,13 @@ function colorStringToArray($stringcolor, $colorifnotfound = array(88, 88, 88)) */ function colorValidateHex($color, $allow_white = true) { - if (!$allow_white && ($color === '#fff' || $color === '#ffffff')) return false; + if (!$allow_white && ($color === '#fff' || $color === '#ffffff')) return false; - if (preg_match('/^#[a-f0-9]{6}$/i', $color)) //hex color is valid - { - return true; - } - return false; + if (preg_match('/^#[a-f0-9]{6}$/i', $color)) //hex color is valid + { + return true; + } + return false; } /** @@ -2096,26 +2096,26 @@ function colorAgressiveness($hex, $ratio = -50, $brightness = 0) */ function colorAdjustBrightness($hex, $steps) { - // Steps should be between -255 and 255. Negative = darker, positive = lighter - $steps = max(-255, min(255, $steps)); + // Steps should be between -255 and 255. Negative = darker, positive = lighter + $steps = max(-255, min(255, $steps)); - // Normalize into a six character long hex string - $hex = str_replace('#', '', $hex); - if (strlen($hex) == 3) { - $hex = str_repeat(substr($hex, 0, 1), 2).str_repeat(substr($hex, 1, 1), 2).str_repeat(substr($hex, 2, 1), 2); - } + // Normalize into a six character long hex string + $hex = str_replace('#', '', $hex); + if (strlen($hex) == 3) { + $hex = str_repeat(substr($hex, 0, 1), 2).str_repeat(substr($hex, 1, 1), 2).str_repeat(substr($hex, 2, 1), 2); + } - // Split into three parts: R, G and B - $color_parts = str_split($hex, 2); - $return = '#'; + // Split into three parts: R, G and B + $color_parts = str_split($hex, 2); + $return = '#'; - foreach ($color_parts as $color) { - $color = hexdec($color); // Convert to decimal - $color = max(0, min(255, $color + $steps)); // Adjust color - $return .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT); // Make two char hex code - } + foreach ($color_parts as $color) { + $color = hexdec($color); // Convert to decimal + $color = max(0, min(255, $color + $steps)); // Adjust color + $return .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT); // Make two char hex code + } - return $return; + return $return; } /** @@ -2125,8 +2125,8 @@ function colorAdjustBrightness($hex, $steps) */ function colorDarker($hex, $percent) { - $steps = intval(255 * $percent / 100) * -1; - return colorAdjustBrightness($hex, $steps); + $steps = intval(255 * $percent / 100) * -1; + return colorAdjustBrightness($hex, $steps); } /** @@ -2136,8 +2136,8 @@ function colorDarker($hex, $percent) */ function colorLighten($hex, $percent) { - $steps = intval(255 * $percent / 100); - return colorAdjustBrightness($hex, $steps); + $steps = intval(255 * $percent / 100); + return colorAdjustBrightness($hex, $steps); } @@ -2149,25 +2149,25 @@ function colorLighten($hex, $percent) */ function colorHexToRgb($hex, $alpha = false, $returnArray = false) { - $string = ''; - $hex = str_replace('#', '', $hex); - $length = strlen($hex); - $rgb = array(); - $rgb['r'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0)); - $rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0)); - $rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0)); - if ($alpha !== false) { - $rgb['a'] = floatval($alpha); - $string = 'rgba('.implode(',', $rgb).')'; - } else { - $string = 'rgb('.implode(',', $rgb).')'; - } + $string = ''; + $hex = str_replace('#', '', $hex); + $length = strlen($hex); + $rgb = array(); + $rgb['r'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0)); + $rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0)); + $rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0)); + if ($alpha !== false) { + $rgb['a'] = floatval($alpha); + $string = 'rgba('.implode(',', $rgb).')'; + } else { + $string = 'rgb('.implode(',', $rgb).')'; + } - if ($returnArray) { - return $rgb; - } else { - return $string; - } + if ($returnArray) { + return $rgb; + } else { + return $string; + } } @@ -2180,25 +2180,25 @@ function colorHexToRgb($hex, $alpha = false, $returnArray = false) */ function cartesianArray(array $input) { - // filter out empty values - $input = array_filter($input); + // filter out empty values + $input = array_filter($input); - $result = array(array()); + $result = array(array()); - foreach ($input as $key => $values) { - $append = array(); + foreach ($input as $key => $values) { + $append = array(); - foreach ($result as $product) { - foreach ($values as $item) { - $product[$key] = $item; - $append[] = $product; - } - } + foreach ($result as $product) { + foreach ($values as $item) { + $product[$key] = $item; + $append[] = $product; + } + } - $result = $append; - } + $result = $append; + } - return $result; + return $result; } @@ -2210,50 +2210,50 @@ function cartesianArray(array $input) */ function getModuleDirForApiClass($moduleobject) { - $moduledirforclass = $moduleobject; - if ($moduledirforclass != 'api') $moduledirforclass = preg_replace('/api$/i', '', $moduledirforclass); + $moduledirforclass = $moduleobject; + if ($moduledirforclass != 'api') $moduledirforclass = preg_replace('/api$/i', '', $moduledirforclass); - if ($moduleobject == 'contracts') { - $moduledirforclass = 'contrat'; - } elseif (in_array($moduleobject, array('admin', 'login', 'setup', 'access', 'status', 'tools', 'documents'))) { - $moduledirforclass = 'api'; - } elseif ($moduleobject == 'contact' || $moduleobject == 'contacts' || $moduleobject == 'customer' || $moduleobject == 'thirdparty' || $moduleobject == 'thirdparties') { - $moduledirforclass = 'societe'; - } elseif ($moduleobject == 'propale' || $moduleobject == 'proposals') { - $moduledirforclass = 'comm/propal'; - } elseif ($moduleobject == 'agenda' || $moduleobject == 'agendaevents') { - $moduledirforclass = 'comm/action'; - } elseif ($moduleobject == 'adherent' || $moduleobject == 'members' || $moduleobject == 'memberstypes' || $moduleobject == 'subscriptions') { - $moduledirforclass = 'adherents'; - } elseif ($moduleobject == 'don' || $moduleobject == 'donations') { - $moduledirforclass = 'don'; - } elseif ($moduleobject == 'banque' || $moduleobject == 'bankaccounts') { - $moduledirforclass = 'compta/bank'; - } elseif ($moduleobject == 'category' || $moduleobject == 'categorie') { - $moduledirforclass = 'categories'; - } elseif ($moduleobject == 'order' || $moduleobject == 'orders') { - $moduledirforclass = 'commande'; - } elseif ($moduleobject == 'shipments') { - $moduledirforclass = 'expedition'; - } elseif ($moduleobject == 'facture' || $moduleobject == 'invoice' || $moduleobject == 'invoices') { - $moduledirforclass = 'compta/facture'; - } elseif ($moduleobject == 'project' || $moduleobject == 'projects' || $moduleobject == 'task' || $moduleobject == 'tasks') { - $moduledirforclass = 'projet'; - } elseif ($moduleobject == 'stock' || $moduleobject == 'stockmovements' || $moduleobject == 'warehouses') { - $moduledirforclass = 'product/stock'; - } elseif ($moduleobject == 'supplierproposals' || $moduleobject == 'supplierproposal' || $moduleobject == 'supplier_proposal') { - $moduledirforclass = 'supplier_proposal'; - } elseif ($moduleobject == 'fournisseur' || $moduleobject == 'supplierinvoices' || $moduleobject == 'supplierorders') { - $moduledirforclass = 'fourn'; - } elseif ($moduleobject == 'ficheinter' || $moduleobject == 'interventions') { - $moduledirforclass = 'fichinter'; - } elseif ($moduleobject == 'mos') { - $moduledirforclass = 'mrp'; - } elseif (in_array($moduleobject, array('products', 'expensereports', 'users', 'tickets', 'boms'))) { - $moduledirforclass = preg_replace('/s$/', '', $moduleobject); - } + if ($moduleobject == 'contracts') { + $moduledirforclass = 'contrat'; + } elseif (in_array($moduleobject, array('admin', 'login', 'setup', 'access', 'status', 'tools', 'documents'))) { + $moduledirforclass = 'api'; + } elseif ($moduleobject == 'contact' || $moduleobject == 'contacts' || $moduleobject == 'customer' || $moduleobject == 'thirdparty' || $moduleobject == 'thirdparties') { + $moduledirforclass = 'societe'; + } elseif ($moduleobject == 'propale' || $moduleobject == 'proposals') { + $moduledirforclass = 'comm/propal'; + } elseif ($moduleobject == 'agenda' || $moduleobject == 'agendaevents') { + $moduledirforclass = 'comm/action'; + } elseif ($moduleobject == 'adherent' || $moduleobject == 'members' || $moduleobject == 'memberstypes' || $moduleobject == 'subscriptions') { + $moduledirforclass = 'adherents'; + } elseif ($moduleobject == 'don' || $moduleobject == 'donations') { + $moduledirforclass = 'don'; + } elseif ($moduleobject == 'banque' || $moduleobject == 'bankaccounts') { + $moduledirforclass = 'compta/bank'; + } elseif ($moduleobject == 'category' || $moduleobject == 'categorie') { + $moduledirforclass = 'categories'; + } elseif ($moduleobject == 'order' || $moduleobject == 'orders') { + $moduledirforclass = 'commande'; + } elseif ($moduleobject == 'shipments') { + $moduledirforclass = 'expedition'; + } elseif ($moduleobject == 'facture' || $moduleobject == 'invoice' || $moduleobject == 'invoices') { + $moduledirforclass = 'compta/facture'; + } elseif ($moduleobject == 'project' || $moduleobject == 'projects' || $moduleobject == 'task' || $moduleobject == 'tasks') { + $moduledirforclass = 'projet'; + } elseif ($moduleobject == 'stock' || $moduleobject == 'stockmovements' || $moduleobject == 'warehouses') { + $moduledirforclass = 'product/stock'; + } elseif ($moduleobject == 'supplierproposals' || $moduleobject == 'supplierproposal' || $moduleobject == 'supplier_proposal') { + $moduledirforclass = 'supplier_proposal'; + } elseif ($moduleobject == 'fournisseur' || $moduleobject == 'supplierinvoices' || $moduleobject == 'supplierorders') { + $moduledirforclass = 'fourn'; + } elseif ($moduleobject == 'ficheinter' || $moduleobject == 'interventions') { + $moduledirforclass = 'fichinter'; + } elseif ($moduleobject == 'mos') { + $moduledirforclass = 'mrp'; + } elseif (in_array($moduleobject, array('products', 'expensereports', 'users', 'tickets', 'boms'))) { + $moduledirforclass = preg_replace('/s$/', '', $moduleobject); + } - return $moduledirforclass; + return $moduledirforclass; } /** @@ -2265,7 +2265,7 @@ function getModuleDirForApiClass($moduleobject) */ function randomColorPart($min = 0, $max = 255) { - return str_pad(dechex(mt_rand($min, $max)), 2, '0', STR_PAD_LEFT); + return str_pad(dechex(mt_rand($min, $max)), 2, '0', STR_PAD_LEFT); } /** @@ -2277,22 +2277,22 @@ function randomColorPart($min = 0, $max = 255) */ function randomColor($min = 0, $max = 255) { - return randomColorPart($min, $max).randomColorPart($min, $max).randomColorPart($min, $max); + return randomColorPart($min, $max).randomColorPart($min, $max).randomColorPart($min, $max); } if (!function_exists('dolEscapeXML')) { - /** - * Encode string for xml usage - * - * @param string $string String to encode - * @return string String encoded - */ - function dolEscapeXML($string) - { - return strtr($string, array('\''=>''', '"'=>'"', '&'=>'&', '<'=>'<', '>'=>'>')); - } + /** + * Encode string for xml usage + * + * @param string $string String to encode + * @return string String encoded + */ + function dolEscapeXML($string) + { + return strtr($string, array('\''=>''', '"'=>'"', '&'=>'&', '<'=>'<', '>'=>'>')); + } } @@ -2306,28 +2306,28 @@ if (!function_exists('dolEscapeXML')) */ function autoOrManual($automaticmanual, $case = 1, $color = 0) { - global $langs; - $result = 'unknown'; $classname = ''; - if ($automaticmanual == 1 || strtolower($automaticmanual) == 'automatic' || strtolower($automaticmanual) == 'true') // A mettre avant test sur no a cause du == 0 - { - $result = $langs->trans('automatic'); - if ($case == 1 || $case == 3) $result = $langs->trans("Automatic"); - if ($case == 2) $result = ''; - if ($case == 3) $result = ' '.$result; + global $langs; + $result = 'unknown'; $classname = ''; + if ($automaticmanual == 1 || strtolower($automaticmanual) == 'automatic' || strtolower($automaticmanual) == 'true') // A mettre avant test sur no a cause du == 0 + { + $result = $langs->trans('automatic'); + if ($case == 1 || $case == 3) $result = $langs->trans("Automatic"); + if ($case == 2) $result = ''; + if ($case == 3) $result = ' '.$result; - $classname = 'ok'; - } elseif ($automaticmanual == 0 || strtolower($automaticmanual) == 'manual' || strtolower($automaticmanual) == 'false') - { - $result = $langs->trans("manual"); - if ($case == 1 || $case == 3) $result = $langs->trans("Manual"); - if ($case == 2) $result = ''; - if ($case == 3) $result = ' '.$result; + $classname = 'ok'; + } elseif ($automaticmanual == 0 || strtolower($automaticmanual) == 'manual' || strtolower($automaticmanual) == 'false') + { + $result = $langs->trans("manual"); + if ($case == 1 || $case == 3) $result = $langs->trans("Manual"); + if ($case == 2) $result = ''; + if ($case == 3) $result = ' '.$result; - if ($color == 2) $classname = 'ok'; - else $classname = 'error'; - } - if ($color) return ''.$result.''; - return $result; + if ($color == 2) $classname = 'ok'; + else $classname = 'error'; + } + if ($color) return ''.$result.''; + return $result; } @@ -2339,13 +2339,13 @@ function autoOrManual($automaticmanual, $case = 1, $color = 0) */ function convertBackOfficeMediasLinksToPublicLinks($notetoshow) { - global $dolibarr_main_url_root; - // Define $urlwithroot - $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $notetoshow = preg_replace('/src="[a-zA-Z0-9_\/\-\.]*(viewimage\.php\?modulepart=medias[^"]*)"/', 'src="'.$urlwithroot.'/\1"', $notetoshow); - return $notetoshow; + global $dolibarr_main_url_root; + // Define $urlwithroot + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + $notetoshow = preg_replace('/src="[a-zA-Z0-9_\/\-\.]*(viewimage\.php\?modulepart=medias[^"]*)"/', 'src="'.$urlwithroot.'/\1"', $notetoshow); + return $notetoshow; } /** diff --git a/htdocs/core/lib/functionsnumtoword.lib.php b/htdocs/core/lib/functionsnumtoword.lib.php index 36d0fb0c80d..ae9401b7954 100644 --- a/htdocs/core/lib/functionsnumtoword.lib.php +++ b/htdocs/core/lib/functionsnumtoword.lib.php @@ -259,7 +259,7 @@ function hundreds2text($hundreds, $tens, $units) $decenas = array("", "", "TREINTA ", "CUARENTA ", "CINCUENTA ", "SESENTA ", "SETENTA ", "OCHENTA ", "NOVENTA "); $veintis = array("VEINTE", "VEINTIUN", "VEINTIDÓS", "VEINTITRÉS", "VEINTICUATRO", "VEINTICINCO", "VEINTISÉIS", "VEINTISIETE", "VEINTIOCHO", "VEINTINUEVE"); $diecis = array("DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", "QUINCE", "DIECISÉIS", "DIECISIETE", "DIECIOCHO", "DIECINUEVE"); - $unidades = array("UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", "OCHO", "NUEVE"); + $unidades = array("UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", "OCHO", "NUEVE"); $entexto = ""; if ($hundreds != 0) { $entexto .= $centenas[$hundreds - 1]; diff --git a/htdocs/core/lib/hrm.lib.php b/htdocs/core/lib/hrm.lib.php index 1ea359f6f0b..e24c503f449 100644 --- a/htdocs/core/lib/hrm.lib.php +++ b/htdocs/core/lib/hrm.lib.php @@ -43,8 +43,8 @@ function establishment_prepare_head($object) // Show more tabs from modules // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'establishment'); $head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/info.php?id='.$object->id; @@ -64,30 +64,30 @@ function establishment_prepare_head($object) */ function hrm_admin_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf, $user; - $langs->load('hrm'); + $langs->load('hrm'); - $h = 0; - $head = array(); + $h = 0; + $head = array(); $head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_hrm.php'; - $head[$h][1] = $langs->trans("Parameters"); - $head[$h][2] = 'parameters'; - $h++; + $head[$h][1] = $langs->trans("Parameters"); + $head[$h][2] = 'parameters'; + $h++; $head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_establishment.php'; - $head[$h][1] = $langs->trans("Establishments"); - $head[$h][2] = 'establishments'; - $h++; + $head[$h][1] = $langs->trans("Establishments"); + $head[$h][2] = 'establishments'; + $h++; - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab - complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin'); - complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin', 'remove'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin', 'remove'); - return $head; + return $head; } diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 4cca58d5c2a..20a97c7ff90 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -40,39 +40,39 @@ function image_format_supported($file, $acceptsvg = 0) { global $conf; - $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php - if ($acceptsvg || ! empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) { - $regeximgext .= '|\.svg'; // Not allowed by default. SVG can contains javascript - } + $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php + if ($acceptsvg || ! empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) { + $regeximgext .= '|\.svg'; // Not allowed by default. SVG can contains javascript + } - // Case filename is not a format image - $reg = array(); - if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1; + // Case filename is not a format image + $reg = array(); + if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1; - // Case filename is a format image but not supported by this PHP - $imgfonction = ''; - if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif'; - if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg'; - if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg'; - if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng'; - if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp'; - if (strtolower($reg[1]) == '.webp') $imgfonction = 'imagecreatefromwebp'; - if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm'; - if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm'; - if (strtolower($reg[1]) == '.svg') $imgfonction = 'imagecreatefromsvg'; // Never available - if ($imgfonction) - { - if (!function_exists($imgfonction)) - { - // Fonctions of conversion not available in this PHP - return 0; - } + // Case filename is a format image but not supported by this PHP + $imgfonction = ''; + if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif'; + if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg'; + if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg'; + if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng'; + if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp'; + if (strtolower($reg[1]) == '.webp') $imgfonction = 'imagecreatefromwebp'; + if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm'; + if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm'; + if (strtolower($reg[1]) == '.svg') $imgfonction = 'imagecreatefromsvg'; // Never available + if ($imgfonction) + { + if (!function_exists($imgfonction)) + { + // Fonctions of conversion not available in this PHP + return 0; + } - // Filename is a format image and supported for conversion by this PHP - return 1; - } + // Filename is a format image and supported for conversion by this PHP + return 1; + } - return 0; + return 0; } @@ -97,9 +97,9 @@ function dol_getImageSize($file, $url = false) if ($filetoread) { - $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image - $ret['width'] = $infoImg[0]; // Largeur de l'image - $ret['height'] = $infoImg[1]; // Hauteur de l'image + $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image + $ret['width'] = $infoImg[0]; // Largeur de l'image + $ret['height'] = $infoImg[1]; // Hauteur de l'image } return $ret; @@ -305,7 +305,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); // Free memory. This does not delete image. - imagedestroy($img); + imagedestroy($img); imagedestroy($imgThumb); clearstatcache(); // File was replaced by a modified one, so we clear file caches. @@ -441,20 +441,20 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } elseif (!file_exists($file)) { // Si le fichier passe en parametre n'existe pas - dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR); - return $langs->trans("ErrorFileNotFound", $file); + dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR); + return $langs->trans("ErrorFileNotFound", $file); } elseif (image_format_supported($file) < 0) { - dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING); - return 'ErrorBadImageFormat'; + dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING); + return 'ErrorBadImageFormat'; } elseif (!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) { // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) - dol_syslog('Wrong value for parameter maxWidth', LOG_ERR); - return 'Error: Wrong value for parameter maxWidth'; + dol_syslog('Wrong value for parameter maxWidth', LOG_ERR); + return 'Error: Wrong value for parameter maxWidth'; } elseif (!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) { // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) - dol_syslog('Wrong value for parameter maxHeight', LOG_ERR); - return 'Error: Wrong value for parameter maxHeight'; + dol_syslog('Wrong value for parameter maxHeight', LOG_ERR); + return 'Error: Wrong value for parameter maxHeight'; } $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image @@ -495,7 +495,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $imgfonction = 'imagecreatefrompng'; break; case IMAGETYPE_BMP: // 6 - // Not supported by PHP GD + // Not supported by PHP GD break; case IMAGETYPE_WBMP: // 15 $imgfonction = 'imagecreatefromwbmp'; @@ -531,7 +531,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $extImg = '.png'; break; case IMAGETYPE_BMP: // 6 - // Not supported by PHP GD + // Not supported by PHP GD $extImg = '.bmp'; break; case IMAGETYPE_WBMP: // 15 @@ -540,14 +540,14 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', break; } - if (!is_resource($img)) - { - dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING); - return 0; - } + if (!is_resource($img)) + { + dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING); + return 0; + } $exifAngle = false; - if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) { + if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) { switch ($ort) { case 3: // 180 rotate left @@ -568,12 +568,12 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } } - if ($exifAngle) - { + if ($exifAngle) + { $rotated = false; - if ($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case - { + if ($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case + { imagealphablending($img, false); imagesavealpha($img, true); $rotated = imagerotate($img, $exifAngle, imageColorAllocateAlpha($img, 0, 0, 0, 127)); @@ -583,9 +583,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $rotated = imagerotate($img, $exifAngle, 0); } - // replace image with good orientation - if (!empty($rotated)) { - $img = $rotated; + // replace image with good orientation + if (!empty($rotated)) { + $img = $rotated; $imgWidth = $trueImgWidth; $imgHeight = $trueImgHeight; } @@ -612,8 +612,8 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $thumbHeight = round($thumbHeight); $thumbWidth = round($thumbWidth); - // Define target format - if (empty($targetformat)) $targetformat = $infoImg[2]; + // Define target format + if (empty($targetformat)) $targetformat = $infoImg[2]; // Create empty image if ($targetformat == IMAGETYPE_GIF) @@ -643,31 +643,31 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', case IMAGETYPE_GIF: // 1 $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF imagecolortransparent($imgThumb, $trans_colour); - $extImgTarget = '.gif'; - $newquality = 'NU'; - break; + $extImgTarget = '.gif'; + $newquality = 'NU'; + break; case IMAGETYPE_JPEG: // 2 - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); - $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '.jpg'); - $newquality = $quality; - break; + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); + $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '.jpg'); + $newquality = $quality; + break; case IMAGETYPE_PNG: // 3 imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel - $extImgTarget = '.png'; - $newquality = $quality - 100; - $newquality = round(abs($quality - 100) * 9 / 100); - break; + $extImgTarget = '.png'; + $newquality = $quality - 100; + $newquality = round(abs($quality - 100) * 9 / 100); + break; case IMAGETYPE_BMP: // 6 - // Not supported by PHP GD - $extImgTarget = '.bmp'; - $newquality = 'NU'; - break; + // Not supported by PHP GD + $extImgTarget = '.bmp'; + $newquality = 'NU'; + break; case IMAGETYPE_WBMP: // 15 $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); - $extImgTarget = '.bmp'; - $newquality = 'NU'; - break; + $extImgTarget = '.bmp'; + $newquality = 'NU'; + break; } if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); @@ -698,7 +698,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', imagepng($imgThumb, $imgThumbName, $newquality); break; case IMAGETYPE_BMP: // 6 - // Not supported by PHP GD + // Not supported by PHP GD break; case IMAGETYPE_WBMP: // 15 imagewbmp($imgThumb, $imgThumbName); @@ -708,9 +708,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', // Set permissions on file if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); - // Free memory. This does not delete image. - imagedestroy($img); - imagedestroy($imgThumb); + // Free memory. This does not delete image. + imagedestroy($img); + imagedestroy($imgThumb); return $imgThumbName; } diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index a59aa3e6301..50330686805 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -63,46 +63,46 @@ function member_prepare_head(Adherent $object) $h++; } - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'member'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'member'); - $nbNote = 0; - if (!empty($object->note)) $nbNote++; - if (!empty($object->note_private)) $nbNote++; - if (!empty($object->note_public)) $nbNote++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id; + $nbNote = 0; + if (!empty($object->note)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Note"); $head[$h][2] = 'note'; - if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $h++; - // Attachments - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member'); - $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id; - $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; - $head[$h][2] = 'document'; - $h++; + // Attachments + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member'); + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); + $nbLinks = Link::count($db, $object->element, $object->id); + $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; + $head[$h][2] = 'document'; + $h++; // Show agenda tab if (!empty($conf->agenda->enabled)) { - $head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id; - $head[$h][1] = $langs->trans("Events"); - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) - { - $head[$h][1] .= '/'; - $head[$h][1] .= $langs->trans("Agenda"); - } - $head[$h][2] = 'agenda'; - $h++; + $head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id; + $head[$h][1] = $langs->trans("Events"); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) + { + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); + } + $head[$h][2] = 'agenda'; + $h++; } complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'remove'); @@ -148,11 +148,11 @@ function member_type_prepare_head(AdherentType $object) $h++; } - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype', 'remove'); @@ -166,45 +166,45 @@ function member_type_prepare_head(AdherentType $object) */ function member_admin_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf, $user; - $h = 0; - $head = array(); + $h = 0; + $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent.php'; - $head[$h][1] = $langs->trans("Miscellaneous"); - $head[$h][2] = 'general'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent.php'; + $head[$h][1] = $langs->trans("Miscellaneous"); + $head[$h][2] = 'general'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_emails.php'; - $head[$h][1] = $langs->trans("EMails"); - $head[$h][2] = 'emails'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_emails.php'; + $head[$h][1] = $langs->trans("EMails"); + $head[$h][2] = 'emails'; + $h++; - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab - complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin'); - $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFieldsMember"); - $head[$h][2] = 'attributes'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsMember"); + $head[$h][2] = 'attributes'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_type_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFieldsMemberType"); - $head[$h][2] = 'attributes_type'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_type_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsMemberType"); + $head[$h][2] = 'attributes_type'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php'; - $head[$h][1] = $langs->trans("BlankSubscriptionForm"); - $head[$h][2] = 'website'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php'; + $head[$h][1] = $langs->trans("BlankSubscriptionForm"); + $head[$h][2] = 'website'; + $h++; - complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin', 'remove'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin', 'remove'); - return $head; + return $head; } @@ -216,50 +216,50 @@ function member_admin_prepare_head() */ function member_stats_prepare_head($object) { - global $langs, $conf, $user; + global $langs, $conf, $user; - $h = 0; - $head = array(); + $h = 0; + $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php'; - $head[$h][1] = $langs->trans("Subscriptions"); - $head[$h][2] = 'statssubscription'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php'; + $head[$h][1] = $langs->trans("Subscriptions"); + $head[$h][2] = 'statssubscription'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry'; - $head[$h][1] = $langs->trans("Country"); - $head[$h][2] = 'statscountry'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry'; + $head[$h][1] = $langs->trans("Country"); + $head[$h][2] = 'statscountry'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion'; - $head[$h][1] = $langs->trans("Region"); - $head[$h][2] = 'statsregion'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion'; + $head[$h][1] = $langs->trans("Region"); + $head[$h][2] = 'statsregion'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate'; - $head[$h][1] = $langs->trans("State"); - $head[$h][2] = 'statsstate'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate'; + $head[$h][1] = $langs->trans("State"); + $head[$h][2] = 'statsstate'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown'; - $head[$h][1] = $langs->trans('Town'); - $head[$h][2] = 'statstown'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown'; + $head[$h][1] = $langs->trans('Town'); + $head[$h][2] = 'statstown'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php'; - $head[$h][1] = $langs->trans('ByProperties'); - $head[$h][2] = 'statsbyproperties'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php'; + $head[$h][1] = $langs->trans('ByProperties'); + $head[$h][2] = 'statsbyproperties'; + $h++; - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats'); - complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove'); - return $head; + return $head; } /** diff --git a/htdocs/core/lib/multicurrency.lib.php b/htdocs/core/lib/multicurrency.lib.php index 94947e5c4b4..065b4dfc886 100644 --- a/htdocs/core/lib/multicurrency.lib.php +++ b/htdocs/core/lib/multicurrency.lib.php @@ -30,21 +30,21 @@ */ function multicurrencyAdminPrepareHead() { - global $langs, $conf; + global $langs, $conf; - $h = 0; - $head = array(); + $h = 0; + $head = array(); - $head[$h][0] = dol_buildpath("/admin/multicurrency.php", 1); - $head[$h][1] = $langs->trans("Parameters"); - $head[$h][2] = 'settings'; - $h++; + $head[$h][0] = dol_buildpath("/admin/multicurrency.php", 1); + $head[$h][1] = $langs->trans("Parameters"); + $head[$h][2] = 'settings'; + $h++; - complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency'); complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency', 'remove'); - return $head; + return $head; } /** diff --git a/htdocs/core/lib/reception.lib.php b/htdocs/core/lib/reception.lib.php index caa08228803..f36295e31f3 100644 --- a/htdocs/core/lib/reception.lib.php +++ b/htdocs/core/lib/reception.lib.php @@ -49,18 +49,18 @@ function reception_prepare_head(Reception $object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $objectsrc = $object; - if ($object->origin == 'commande' && $object->origin_id > 0) - { - $objectsrc = new Commande($db); - $objectsrc->fetch($object->origin_id); - } - $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); - $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id; - $head[$h][1] = $langs->trans("ContactsAddresses"); + $objectsrc = $object; + if ($object->origin == 'commande' && $object->origin_id > 0) + { + $objectsrc = new Commande($db); + $objectsrc->fetch($object->origin_id); + } + $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); + $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id; + $head[$h][1] = $langs->trans("ContactsAddresses"); if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; - $head[$h][2] = 'contact'; - $h++; + $head[$h][2] = 'contact'; + $h++; } // Show more tabs from modules @@ -69,18 +69,18 @@ function reception_prepare_head(Reception $object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception'); - $nbNote = 0; - if (!empty($object->note_private)) $nbNote++; - if (!empty($object->note_public)) $nbNote++; + $nbNote = 0; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id; $head[$h][1] = $langs->trans("Notes"); if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; - complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'remove'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'remove'); - return $head; + return $head; } /** @@ -105,18 +105,18 @@ function reception_admin_prepare_head() if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) { - $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFields"); - $head[$h][2] = 'attributes_reception'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][2] = 'attributes_reception'; + $h++; } if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) { - $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFieldsLines"); - $head[$h][2] = 'attributeslines_reception'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsLines"); + $head[$h][2] = 'attributeslines_reception'; + $h++; } complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin', 'remove'); diff --git a/htdocs/core/lib/resource.lib.php b/htdocs/core/lib/resource.lib.php index 3222c1c5768..a4ba796078f 100644 --- a/htdocs/core/lib/resource.lib.php +++ b/htdocs/core/lib/resource.lib.php @@ -37,13 +37,13 @@ function resource_prepare_head($object) $head[$h][0] = dol_buildpath('/resource/card.php', 1).'?id='.$object->id; $head[$h][1] = $langs->trans("ResourceCard"); - $head[$h][2] = 'resource'; + $head[$h][2] = 'resource'; $h++; if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && (empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER) || empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY))) { - $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); - $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id; + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); + $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; diff --git a/htdocs/core/lib/salaries.lib.php b/htdocs/core/lib/salaries.lib.php index a3df043d4c4..c11e37b7aaa 100644 --- a/htdocs/core/lib/salaries.lib.php +++ b/htdocs/core/lib/salaries.lib.php @@ -27,41 +27,41 @@ */ function salaries_prepare_head($object) { - global $db, $langs, $conf; + global $db, $langs, $conf; - $h = 0; - $head = array(); + $h = 0; + $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id; - $head[$h][1] = $langs->trans("SalaryPayment"); - $head[$h][2] = 'card'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id; + $head[$h][1] = $langs->trans("SalaryPayment"); + $head[$h][2] = 'card'; + $h++; - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries'); - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref); - $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id; - $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; - $head[$h][2] = 'documents'; - $h++; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); + $nbLinks = Link::count($db, $object->element, $object->id); + $head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; + $head[$h][2] = 'documents'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id; - $head[$h][1] = $langs->trans("Info"); - $head[$h][2] = 'info'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; - complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove'); - return $head; + return $head; } /** @@ -71,28 +71,28 @@ function salaries_prepare_head($object) */ function salaries_admin_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf, $user; - $h = 0; - $head = array(); + $h = 0; + $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php'; - $head[$h][1] = $langs->trans("Miscellaneous"); - $head[$h][2] = 'general'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php'; + $head[$h][1] = $langs->trans("Miscellaneous"); + $head[$h][2] = 'general'; + $h++; - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab - complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin'); - $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFieldsSalaries"); - $head[$h][2] = 'attributes'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsSalaries"); + $head[$h][2] = 'attributes'; + $h++; - complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin', 'remove'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin', 'remove'); - return $head; + return $head; } diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 9a36c0bb269..d4bb4584e26 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -309,7 +309,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f break; } } - } elseif (!empty($feature)) { // This is for permissions on 2 levels ('creer' or 'write') + } elseif (!empty($feature)) { // This is for permissions on 2 levels ('creer' or 'write') //print '
feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; exit; if (empty($user->rights->$feature->creer) && empty($user->rights->$feature->write) @@ -541,7 +541,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand if ($feature == 'agenda')// Also check owner or attendee for users without allactions->read { if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) { - require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $action = new ActionComm($db); $action->fetch($objectid); if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) { diff --git a/htdocs/core/lib/takepos.lib.php b/htdocs/core/lib/takepos.lib.php index a651e1d76e0..dfddc95d733 100644 --- a/htdocs/core/lib/takepos.lib.php +++ b/htdocs/core/lib/takepos.lib.php @@ -71,5 +71,5 @@ function takepos_admin_prepare_head() complete_head_from_modules($conf, $langs, null, $head, $h, 'takepos_admin', 'remove'); - return $head; + return $head; } diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index d47bfb2cab2..5558274710f 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -30,41 +30,41 @@ */ function ticketAdminPrepareHead() { - global $langs, $conf; + global $langs, $conf; - $langs->load("ticket"); + $langs->load("ticket"); - $h = 0; - $head = array(); + $h = 0; + $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/admin/ticket.php'; - $head[$h][1] = $langs->trans("TicketSettings"); - $head[$h][2] = 'settings'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/ticket.php'; + $head[$h][1] = $langs->trans("TicketSettings"); + $head[$h][2] = 'settings'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/admin/ticket_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFieldsTicket"); - $head[$h][2] = 'attributes'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/ticket_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsTicket"); + $head[$h][2] = 'attributes'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/admin/ticket_public.php'; - $head[$h][1] = $langs->trans("PublicInterface"); - $head[$h][2] = 'public'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/ticket_public.php'; + $head[$h][1] = $langs->trans("PublicInterface"); + $head[$h][2] = 'public'; + $h++; - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - //$this->tabs = array( - // 'entity:+tabname:Title:@ticket:/ticket/mypage.php?id=__ID__' - //); // to add new tab - //$this->tabs = array( - // 'entity:-tabname:Title:@ticket:/ticket/mypage.php?id=__ID__' - //); // to remove a tab - complete_head_from_modules($conf, $langs, null, $head, $h, 'ticketadmin'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@ticket:/ticket/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@ticket:/ticket/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, null, $head, $h, 'ticketadmin'); complete_head_from_modules($conf, $langs, null, $head, $h, 'ticketadmin', 'remove'); - return $head; + return $head; } /** @@ -75,42 +75,42 @@ function ticketAdminPrepareHead() */ function ticket_prepare_head($object) { - global $db, $langs, $conf, $user; + global $db, $langs, $conf, $user; - $h = 0; - $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id='.$object->track_id; - $head[$h][1] = $langs->trans("Ticket"); - $head[$h][2] = 'tabTicket'; - $h++; + $h = 0; + $head = array(); + $head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id='.$object->track_id; + $head[$h][1] = $langs->trans("Ticket"); + $head[$h][2] = 'tabTicket'; + $h++; - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid)) - { - $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); - $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; - $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; - $head[$h][2] = 'contact'; - $h++; - } + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid)) + { + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); + $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; + $head[$h][2] = 'contact'; + $h++; + } - complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket'); - // Attached files - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $upload_dir = $conf->ticket->dir_output."/".$object->ref; - $nbFiles = count(dol_dir_list($upload_dir, 'files')); - $head[$h][0] = dol_buildpath('/ticket/document.php', 1).'?id='.$object->id; - $head[$h][1] = $langs->trans("Documents"); - if ($nbFiles > 0) { - $head[$h][1] .= ''.$nbFiles.''; - } + // Attached files + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $upload_dir = $conf->ticket->dir_output."/".$object->ref; + $nbFiles = count(dol_dir_list($upload_dir, 'files')); + $head[$h][0] = dol_buildpath('/ticket/document.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Documents"); + if ($nbFiles > 0) { + $head[$h][1] .= ''.$nbFiles.''; + } - $head[$h][2] = 'tabTicketDocument'; - $h++; + $head[$h][2] = 'tabTicketDocument'; + $h++; - // History + // History $ticketViewType = "messaging"; if (empty($_SESSION['ticket-view-type'])) { $_SESSION['ticket-view-type'] = $ticketViewType; @@ -124,20 +124,20 @@ function ticket_prepare_head($object) // $ticketViewType == "list" $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id; } - $head[$h][1] = $langs->trans('Events'); - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) - { - $head[$h][1] .= '/'; - $head[$h][1] .= $langs->trans("Agenda"); - } - $head[$h][2] = 'tabTicketLogs'; - $h++; + $head[$h][1] = $langs->trans('Events'); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) + { + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); + } + $head[$h][2] = 'tabTicketLogs'; + $h++; - complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket', 'remove'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket', 'remove'); - return $head; + return $head; } /** @@ -184,13 +184,13 @@ function showDirectPublicLink($object) */ function generate_random_id($car = 16) { - $string = ""; - $chaine = "abcdefghijklmnopqrstuvwxyz123456789"; - srand((double) microtime() * 1000000); - for ($i = 0; $i < $car; $i++) { - $string .= $chaine[rand() % strlen($chaine)]; - } - return $string; + $string = ""; + $chaine = "abcdefghijklmnopqrstuvwxyz123456789"; + srand((double) microtime() * 1000000); + for ($i = 0; $i < $car; $i++) { + $string .= $chaine[rand() % strlen($chaine)]; + } + return $string; } /** @@ -277,255 +277,255 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $ */ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC') { - global $user, $conf; - global $form; + global $user, $conf; + global $form; - global $param, $massactionbutton; + global $param, $massactionbutton; - dol_include_once('/comm/action/class/actioncomm.class.php'); + dol_include_once('/comm/action/class/actioncomm.class.php'); - // Check parameters - if (!is_object($filterobj) && !is_object($objcon)) dol_print_error('', 'BadParameter'); + // Check parameters + if (!is_object($filterobj) && !is_object($objcon)) dol_print_error('', 'BadParameter'); - $out = ''; - $histo = array(); - $numaction = 0; - $now = dol_now('tzuser'); + $out = ''; + $histo = array(); + $numaction = 0; + $now = dol_now('tzuser'); - // Open DSI -- Fix order by -- Begin - $sortfield_list = explode(',', $sortfield); - $sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent'); - $sortfield_new_list = array(); - foreach ($sortfield_list as $sortfield_value) { - $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)]; - } - $sortfield_new = implode(',', $sortfield_new_list); + // Open DSI -- Fix order by -- Begin + $sortfield_list = explode(',', $sortfield); + $sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent'); + $sortfield_new_list = array(); + foreach ($sortfield_list as $sortfield_value) { + $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)]; + } + $sortfield_new = implode(',', $sortfield_new_list); - if (!empty($conf->agenda->enabled)) - { - // Recherche histo sur actioncomm - if (is_object($objcon) && $objcon->id > 0) { - $sql = "SELECT DISTINCT a.id, a.label as label,"; - } else { - $sql = "SELECT a.id, a.label as label,"; - } - $sql .= " a.datep as dp,"; - $sql .= " a.note as message,"; - $sql .= " a.datep2 as dp2,"; - $sql .= " a.percent as percent, 'action' as type,"; - $sql .= " a.fk_element, a.elementtype,"; - $sql .= " a.fk_contact,"; - $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; - $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= ", sp.lastname, sp.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", m.lastname, m.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref"; - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; + if (!empty($conf->agenda->enabled)) + { + // Recherche histo sur actioncomm + if (is_object($objcon) && $objcon->id > 0) { + $sql = "SELECT DISTINCT a.id, a.label as label,"; + } else { + $sql = "SELECT a.id, a.label as label,"; + } + $sql .= " a.datep as dp,"; + $sql .= " a.note as message,"; + $sql .= " a.datep2 as dp2,"; + $sql .= " a.percent as percent, 'action' as type,"; + $sql .= " a.fk_element, a.elementtype,"; + $sql .= " a.fk_contact,"; + $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; + $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= ", sp.lastname, sp.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", m.lastname, m.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; - $force_filter_contact = false; - if (is_object($objcon) && $objcon->id > 0) { - $force_filter_contact = true; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; - $sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".$objcon->id; - } + $force_filter_contact = false; + if (is_object($objcon) && $objcon->id > 0) { + $force_filter_contact = true; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; + $sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".$objcon->id; + } - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; - $sql .= " ON er.resource_type = 'dolresource'"; - $sql .= " AND er.element_id = a.id"; - $sql .= " AND er.resource_id = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", ".MAIN_DB_PREFIX."product as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " ON er.resource_type = 'dolresource'"; + $sql .= " AND er.element_id = a.id"; + $sql .= " AND er.resource_id = ".$filterobj->id; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", ".MAIN_DB_PREFIX."product as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o"; - $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; - if ($force_filter_contact === false) { - if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id; - elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') - { - $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') - { - $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') - { - $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') - { - $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') - { - $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') - { - $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; - if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; - } - } + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; + if ($force_filter_contact === false) { + if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id; + elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') + { + $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') + { + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') + { + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') + { + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') + { + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') + { + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; + } + } - // Condition on actioncode - if (!empty($actioncode)) - { - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; - else { - if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; - } - } else { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; - else $sql .= " AND c.code = '".$db->escape($actioncode)."'"; - } - } - if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); - } + // Condition on actioncode + if (!empty($actioncode)) + { + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; + else { + if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; + } + } else { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; + else $sql .= " AND c.code = '".$db->escape($actioncode)."'"; + } + } + if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); + } - // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. - if (!empty($conf->mailing->enabled) && !empty($objcon->email) - && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) - { - $langs->load("mails"); + // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. + if (!empty($conf->mailing->enabled) && !empty($objcon->email) + && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) + { + $langs->load("mails"); - $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; - $sql2 .= ", null as fk_element, '' as elementtype, null as contact_id"; - $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; - $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref"; - $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; - $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. - $sql2 .= " AND mc.statut = 1"; - $sql2 .= " AND u.rowid = m.fk_user_valid"; - $sql2 .= " AND mc.fk_mailing=m.rowid"; - } + $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; + $sql2 .= ", null as fk_element, '' as elementtype, null as contact_id"; + $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; + $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; + $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. + $sql2 .= " AND mc.statut = 1"; + $sql2 .= " AND u.rowid = m.fk_user_valid"; + $sql2 .= " AND mc.fk_mailing=m.rowid"; + } - if (!empty($sql) && !empty($sql2)) { - $sql = $sql." UNION ".$sql2; - } elseif (empty($sql) && !empty($sql2)) { - $sql = $sql2; - } + if (!empty($sql) && !empty($sql2)) { + $sql = $sql." UNION ".$sql2; + } elseif (empty($sql) && !empty($sql2)) { + $sql = $sql2; + } - //TODO Add limit in nb of results - $sql .= $db->order($sortfield_new, $sortorder); - dol_syslog("company.lib::show_actions_done", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $i = 0; - $num = $db->num_rows($resql); + //TODO Add limit in nb of results + $sql .= $db->order($sortfield_new, $sortorder); + dol_syslog("company.lib::show_actions_done", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - if ($obj->type == 'action') { - $contactaction = new ActionComm($db); - $contactaction->id = $obj->id; - $result = $contactaction->fetchResources(); - if ($result < 0) { - dol_print_error($db); - setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); - } + if ($obj->type == 'action') { + $contactaction = new ActionComm($db); + $contactaction->id = $obj->id; + $result = $contactaction->fetchResources(); + if ($result < 0) { + dol_print_error($db); + setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); + } - //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - $tododone = ''; - if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo'; + //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + $tododone = ''; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo'; - $histo[$numaction] = array( - 'type'=>$obj->type, - 'tododone'=>$tododone, - 'id'=>$obj->id, - 'datestart'=>$db->jdate($obj->dp), - 'dateend'=>$db->jdate($obj->dp2), - 'note'=>$obj->label, - 'message'=>$obj->message, - 'percent'=>$obj->percent, + $histo[$numaction] = array( + 'type'=>$obj->type, + 'tododone'=>$tododone, + 'id'=>$obj->id, + 'datestart'=>$db->jdate($obj->dp), + 'dateend'=>$db->jdate($obj->dp2), + 'note'=>$obj->label, + 'message'=>$obj->message, + 'percent'=>$obj->percent, - 'userid'=>$obj->user_id, - 'login'=>$obj->user_login, - 'userfirstname'=>$obj->user_firstname, - 'userlastname'=>$obj->user_lastname, - 'userphoto'=>$obj->user_photo, + 'userid'=>$obj->user_id, + 'login'=>$obj->user_login, + 'userfirstname'=>$obj->user_firstname, + 'userlastname'=>$obj->user_lastname, + 'userphoto'=>$obj->user_photo, - 'contact_id'=>$obj->fk_contact, - 'socpeopleassigned' => $contactaction->socpeopleassigned, - 'lastname'=>$obj->lastname, - 'firstname'=>$obj->firstname, - 'fk_element'=>$obj->fk_element, - 'elementtype'=>$obj->elementtype, - // Type of event - 'acode'=>$obj->acode, - 'alabel'=>$obj->alabel, - 'libelle'=>$obj->alabel, // deprecated - 'apicto'=>$obj->apicto - ); - } else { - $histo[$numaction] = array( - 'type'=>$obj->type, - 'tododone'=>'done', - 'id'=>$obj->id, - 'datestart'=>$db->jdate($obj->dp), - 'dateend'=>$db->jdate($obj->dp2), - 'note'=>$obj->label, - 'message'=>$obj->message, - 'percent'=>$obj->percent, - 'acode'=>$obj->acode, + 'contact_id'=>$obj->fk_contact, + 'socpeopleassigned' => $contactaction->socpeopleassigned, + 'lastname'=>$obj->lastname, + 'firstname'=>$obj->firstname, + 'fk_element'=>$obj->fk_element, + 'elementtype'=>$obj->elementtype, + // Type of event + 'acode'=>$obj->acode, + 'alabel'=>$obj->alabel, + 'libelle'=>$obj->alabel, // deprecated + 'apicto'=>$obj->apicto + ); + } else { + $histo[$numaction] = array( + 'type'=>$obj->type, + 'tododone'=>'done', + 'id'=>$obj->id, + 'datestart'=>$db->jdate($obj->dp), + 'dateend'=>$db->jdate($obj->dp2), + 'note'=>$obj->label, + 'message'=>$obj->message, + 'percent'=>$obj->percent, + 'acode'=>$obj->acode, - 'userid'=>$obj->user_id, - 'login'=>$obj->user_login, - 'userfirstname'=>$obj->user_firstname, - 'userlastname'=>$obj->user_lastname, - 'userphoto'=>$obj->user_photo - ); - } + 'userid'=>$obj->user_id, + 'login'=>$obj->user_login, + 'userfirstname'=>$obj->user_firstname, + 'userlastname'=>$obj->user_lastname, + 'userphoto'=>$obj->user_photo + ); + } - $numaction++; - $i++; - } - } else { - dol_print_error($db); - } + $numaction++; + $i++; + } + } else { + dol_print_error($db); + } - if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) - { - $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; + if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) + { + $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $formactions = new FormActions($db); + $formactions = new FormActions($db); - $actionstatic = new ActionComm($db); - $userstatic = new User($db); - $contactstatic = new Contact($db); - $userGetNomUrlCache = array(); + $actionstatic = new ActionComm($db); + $userstatic = new User($db); + $contactstatic = new Contact($db); + $userGetNomUrlCache = array(); $out .= '
'; $out .= '
'; @@ -571,108 +571,108 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $out .= ''; - $out .= '
'; + $out .= ''; $out .= '
'; - $out .= "\n"; + $out .= "\n"; - $out .= '
\n"; + } - if ($noprint) return $out; - else print $out; + if ($noprint) return $out; + else print $out; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f70fdf03d1b..b7e67a14f0b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -56,19 +56,19 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = if (empty($noout)) print_start_menu_array(); - $usemenuhider = 1; + $usemenuhider = 1; // Show/Hide vertical menu. The hamburger icon for .menuhider action. if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $showmode = 1; - $classname = 'class="tmenu menuhider"'; - $idsel = 'menu'; + $showmode = 1; + $classname = 'class="tmenu menuhider"'; + $idsel = 'menu'; - $menu->add('#', (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? '' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); + $menu->add('#', (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? '' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } - $menu_arr = array(); + $menu_arr = array(); // Home $menu_arr[] = array( @@ -92,9 +92,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Members $tmpentry = array( - 'enabled' => (!empty($conf->adherent->enabled)), - 'perms' => (!empty($user->rights->adherent->lire)), - 'module' => 'adherent' + 'enabled' => (!empty($conf->adherent->enabled)), + 'perms' => (!empty($user->rights->adherent->lire)), + 'module' => 'adherent' ); $menu_arr[] = array( 'name' => 'Members', @@ -117,13 +117,13 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Third parties $tmpentry = array( - 'enabled'=> ((!empty($conf->societe->enabled) && - (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - ) - || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) - ), - 'perms'=> (!empty($user->rights->societe->lire) || !empty($user->rights->fournisseur->lire)), - 'module'=>'societe|fournisseur' + 'enabled'=> ((!empty($conf->societe->enabled) && + (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + ) + || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) + ), + 'perms'=> (!empty($user->rights->societe->lire) || !empty($user->rights->fournisseur->lire)), + 'module'=>'societe|fournisseur' ); $menu_arr[] = array( 'name' => 'Companies', @@ -148,7 +148,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $tmpentry = array( 'enabled'=> (!empty($conf->product->enabled) || !empty($conf->service->enabled) || !empty($conf->expedition->enabled)), 'perms'=> (!empty($user->rights->produit->lire) || !empty($user->rights->service->lire) || !empty($user->rights->expedition->lire)), - 'module'=>'product|service' + 'module'=>'product|service' ); $menu_arr[] = array( 'name' => 'Products', @@ -157,7 +157,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ? (array("TMenuProducts", " | ", "TMenuServices")) : (!empty($conf->product->enabled) ? "TMenuProducts" : "TMenuServices"), 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "products", 'leftmenu' => '', @@ -173,34 +173,34 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // MRP $tmpentry = array( - 'enabled'=>(!empty($conf->bom->enabled) || !empty($conf->mrp->enabled)), - 'perms'=>(!empty($user->rights->bom->read) || !empty($user->rights->mrp->read)), - 'module'=>'bom|mrp' + 'enabled'=>(!empty($conf->bom->enabled) || !empty($conf->mrp->enabled)), + 'perms'=>(!empty($user->rights->bom->read) || !empty($user->rights->mrp->read)), + 'module'=>'bom|mrp' ); $menu_arr[] = array( - 'name' => 'TMenuMRP', - 'link' => '/mrp/index.php?mainmenu=mrp&leftmenu=', - 'title' => "TMenuMRP", - 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), - 'target' => $atarget, - 'mainmenu' => "mrp", - 'leftmenu' => '', - 'position' => 30, - 'id' => $id, - 'idsel' => 'mrp', - 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "mrp") ? 'class="tmenusel"' : 'class="tmenu"', - 'prefix' => '', - 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "mrp") ? 0 : 1), - 'loadLangs' => array("mrp"), - 'submenus' => array(), + 'name' => 'TMenuMRP', + 'link' => '/mrp/index.php?mainmenu=mrp&leftmenu=', + 'title' => "TMenuMRP", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), + 'target' => $atarget, + 'mainmenu' => "mrp", + 'leftmenu' => '', + 'position' => 30, + 'id' => $id, + 'idsel' => 'mrp', + 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "mrp") ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "mrp") ? 0 : 1), + 'loadLangs' => array("mrp"), + 'submenus' => array(), ); // Projects $tmpentry = array( - 'enabled'=> (!empty($conf->projet->enabled) ? 1 : 0), - 'perms'=> (!empty($user->rights->projet->lire) ? 1 : 0), - 'module'=>'projet' + 'enabled'=> (!empty($conf->projet->enabled) ? 1 : 0), + 'perms'=> (!empty($user->rights->projet->lire) ? 1 : 0), + 'module'=>'projet' ); $menu_arr[] = array( 'name' => 'Projet', @@ -209,7 +209,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ? (($conf->global->PROJECT_USE_OPPORTUNITIES == 2) ? "Leads" : "Projects") : "Projects", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "project", 'leftmenu' => '', @@ -225,14 +225,14 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Commercial $tmpentry = array( - 'enabled'=>(!empty($conf->propal->enabled) || - !empty($conf->commande->enabled) || - !empty($conf->fournisseur->enabled) || - !empty($conf->supplier_proposal->enabled) || - !empty($conf->supplier_order->enabled) || - !empty($conf->contrat->enabled) || - !empty($conf->ficheinter->enabled) - ) ? 1 : 0, + 'enabled'=>(!empty($conf->propal->enabled) || + !empty($conf->commande->enabled) || + !empty($conf->fournisseur->enabled) || + !empty($conf->supplier_proposal->enabled) || + !empty($conf->supplier_order->enabled) || + !empty($conf->contrat->enabled) || + !empty($conf->ficheinter->enabled) + ) ? 1 : 0, 'perms'=>(!empty($user->rights->propal->lire) || !empty($user->rights->commande->lire) || !empty($user->rights->fournisseur->lire) || @@ -243,7 +243,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = !empty($user->rights->supplier_order->lire) || !empty($user->rights->fournisseur->commande->lire) ), - 'module'=>'propal|commande|supplier_proposal|supplier_order|contrat|ficheinter' + 'module'=>'propal|commande|supplier_proposal|supplier_order|contrat|ficheinter' ); $onlysupplierorder = !empty($user->rights->fournisseur->commande->lire) && @@ -259,7 +259,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'link' => ($onlysupplierorder ? '/fourn/commande/index.php?mainmenu=commercial&leftmenu=' : '/comm/index.php?mainmenu=commercial&leftmenu='), 'title' => "Commercial", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "commercial", 'leftmenu' => '', @@ -275,25 +275,25 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Billing - Financial $tmpentry = array( - 'enabled'=>(!empty($conf->facture->enabled) || - !empty($conf->don->enabled) || - !empty($conf->tax->enabled) || - !empty($conf->salaries->enabled) || - !empty($conf->supplier_invoice->enabled) || - !empty($conf->loan->enabled) || - !empty($conf->margins->enabled) - ) ? 1 : 0, - 'perms'=>(!empty($user->rights->facture->lire) || !empty($user->rights->don->contact->lire) - || !empty($user->rights->tax->charges->lire) || !empty($user->rights->salaries->read) - || !empty($user->rights->fournisseur->facture->lire) || !empty($user->rights->loan->read) || !empty($user->rights->margins->liretous)), - 'module'=>'facture|supplier_invoice|don|tax|salaries|loan' + 'enabled'=>(!empty($conf->facture->enabled) || + !empty($conf->don->enabled) || + !empty($conf->tax->enabled) || + !empty($conf->salaries->enabled) || + !empty($conf->supplier_invoice->enabled) || + !empty($conf->loan->enabled) || + !empty($conf->margins->enabled) + ) ? 1 : 0, + 'perms'=>(!empty($user->rights->facture->lire) || !empty($user->rights->don->contact->lire) + || !empty($user->rights->tax->charges->lire) || !empty($user->rights->salaries->read) + || !empty($user->rights->fournisseur->facture->lire) || !empty($user->rights->loan->read) || !empty($user->rights->margins->liretous)), + 'module'=>'facture|supplier_invoice|don|tax|salaries|loan' ); $menu_arr[] = array( 'name' => 'Compta', 'link' => '/compta/index.php?mainmenu=billing&leftmenu=', 'title' => "MenuFinancial", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "billing", 'leftmenu' => '', @@ -309,16 +309,16 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Bank $tmpentry = array( - 'enabled'=>(!empty($conf->banque->enabled) || !empty($conf->prelevement->enabled)), + 'enabled'=>(!empty($conf->banque->enabled) || !empty($conf->prelevement->enabled)), 'perms'=>(!empty($user->rights->banque->lire) || !empty($user->rights->prelevement->lire) || !empty($user->rights->paymentbybanktransfer->read)), - 'module'=>'banque|prelevement|paymentbybanktransfer' + 'module'=>'banque|prelevement|paymentbybanktransfer' ); $menu_arr[] = array( 'name' => 'Bank', 'link' => '/compta/bank/list.php?mainmenu=bank&leftmenu=', 'title' => "MenuBankCash", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "bank", 'leftmenu' => '', @@ -336,16 +336,16 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Accounting $tmpentry = array( - 'enabled'=>(!empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled) || !empty($conf->asset->enabled)), - 'perms'=>(!empty($user->rights->compta->resultat->lire) || !empty($user->rights->accounting->mouvements->lire) || !empty($user->rights->asset->read)), - 'module'=>'comptabilite|accounting|asset' + 'enabled'=>(!empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled) || !empty($conf->asset->enabled)), + 'perms'=>(!empty($user->rights->compta->resultat->lire) || !empty($user->rights->accounting->mouvements->lire) || !empty($user->rights->asset->read)), + 'module'=>'comptabilite|accounting|asset' ); $menu_arr[] = array( 'name' => 'Accounting', 'link' => '/accountancy/index.php?mainmenu=accountancy&leftmenu=', 'title' => "MenuAccountancy", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "accountancy", 'leftmenu' => '', @@ -365,14 +365,14 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $tmpentry = array( 'enabled'=>(!empty($conf->hrm->enabled) || !empty($conf->holiday->enabled) || !empty($conf->deplacement->enabled) || !empty($conf->expensereport->enabled) || !empty($conf->recruitment->enabled)), 'perms'=>(!empty($user->rights->hrm->employee->read) || !empty($user->rights->holiday->write) || !empty($user->rights->deplacement->lire) || !empty($user->rights->expensereport->lire) || !empty($user->rights->recruitment->recruitmentjobposition->read)), - 'module'=>'hrm|holiday|deplacement|expensereport|recruitment' + 'module'=>'hrm|holiday|deplacement|expensereport|recruitment' ); $menu_arr[] = array( 'name' => 'HRM', 'link' => '/hrm/index.php?mainmenu=hrm&leftmenu=', 'title' => "HRM", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "hrm", 'leftmenu' => '', @@ -390,16 +390,16 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Tools $tmpentry = array( - 'enabled'=>1, - 'perms'=>1, - 'module'=>'' + 'enabled'=>1, + 'perms'=>1, + 'module'=>'' ); $menu_arr[] = array( 'name' => 'Tools', 'link' => '/core/tools.php?mainmenu=tools&leftmenu=', 'title' => "Tools", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "tools", 'leftmenu' => '', @@ -464,7 +464,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = { $newTabMenu[$i]['url'] = make_substitutions($newTabMenu[$i]['url'], $substitarray); - // url = url from host, shorturl = relative path into dolibarr sources + // url = url from host, shorturl = relative path into dolibarr sources $url = $shorturl = $newTabMenu[$i]['url']; if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) // Do not change url content for external links { @@ -476,7 +476,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad $url = dol_buildpath($url, 1).($param ? '?'.$param : ''); //$shorturl = $shorturl.($param?'?'.$param:''); - $shorturl = $url; + $shorturl = $url; if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT, '/').'/', '', $shorturl); } @@ -492,7 +492,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Sort on position $menu->liste = dol_sort_array($menu->liste, 'position'); - // Output menu entries + // Output menu entries // Show logo company if (empty($conf->global->MAIN_MENU_INVERT) && empty($noout) && !empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { @@ -527,20 +527,20 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = print_end_menu_entry(4); } - if (empty($noout)) { - foreach ($menu->liste as $menuval) { - print_start_menu_entry($menuval['idsel'], $menuval['classname'], $menuval['enabled']); - print_text_menu_entry($menuval['titre'], $menuval['enabled'], (($menuval['url'] != '#' && !preg_match('/^(http:\/\/|https:\/\/)/i', $menuval['url'])) ? DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target'] ? $menuval['target'] : $atarget)); - print_end_menu_entry($menuval['enabled']); - } - } + if (empty($noout)) { + foreach ($menu->liste as $menuval) { + print_start_menu_entry($menuval['idsel'], $menuval['classname'], $menuval['enabled']); + print_text_menu_entry($menuval['titre'], $menuval['enabled'], (($menuval['url'] != '#' && !preg_match('/^(http:\/\/|https:\/\/)/i', $menuval['url'])) ? DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target'] ? $menuval['target'] : $atarget)); + print_end_menu_entry($menuval['enabled']); + } + } $showmode = 1; - if (empty($noout)) { - print_start_menu_entry('', 'class="tmenuend"', $showmode); - print_end_menu_entry($showmode); - print_end_menu_array(); - } + if (empty($noout)) { + print_start_menu_entry('', 'class="tmenuend"', $showmode); + print_end_menu_entry($showmode); + print_end_menu_array(); + } return 0; } @@ -553,7 +553,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = */ function print_start_menu_array() { - global $conf; + global $conf; print '
'; print '
'; if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) { - // Remove allready present info in new dash board - if (!empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD) && is_array($boxstatItems) && count($boxstatItems) > 0) { - foreach ($boxstatItems as $boxstatItemKey => $boxstatItemHtml) { - if (in_array($boxstatItemKey, $globalStatInTopOpenedDashBoard)) { - unset($boxstatItems[$boxstatItemKey]); - } - } - } + // Remove allready present info in new dash board + if (!empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD) && is_array($boxstatItems) && count($boxstatItems) > 0) { + foreach ($boxstatItems as $boxstatItemKey => $boxstatItemHtml) { + if (in_array($boxstatItemKey, $globalStatInTopOpenedDashBoard)) { + unset($boxstatItems[$boxstatItemKey]); + } + } + } - if (!empty($boxstatFromHook) || !empty($boxstatItems)) { - $boxstat .= ''."\n"; - $boxstat .= '
'; - $boxstat .= ''; - $boxstat .= ''; - $boxstat .= ''; - $boxstat .= ''; - $boxstat .= ''; + $boxstat .= '
'; - $boxstat .= '
'.$langs->trans("DolibarrStateBoard").'
'; - $boxstat .= '
'; + if (!empty($boxstatFromHook) || !empty($boxstatItems)) { + $boxstat .= ''."\n"; + $boxstat .= '
'; + $boxstat .= ''; + $boxstat .= ''; + $boxstat .= ''; + $boxstat .= ''; + $boxstat .= ''; - $boxstat .= '
'; + $boxstat .= '
'.$langs->trans("DolibarrStateBoard").'
'; + $boxstat .= '
'; - $boxstat .= $boxstatFromHook; + $boxstat .= $boxstatFromHook; - if (is_array($boxstatItems) && count($boxstatItems) > 0) - { - $boxstat .= implode('', $boxstatItems); - } + if (is_array($boxstatItems) && count($boxstatItems) > 0) + { + $boxstat .= implode('', $boxstatItems); + } - $boxstat .= '
'; - $boxstat .= '
'; - $boxstat .= '
'; - $boxstat .= '
'; - $boxstat .= '
'; - $boxstat .= '
'; - $boxstat .= '
'; - $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= '
'; - $boxstat .= '
'; - $boxstat .= '
'; - } + $boxstat .= '
'; + $boxstat .= '
'; + } } $boxlist .= '
'; @@ -962,32 +962,32 @@ print '
'; // Security warning repertoire install existe (si utilisateur admin) if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) { - $message = ''; + $message = ''; - // Check if install lock file is present - $lockfile = DOL_DATA_ROOT.'/install.lock'; - if (!empty($lockfile) && !file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install")) - { - $langs->load("errors"); - //if (! empty($message)) $message.='
'; - $message .= info_admin($langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); - } + // Check if install lock file is present + $lockfile = DOL_DATA_ROOT.'/install.lock'; + if (!empty($lockfile) && !file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install")) + { + $langs->load("errors"); + //if (! empty($message)) $message.='
'; + $message .= info_admin($langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); + } - // Conf files must be in read only mode - if (is_writable($conffile)) - { - $langs->load("errors"); - //$langs->load("other"); - //if (! empty($message)) $message.='
'; - $message .= info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); - } + // Conf files must be in read only mode + if (is_writable($conffile)) + { + $langs->load("errors"); + //$langs->load("other"); + //if (! empty($message)) $message.='
'; + $message .= info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); + } - if ($message) - { - print $message; - //$message.='
'; - //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); - } + if ($message) + { + print $message; + //$message.='
'; + //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); + } } //print 'mem='.memory_get_usage().' - '.memory_get_peak_usage(); @@ -1009,10 +1009,10 @@ $db->close(); */ function showWeather($totallate, $text, $options, $morecss = '') { - global $conf; + global $conf; - $weather = getWeatherStatus($totallate); - return img_weather($text, $weather->picto, $options, 0, $morecss); + $weather = getWeatherStatus($totallate); + return img_weather($text, $weather->picto, $options, 0, $morecss); } diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index ef4e3b82a9d..b4fe656bbac 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -93,13 +93,13 @@ $error = 0; // If password is encoded, we decode it if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { - require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; - if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) - { - $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); - $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); - $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted - } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; + if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) + { + $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); + $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); + $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted + } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); } // $conf is already instancied inside inc.php @@ -118,40 +118,40 @@ $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf if ($db->connected) { - print ''; - print $langs->trans("ServerConnection")." : $dolibarr_main_db_host".$langs->trans("OK").""; - dolibarr_install_syslog("repair: ".$langs->transnoentities("ServerConnection").": ".$dolibarr_main_db_host.$langs->transnoentities("OK")); - $ok = 1; + print ''; + print $langs->trans("ServerConnection")." : $dolibarr_main_db_host".$langs->trans("OK").""; + dolibarr_install_syslog("repair: ".$langs->transnoentities("ServerConnection").": ".$dolibarr_main_db_host.$langs->transnoentities("OK")); + $ok = 1; } else { - print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)."".$langs->transnoentities("Error").""; - dolibarr_install_syslog("repair: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); - $ok = 0; + print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)."".$langs->transnoentities("Error").""; + dolibarr_install_syslog("repair: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); + $ok = 0; } if ($ok) { - if ($db->database_selected) - { - print ''; - print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."".$langs->trans("OK").""; - dolibarr_install_syslog("repair: database connection successful: ".$dolibarr_main_db_name); - $ok = 1; - } else { - print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)."".$langs->trans("Error").""; - dolibarr_install_syslog("repair: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); - $ok = 0; - } + if ($db->database_selected) + { + print ''; + print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."".$langs->trans("OK").""; + dolibarr_install_syslog("repair: database connection successful: ".$dolibarr_main_db_name); + $ok = 1; + } else { + print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)."".$langs->trans("Error").""; + dolibarr_install_syslog("repair: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); + $ok = 0; + } } // Show database version if ($ok) { - $version = $db->getVersion(); - $versionarray = $db->getVersionArray(); - print ''.$langs->trans("ServerVersion").''; - print ''.$version.''; - dolibarr_install_syslog("repair: ".$langs->transnoentities("ServerVersion").": ".$version); - //print ''.join('.',$versionarray).''; + $version = $db->getVersion(); + $versionarray = $db->getVersionArray(); + print ''.$langs->trans("ServerVersion").''; + print ''.$version.''; + dolibarr_install_syslog("repair: ".$langs->transnoentities("ServerVersion").": ".$version); + //print ''.join('.',$versionarray).''; } $conf->setValues($db); @@ -180,41 +180,41 @@ if ($ok && GETPOST('standard', 'alpha')) { $dir = "mysql/migration/"; - $filelist = array(); - $i = 0; - $ok = 0; + $filelist = array(); + $i = 0; + $ok = 0; - // Recupere list fichier - $filesindir = array(); - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.sql$/i', $file)) $filesindir[] = $file; - } - } - sort($filesindir); + // Recupere list fichier + $filesindir = array(); + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.sql$/i', $file)) $filesindir[] = $file; + } + } + sort($filesindir); - foreach ($filesindir as $file) - { - if (preg_match('/repair/i', $file)) - { - $filelist[] = $file; - } - } + foreach ($filesindir as $file) + { + if (preg_match('/repair/i', $file)) + { + $filelist[] = $file; + } + } - // Loop on each file - foreach ($filelist as $file) - { - print '*** '; - print $langs->trans("Script").''.$file.''; + // Loop on each file + foreach ($filelist as $file) + { + print '*** '; + print $langs->trans("Script").''.$file.''; - $name = substr($file, 0, dol_strlen($file) - 4); + $name = substr($file, 0, dol_strlen($file) - 4); - // Run sql script - $ok = run_sql($dir.$file, 0, '', 1); - } + // Run sql script + $ok = run_sql($dir.$file, 0, '', 1); + } } @@ -231,98 +231,98 @@ if ($ok && GETPOST('standard', 'alpha')) print '
*** Check fields into extra table structure match table of definition. If not add column into table'; foreach ($listofmodulesextra as $tablename => $elementtype) { - // Get list of fields - $tableextra = MAIN_DB_PREFIX.$tablename.'_extrafields'; + // Get list of fields + $tableextra = MAIN_DB_PREFIX.$tablename.'_extrafields'; - // Define $arrayoffieldsdesc - $arrayoffieldsdesc = $extrafields->fetch_name_optionals_label($elementtype); + // Define $arrayoffieldsdesc + $arrayoffieldsdesc = $extrafields->fetch_name_optionals_label($elementtype); - // Define $arrayoffieldsfound - $arrayoffieldsfound = array(); - $resql = $db->DDLDescTable($tableextra); - if ($resql) - { - print 'Check availability of extra field for '.$tableextra."
\n"; - $i = 0; - while ($obj = $db->fetch_object($resql)) - { - $fieldname = $fieldtype = ''; - if (preg_match('/mysql/', $db->type)) - { - $fieldname = $obj->Field; - $fieldtype = $obj->Type; - } else { - $fieldname = isset($obj->Key) ? $obj->Key : $obj->attname; - $fieldtype = isset($obj->Type) ? $obj->Type : 'varchar'; - } + // Define $arrayoffieldsfound + $arrayoffieldsfound = array(); + $resql = $db->DDLDescTable($tableextra); + if ($resql) + { + print 'Check availability of extra field for '.$tableextra."
\n"; + $i = 0; + while ($obj = $db->fetch_object($resql)) + { + $fieldname = $fieldtype = ''; + if (preg_match('/mysql/', $db->type)) + { + $fieldname = $obj->Field; + $fieldtype = $obj->Type; + } else { + $fieldname = isset($obj->Key) ? $obj->Key : $obj->attname; + $fieldtype = isset($obj->Type) ? $obj->Type : 'varchar'; + } - if (empty($fieldname)) continue; - if (in_array($fieldname, array('rowid', 'tms', 'fk_object', 'import_key'))) continue; - $arrayoffieldsfound[$fieldname] = array('type'=>$fieldtype); - } + if (empty($fieldname)) continue; + if (in_array($fieldname, array('rowid', 'tms', 'fk_object', 'import_key'))) continue; + $arrayoffieldsfound[$fieldname] = array('type'=>$fieldtype); + } - // If it does not match, we create fields - foreach ($arrayoffieldsdesc as $code => $label) - { - if (!in_array($code, array_keys($arrayoffieldsfound))) - { - print 'Found field '.$code.' declared into '.MAIN_DB_PREFIX.'extrafields table but not found into desc of table '.$tableextra." -> "; - $type = $extrafields->attributes[$elementtype]['type'][$code]; $length = $extrafields->attributes[$elementtype]['size'][$code]; $attribute = ''; $default = ''; $extra = ''; $null = 'null'; + // If it does not match, we create fields + foreach ($arrayoffieldsdesc as $code => $label) + { + if (!in_array($code, array_keys($arrayoffieldsfound))) + { + print 'Found field '.$code.' declared into '.MAIN_DB_PREFIX.'extrafields table but not found into desc of table '.$tableextra." -> "; + $type = $extrafields->attributes[$elementtype]['type'][$code]; $length = $extrafields->attributes[$elementtype]['size'][$code]; $attribute = ''; $default = ''; $extra = ''; $null = 'null'; - if ($type == 'boolean') { - $typedb = 'int'; - $lengthdb = '1'; - } elseif ($type == 'price') { - $typedb = 'double'; - $lengthdb = '24,8'; - } elseif ($type == 'phone') { - $typedb = 'varchar'; - $lengthdb = '20'; - } elseif ($type == 'mail') { - $typedb = 'varchar'; - $lengthdb = '128'; - } elseif (($type == 'select') || ($type == 'sellist') || ($type == 'radio') || ($type == 'checkbox') || ($type == 'chkbxlst')) { - $typedb = 'text'; - $lengthdb = ''; - } elseif ($type == 'link') { - $typedb = 'int'; - $lengthdb = '11'; - } else { - $typedb = $type; - $lengthdb = $length; - } + if ($type == 'boolean') { + $typedb = 'int'; + $lengthdb = '1'; + } elseif ($type == 'price') { + $typedb = 'double'; + $lengthdb = '24,8'; + } elseif ($type == 'phone') { + $typedb = 'varchar'; + $lengthdb = '20'; + } elseif ($type == 'mail') { + $typedb = 'varchar'; + $lengthdb = '128'; + } elseif (($type == 'select') || ($type == 'sellist') || ($type == 'radio') || ($type == 'checkbox') || ($type == 'chkbxlst')) { + $typedb = 'text'; + $lengthdb = ''; + } elseif ($type == 'link') { + $typedb = 'int'; + $lengthdb = '11'; + } else { + $typedb = $type; + $lengthdb = $length; + } - $field_desc = array( - 'type'=>$typedb, - 'value'=>$lengthdb, - 'attribute'=>$attribute, - 'default'=>$default, - 'extra'=>$extra, - 'null'=>$null - ); - //var_dump($field_desc);exit; + $field_desc = array( + 'type'=>$typedb, + 'value'=>$lengthdb, + 'attribute'=>$attribute, + 'default'=>$default, + 'extra'=>$extra, + 'null'=>$null + ); + //var_dump($field_desc);exit; - $result = 0; - if (GETPOST('standard', 'alpha') == 'confirmed') - { - $result = $db->DDLAddField($tableextra, $code, $field_desc, ""); + $result = 0; + if (GETPOST('standard', 'alpha') == 'confirmed') + { + $result = $db->DDLAddField($tableextra, $code, $field_desc, ""); - if ($result < 0) - { - print "KO ".$db->lasterror."
\n"; - } else { - print "OK
\n"; - } - } else { - print ' - Mode test, no column added.'; - } - } - } + if ($result < 0) + { + print "KO ".$db->lasterror."
\n"; + } else { + print "OK
\n"; + } + } else { + print ' - Mode test, no column added.'; + } + } + } - print " \n"; - } else { - dol_print_error($db); - } + print " \n"; + } else { + dol_print_error($db); + } } } @@ -659,63 +659,63 @@ if ($ok && GETPOST('restore_user_pictures', 'alpha')) // rebuild_product_thumbs: Rebuild thumbs for product files if ($ok && GETPOST('rebuild_product_thumbs', 'alpha')) { - $ext = ''; - global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini; + $ext = ''; + global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini; - print '
*** Rebuild product thumbs
'; + print '
*** Rebuild product thumbs
'; - $sql = "SELECT s.rowid, s.ref FROM ".MAIN_DB_PREFIX."product as s ORDER BY s.ref"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; + $sql = "SELECT s.rowid, s.ref FROM ".MAIN_DB_PREFIX."product as s ORDER BY s.ref"; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - if (!empty($obj->ref)) - { - $files = dol_dir_list($dolibarr_main_data_root.'/produit/'.$obj->ref, 'files', 0); - foreach ($files as $file) - { + if (!empty($obj->ref)) + { + $files = dol_dir_list($dolibarr_main_data_root.'/produit/'.$obj->ref, 'files', 0); + foreach ($files as $file) + { // Generate thumbs. if (image_format_supported($file['fullname']) == 1) { - $imgThumbSmall = 'notbuild'; - if (GETPOST('rebuild_product_thumbs', 'alpha') == 'confirmed') - { - // Used on logon for example - $imgThumbSmall = vignette($file['fullname'], $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); - } - print 'Check product '.$obj->rowid.", file ".$file['fullname']." -> ".$imgThumbSmall." maxwidthsmall=".$maxwidthsmall." maxheightsmall=".$maxheightsmall."
\n"; - $imgThumbMini = 'notbuild'; - if (GETPOST('rebuild_product_thumbs', 'alpha') == 'confirmed') - { - // Create mini thumbs for image (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($file['fullname'], $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); - } - print 'Check product '.$obj->rowid.", file ".$file['fullname']." -> ".$imgThumbMini." maxwidthmini=".$maxwidthmini." maxheightmini=".$maxheightmini."
\n"; + $imgThumbSmall = 'notbuild'; + if (GETPOST('rebuild_product_thumbs', 'alpha') == 'confirmed') + { + // Used on logon for example + $imgThumbSmall = vignette($file['fullname'], $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); + } + print 'Check product '.$obj->rowid.", file ".$file['fullname']." -> ".$imgThumbSmall." maxwidthsmall=".$maxwidthsmall." maxheightsmall=".$maxheightsmall."
\n"; + $imgThumbMini = 'notbuild'; + if (GETPOST('rebuild_product_thumbs', 'alpha') == 'confirmed') + { + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($file['fullname'], $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + } + print 'Check product '.$obj->rowid.", file ".$file['fullname']." -> ".$imgThumbMini." maxwidthmini=".$maxwidthmini." maxheightmini=".$maxheightmini."
\n"; } - } - } + } + } - $i++; - } - } else { - $ok = 0; - dol_print_error($db); - } + $i++; + } + } else { + $ok = 0; + dol_print_error($db); + } - print ''; + print ''; } // clean_linked_elements: Check and clean linked elements if ($ok && GETPOST('clean_linked_elements', 'alpha')) { - print '
*** Check table of linked elements and delete orphelins links'; + print '
*** Check table of linked elements and delete orphelins links'; // propal => order print ''.checkLinkedElements('propal', 'commande')."\n"; @@ -819,414 +819,414 @@ if ($ok && GETPOST('clean_menus', 'alpha')) // clean_orphelin_dir: Run purge of directory if ($ok && GETPOST('clean_orphelin_dir', 'alpha')) { - $listmodulepart = array('company', 'invoice', 'invoice_supplier', 'propal', 'order', 'order_supplier', 'contract', 'tax'); - foreach ($listmodulepart as $modulepart) - { - $filearray = array(); - $upload_dir = isset($conf->$modulepart->dir_output) ? $conf->$modulepart->dir_output : ''; - if ($modulepart == 'company') $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing - if ($modulepart == 'invoice') $upload_dir = $conf->facture->dir_output; - if ($modulepart == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; - if ($modulepart == 'order') $upload_dir = $conf->commande->dir_output; - if ($modulepart == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; - if ($modulepart == 'contract') $upload_dir = $conf->contrat->dir_output; + $listmodulepart = array('company', 'invoice', 'invoice_supplier', 'propal', 'order', 'order_supplier', 'contract', 'tax'); + foreach ($listmodulepart as $modulepart) + { + $filearray = array(); + $upload_dir = isset($conf->$modulepart->dir_output) ? $conf->$modulepart->dir_output : ''; + if ($modulepart == 'company') $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing + if ($modulepart == 'invoice') $upload_dir = $conf->facture->dir_output; + if ($modulepart == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; + if ($modulepart == 'order') $upload_dir = $conf->commande->dir_output; + if ($modulepart == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; + if ($modulepart == 'contract') $upload_dir = $conf->contrat->dir_output; - if (empty($upload_dir)) continue; + if (empty($upload_dir)) continue; - print '
*** Clean orphelins files into files '.$upload_dir.''; + print '
*** Clean orphelins files into files '.$upload_dir.''; - $filearray = dol_dir_list($upload_dir, "files", 1, '', array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$'), '', SORT_DESC, 1, true); + $filearray = dol_dir_list($upload_dir, "files", 1, '', array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$'), '', SORT_DESC, 1, true); - // To show ref or specific information according to view to show (defined by $module) - if ($modulepart == 'company') - { - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $object_instance = new Societe($db); - } - if ($modulepart == 'invoice') - { - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $object_instance = new Facture($db); - } elseif ($modulepart == 'invoice_supplier') - { - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $object_instance = new FactureFournisseur($db); - } elseif ($modulepart == 'propal') - { - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $object_instance = new Propal($db); - } elseif ($modulepart == 'order') - { - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $object_instance = new Commande($db); - } elseif ($modulepart == 'order_supplier') - { - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $object_instance = new CommandeFournisseur($db); - } elseif ($modulepart == 'contract') - { - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $object_instance = new Contrat($db); - } elseif ($modulepart == 'tax') - { - include_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; - $object_instance = new ChargeSociales($db); - } + // To show ref or specific information according to view to show (defined by $module) + if ($modulepart == 'company') + { + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $object_instance = new Societe($db); + } + if ($modulepart == 'invoice') + { + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $object_instance = new Facture($db); + } elseif ($modulepart == 'invoice_supplier') + { + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $object_instance = new FactureFournisseur($db); + } elseif ($modulepart == 'propal') + { + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + $object_instance = new Propal($db); + } elseif ($modulepart == 'order') + { + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $object_instance = new Commande($db); + } elseif ($modulepart == 'order_supplier') + { + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $object_instance = new CommandeFournisseur($db); + } elseif ($modulepart == 'contract') + { + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + $object_instance = new Contrat($db); + } elseif ($modulepart == 'tax') + { + include_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; + $object_instance = new ChargeSociales($db); + } - foreach ($filearray as $key => $file) - { - if (!is_dir($file['name']) - && $file['name'] != '.' - && $file['name'] != '..' - && $file['name'] != 'CVS' - ) - { - // Define relative path used to store the file - $relativefile = preg_replace('/'.preg_quote($upload_dir.'/', '/').'/', '', $file['fullname']); + foreach ($filearray as $key => $file) + { + if (!is_dir($file['name']) + && $file['name'] != '.' + && $file['name'] != '..' + && $file['name'] != 'CVS' + ) + { + // Define relative path used to store the file + $relativefile = preg_replace('/'.preg_quote($upload_dir.'/', '/').'/', '', $file['fullname']); - //var_dump($file); - $id = 0; $ref = ''; $object_instance->id = 0; $object_instance->ref = ''; $label = ''; + //var_dump($file); + $id = 0; $ref = ''; $object_instance->id = 0; $object_instance->ref = ''; $label = ''; - // To show ref or specific information according to view to show (defined by $module) - if ($modulepart == 'invoice') { - preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = $reg[1]; - } - if ($modulepart == 'invoice_supplier') { - preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = empty($reg[1]) ? '' : $reg[1]; - } - if ($modulepart == 'propal') { - preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = $reg[1]; - } - if ($modulepart == 'order') { - preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = $reg[1]; - } - if ($modulepart == 'order_supplier') { - preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = $reg[1]; - } - if ($modulepart == 'contract') { - preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = $reg[1]; - } - if ($modulepart == 'tax') { - preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = $reg[1]; - } + // To show ref or specific information according to view to show (defined by $module) + if ($modulepart == 'invoice') { + preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = $reg[1]; + } + if ($modulepart == 'invoice_supplier') { + preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = empty($reg[1]) ? '' : $reg[1]; + } + if ($modulepart == 'propal') { + preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = $reg[1]; + } + if ($modulepart == 'order') { + preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = $reg[1]; + } + if ($modulepart == 'order_supplier') { + preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = $reg[1]; + } + if ($modulepart == 'contract') { + preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = $reg[1]; + } + if ($modulepart == 'tax') { + preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = $reg[1]; + } - if ($id || $ref) - { - //print 'Fetch '.$id.' or '.$ref.'
'; - $result = $object_instance->fetch($id, $ref); - //print $result.'
'; - if ($result == 0) // Not found but no error - { - // Clean of orphelins directories are done into repair.php - print ''; - print 'Delete orphelins file '.$file['fullname'].'
'; - if (GETPOST('clean_orphelin_dir', 'alpha') == 'confirmed') - { - dol_delete_file($file['fullname'], 1, 1, 1); - dol_delete_dir(dirname($file['fullname']), 1); - } - print ""; - } elseif ($result < 0) print 'Error in '.get_class($object_instance).'.fetch of id'.$id.' ref='.$ref.', result='.$result.'
'; - } - } - } - } + if ($id || $ref) + { + //print 'Fetch '.$id.' or '.$ref.'
'; + $result = $object_instance->fetch($id, $ref); + //print $result.'
'; + if ($result == 0) // Not found but no error + { + // Clean of orphelins directories are done into repair.php + print ''; + print 'Delete orphelins file '.$file['fullname'].'
'; + if (GETPOST('clean_orphelin_dir', 'alpha') == 'confirmed') + { + dol_delete_file($file['fullname'], 1, 1, 1); + dol_delete_dir(dirname($file['fullname']), 1); + } + print ""; + } elseif ($result < 0) print 'Error in '.get_class($object_instance).'.fetch of id'.$id.' ref='.$ref.', result='.$result.'
'; + } + } + } + } } // clean_linked_elements: Check and clean linked elements if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) { - $methodtofix = GETPOST('methodtofix', 'alpha') ?GETPOST('methodtofix', 'alpha') : 'updatestock'; + $methodtofix = GETPOST('methodtofix', 'alpha') ?GETPOST('methodtofix', 'alpha') : 'updatestock'; - print '
*** Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch)'; + print '
*** Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch)'; - $sql = "SELECT p.rowid, p.ref, p.tobatch, ps.rowid as psrowid, ps.fk_entrepot, ps.reel, SUM(pb.qty) as reelbatch"; - $sql .= " FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_stock as ps LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb ON ps.rowid = pb.fk_product_stock"; - $sql .= " WHERE p.rowid = ps.fk_product"; - $sql .= " AND p.tobatch = 1"; - $sql .= " GROUP BY p.rowid, p.ref, p.tobatch, ps.rowid, ps.fk_entrepot, ps.reel"; - $sql .= " HAVING reel != SUM(pb.qty) or SUM(pb.qty) IS NULL"; - print $sql; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); + $sql = "SELECT p.rowid, p.ref, p.tobatch, ps.rowid as psrowid, ps.fk_entrepot, ps.reel, SUM(pb.qty) as reelbatch"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_stock as ps LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb ON ps.rowid = pb.fk_product_stock"; + $sql .= " WHERE p.rowid = ps.fk_product"; + $sql .= " AND p.tobatch = 1"; + $sql .= " GROUP BY p.rowid, p.ref, p.tobatch, ps.rowid, ps.fk_entrepot, ps.reel"; + $sql .= " HAVING reel != SUM(pb.qty) or SUM(pb.qty) IS NULL"; + print $sql; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); - if ($num) - { - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - print 'Product '.$obj->rowid.'-'.$obj->ref.' in warehose '.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' (product_stock.reel) != '.($obj->reelbatch ? $obj->reelbatch : '0').' (sum product_batch)'; + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + print 'Product '.$obj->rowid.'-'.$obj->ref.' in warehose '.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' (product_stock.reel) != '.($obj->reelbatch ? $obj->reelbatch : '0').' (sum product_batch)'; - // Fix - if ($obj->reel != $obj->reelbatch) - { - if ($methodtofix == 'updatebatch') - { - // Method 1 - print ' -> Insert qty '.($obj->reel - $obj->reelbatch).' with lot 000000 linked to fk_product_stock='.$obj->psrowid; - if (GETPOST('clean_product_stock_batch') == 'confirmed') - { - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_batch(fk_product_stock, batch, qty)"; - $sql2 .= "VALUES(".$obj->psrowid.", '000000', ".($obj->reel - $obj->reelbatch).")"; - $resql2 = $db->query($sql2); - if (!$resql2) - { - // TODO If it fails, we must make update - //$sql2 ="UPDATE ".MAIN_DB_PREFIX."product_batch"; - //$sql2.=" SET ".$obj->psrowid.", '000000', ".($obj->reel - $obj->reelbatch).")"; - //$sql2.=" WHERE fk_product_stock = ".$obj->psrowid" - } - } - } - if ($methodtofix == 'updatestock') - { - // Method 2 - print ' -> Update qty of product_stock with qty = '.($obj->reelbatch ? $obj->reelbatch : '0').' for ps.rowid = '.$obj->psrowid; - if (GETPOST('clean_product_stock_batch') == 'confirmed') - { - $error = 0; + // Fix + if ($obj->reel != $obj->reelbatch) + { + if ($methodtofix == 'updatebatch') + { + // Method 1 + print ' -> Insert qty '.($obj->reel - $obj->reelbatch).' with lot 000000 linked to fk_product_stock='.$obj->psrowid; + if (GETPOST('clean_product_stock_batch') == 'confirmed') + { + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_batch(fk_product_stock, batch, qty)"; + $sql2 .= "VALUES(".$obj->psrowid.", '000000', ".($obj->reel - $obj->reelbatch).")"; + $resql2 = $db->query($sql2); + if (!$resql2) + { + // TODO If it fails, we must make update + //$sql2 ="UPDATE ".MAIN_DB_PREFIX."product_batch"; + //$sql2.=" SET ".$obj->psrowid.", '000000', ".($obj->reel - $obj->reelbatch).")"; + //$sql2.=" WHERE fk_product_stock = ".$obj->psrowid" + } + } + } + if ($methodtofix == 'updatestock') + { + // Method 2 + print ' -> Update qty of product_stock with qty = '.($obj->reelbatch ? $obj->reelbatch : '0').' for ps.rowid = '.$obj->psrowid; + if (GETPOST('clean_product_stock_batch') == 'confirmed') + { + $error = 0; - $db->begin(); + $db->begin(); - $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_stock"; - $sql2 .= " SET reel = ".($obj->reelbatch ? $obj->reelbatch : '0')." WHERE rowid = ".$obj->psrowid; - $resql2 = $db->query($sql2); - if ($resql2) - { - // We update product_stock, so we must fill p.stock into product too. - $sql3 = 'UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid)'; - $resql3 = $db->query($sql3); - if (!$resql3) - { - $error++; - dol_print_error($db); - } - } else { - $error++; - dol_print_error($db); - } + $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_stock"; + $sql2 .= " SET reel = ".($obj->reelbatch ? $obj->reelbatch : '0')." WHERE rowid = ".$obj->psrowid; + $resql2 = $db->query($sql2); + if ($resql2) + { + // We update product_stock, so we must fill p.stock into product too. + $sql3 = 'UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid)'; + $resql3 = $db->query($sql3); + if (!$resql3) + { + $error++; + dol_print_error($db); + } + } else { + $error++; + dol_print_error($db); + } - if (!$error) $db->commit(); - else $db->rollback(); - } - } - } + if (!$error) $db->commit(); + else $db->rollback(); + } + } + } - print''; + print''; - $i++; - } - } else { - print 'Nothing to do'; - } - } else { - dol_print_error($db); - } + $i++; + } + } else { + print 'Nothing to do'; + } + } else { + dol_print_error($db); + } } // clean_product_stock_negative_if_batch if ($ok && GETPOST('clean_product_stock_negative_if_batch', 'alpha')) { - print '
Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch)'; + print '
Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch)'; - $sql = "SELECT p.rowid, p.ref, p.tobatch, ps.rowid as psrowid, ps.fk_entrepot, ps.reel, SUM(pb.qty) as reelbatch"; - $sql .= " FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product_batch as pb"; - $sql .= " WHERE p.rowid = ps.fk_product AND ps.rowid = pb.fk_product_stock"; - $sql .= " AND p.tobatch = 1"; - $sql .= " GROUP BY p.rowid, p.ref, p.tobatch, ps.rowid, ps.fk_entrepot, ps.reel"; - $sql .= " HAVING reel != SUM(pb.qty)"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); + $sql = "SELECT p.rowid, p.ref, p.tobatch, ps.rowid as psrowid, ps.fk_entrepot, ps.reel, SUM(pb.qty) as reelbatch"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product_batch as pb"; + $sql .= " WHERE p.rowid = ps.fk_product AND ps.rowid = pb.fk_product_stock"; + $sql .= " AND p.tobatch = 1"; + $sql .= " GROUP BY p.rowid, p.ref, p.tobatch, ps.rowid, ps.fk_entrepot, ps.reel"; + $sql .= " HAVING reel != SUM(pb.qty)"; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); - if ($num) - { - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - print ''.$obj->rowid.'-'.$obj->ref.'-'.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' != '.$obj->reelbatch; + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + print ''.$obj->rowid.'-'.$obj->ref.'-'.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' != '.$obj->reelbatch; - // TODO - } - } - } + // TODO + } + } + } } // set_empty_time_spent_amount if ($ok && GETPOST('set_empty_time_spent_amount', 'alpha')) { - print '
*** Set value of time spent without amount'; + print '
*** Set value of time spent without amount'; - $sql = "SELECT COUNT(ptt.rowid) as nb, u.rowid as user_id, u.login, u.thm as user_thm"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as ptt, ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE ptt.fk_user = u.rowid"; - $sql .= " AND ptt.thm IS NULL and u.thm > 0"; - $sql .= " GROUP BY u.rowid, u.login, u.thm"; + $sql = "SELECT COUNT(ptt.rowid) as nb, u.rowid as user_id, u.login, u.thm as user_thm"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as ptt, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE ptt.fk_user = u.rowid"; + $sql .= " AND ptt.thm IS NULL and u.thm > 0"; + $sql .= " GROUP BY u.rowid, u.login, u.thm"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); - if ($num) - { - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - print ''.$obj->login.'-'.$obj->user_id.' ('.$obj->nb.' lines to fix) -> '.$obj->user_thm; + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + print ''.$obj->login.'-'.$obj->user_id.' ('.$obj->nb.' lines to fix) -> '.$obj->user_thm; - $db->begin(); + $db->begin(); - if (GETPOST('set_empty_time_spent_amount') == 'confirmed') - { - $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; - $sql2 .= " SET thm = ".$obj->user_thm." WHERE thm IS NULL AND fk_user = ".$obj->user_id; - $resql2 = $db->query($sql2); - if (!$resql2) - { - $error++; - dol_print_error($db); - } - } + if (GETPOST('set_empty_time_spent_amount') == 'confirmed') + { + $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; + $sql2 .= " SET thm = ".$obj->user_thm." WHERE thm IS NULL AND fk_user = ".$obj->user_id; + $resql2 = $db->query($sql2); + if (!$resql2) + { + $error++; + dol_print_error($db); + } + } - if (!$error) $db->commit(); - else $db->rollback(); + if (!$error) $db->commit(); + else $db->rollback(); - print''; + print''; - if ($error) break; + if ($error) break; - $i++; - } - } else { - print 'No time spent with empty line on users with a hourly rate defined'; - } - } else { - dol_print_error($db); - } + $i++; + } + } else { + print 'No time spent with empty line on users with a hourly rate defined'; + } + } else { + dol_print_error($db); + } } // force_disable_of_modules_not_found if ($ok && GETPOST('force_disable_of_modules_not_found', 'alpha')) { - print '
*** Force modules not found physicaly to be disabled (only modules adding js, css or hooks can be detected as removed physicaly)'; + print '
*** Force modules not found physicaly to be disabled (only modules adding js, css or hooks can be detected as removed physicaly)'; - $arraylistofkey = array('hooks', 'js', 'css'); + $arraylistofkey = array('hooks', 'js', 'css'); - foreach ($arraylistofkey as $key) - { - $sql = "SELECT DISTINCT name, value"; - $sql .= " FROM ".MAIN_DB_PREFIX."const as c"; - $sql .= " WHERE name LIKE 'MAIN_MODULE_%_".strtoupper($key)."'"; - $sql .= " ORDER BY name"; + foreach ($arraylistofkey as $key) + { + $sql = "SELECT DISTINCT name, value"; + $sql .= " FROM ".MAIN_DB_PREFIX."const as c"; + $sql .= " WHERE name LIKE 'MAIN_MODULE_%_".strtoupper($key)."'"; + $sql .= " ORDER BY name"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - if ($num) - { - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $constantname = $obj->name; // Name of constant for hook or js or css declaration + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $constantname = $obj->name; // Name of constant for hook or js or css declaration - print ''; - print $constantname; + print ''; + print $constantname; - $db->begin(); + $db->begin(); - $reg = array(); - if (preg_match('/MAIN_MODULE_(.*)_'.strtoupper($key).'/i', $constantname, $reg)) - { - $name = strtolower($reg[1]); + $reg = array(); + if (preg_match('/MAIN_MODULE_(.*)_'.strtoupper($key).'/i', $constantname, $reg)) + { + $name = strtolower($reg[1]); - if ($name) // An entry for key $key and module $name was found in database. - { - $reloffile = ''; + if ($name) // An entry for key $key and module $name was found in database. + { + $reloffile = ''; $result = 'found'; - if ($key == 'hooks') $reloffile = $name.'/class/actions_'.$name.'.class.php'; - if ($key == 'js') - { - $value = $obj->value; - $valuearray = json_decode($value); - $reloffile = $valuearray[0]; - $reloffile = preg_replace('/^\//', '', $valuearray[0]); - } - if ($key == 'css') - { - $value = $obj->value; - $valuearray = json_decode($value); - if ($value && count($valuearray) == 0) $valuearray[0] = $value; // If value was not a json array but a string - $reloffile = preg_replace('/^\//', '', $valuearray[0]); - } + if ($key == 'hooks') $reloffile = $name.'/class/actions_'.$name.'.class.php'; + if ($key == 'js') + { + $value = $obj->value; + $valuearray = json_decode($value); + $reloffile = $valuearray[0]; + $reloffile = preg_replace('/^\//', '', $valuearray[0]); + } + if ($key == 'css') + { + $value = $obj->value; + $valuearray = json_decode($value); + if ($value && count($valuearray) == 0) $valuearray[0] = $value; // If value was not a json array but a string + $reloffile = preg_replace('/^\//', '', $valuearray[0]); + } - if ($reloffile) - { - //var_dump($key.' - '.$value.' - '.$reloffile); - try { - $result = dol_buildpath($reloffile, 0, 2); - } catch (Exception $e) - { + if ($reloffile) + { + //var_dump($key.' - '.$value.' - '.$reloffile); + try { + $result = dol_buildpath($reloffile, 0, 2); + } catch (Exception $e) + { // No catch yet $result = 'found'; // If error, we force lke if we found to avoid any deletion - } - } + } + } - if (!$result) - { - print ' - File of '.$key.' ('.$reloffile.') NOT found, we disable the module.'; - if (GETPOST('force_disable_of_modules_not_found') == 'confirmed') - { - $sql2 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'MAIN_MODULE_".strtoupper($name)."_".strtoupper($key)."'"; - $resql2 = $db->query($sql2); - if (!$resql2) - { - $error++; - dol_print_error($db); - } - $sql3 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'MAIN_MODULE_".strtoupper($name)."'"; - $resql3 = $db->query($sql3); - if (!$resql3) - { - $error++; - dol_print_error($db); - } else print ' - Cleaned'; - } else { - print ' - Canceled (test mode)'; - } - } else { - print ' - File of '.$key.' ('.$reloffile.') found, we do nothing.'; - } - } + if (!$result) + { + print ' - File of '.$key.' ('.$reloffile.') NOT found, we disable the module.'; + if (GETPOST('force_disable_of_modules_not_found') == 'confirmed') + { + $sql2 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'MAIN_MODULE_".strtoupper($name)."_".strtoupper($key)."'"; + $resql2 = $db->query($sql2); + if (!$resql2) + { + $error++; + dol_print_error($db); + } + $sql3 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'MAIN_MODULE_".strtoupper($name)."'"; + $resql3 = $db->query($sql3); + if (!$resql3) + { + $error++; + dol_print_error($db); + } else print ' - Cleaned'; + } else { + print ' - Canceled (test mode)'; + } + } else { + print ' - File of '.$key.' ('.$reloffile.') found, we do nothing.'; + } + } - if (!$error) $db->commit(); - else $db->rollback(); - } + if (!$error) $db->commit(); + else $db->rollback(); + } - print''; + print''; - if ($error) break; + if ($error) break; - $i++; - } - } else { - print 'No active module with missing files found by searching on MAIN_MODULE_(.*)_'.strtoupper($key).''; - } - } else { - dol_print_error($db); - } - } + $i++; + } + } else { + print 'No active module with missing files found by searching on MAIN_MODULE_(.*)_'.strtoupper($key).''; + } + } else { + dol_print_error($db); + } + } } @@ -1281,54 +1281,54 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) // force utf8 on tables if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) { - print '
*** Force page code and collation of tables into utf8/utf8_unicode_ci (for mysql/mariadb only)'; + print '
*** Force page code and collation of tables into utf8/utf8_unicode_ci (for mysql/mariadb only)'; - if ($db->type == "mysql" || $db->type == "mysqli") - { - $force_utf8_on_tables = GETPOST('force_utf8_on_tables', 'alpha'); + if ($db->type == "mysql" || $db->type == "mysqli") + { + $force_utf8_on_tables = GETPOST('force_utf8_on_tables', 'alpha'); - $listoftables = $db->DDLListTables($db->database_name); + $listoftables = $db->DDLListTables($db->database_name); - // Disable foreign key checking for avoid errors - if ($force_utf8_on_tables == 'confirmed') - { - $sql = 'SET FOREIGN_KEY_CHECKS=0'; - print ''; - $resql = $db->query($sql); - } + // Disable foreign key checking for avoid errors + if ($force_utf8_on_tables == 'confirmed') + { + $sql = 'SET FOREIGN_KEY_CHECKS=0'; + print ''; + $resql = $db->query($sql); + } - foreach ($listoftables as $table) - { - // do not convert llx_const if mysql encrypt/decrypt is used - if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) continue; + foreach ($listoftables as $table) + { + // do not convert llx_const if mysql encrypt/decrypt is used + if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) continue; - print ''; - print $table; - $sql = 'ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci'; - print ''; - if ($force_utf8_on_tables == 'confirmed') - { - $resql = $db->query($sql); - print ' - Done ('.($resql ? 'OK' : 'KO').')'; - } else print ' - Disabled'; - print ''; - } + print ''; + print $table; + $sql = 'ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci'; + print ''; + if ($force_utf8_on_tables == 'confirmed') + { + $resql = $db->query($sql); + print ' - Done ('.($resql ? 'OK' : 'KO').')'; + } else print ' - Disabled'; + print ''; + } - // Enable foreign key checking - if ($force_utf8_on_tables == 'confirmed') - { - $sql = 'SET FOREIGN_KEY_CHECKS=1'; - print ''; - $resql = $db->query($sql); - } - } else { - print 'Not available with database type '.$db->type.''; - } + // Enable foreign key checking + if ($force_utf8_on_tables == 'confirmed') + { + $sql = 'SET FOREIGN_KEY_CHECKS=1'; + print ''; + $resql = $db->query($sql); + } + } else { + print 'Not available with database type '.$db->type.''; + } } // if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { - /* + /* * This script is meant to be run when upgrading from a dolibarr version < 3.8 * to a newer version. * @@ -1354,113 +1354,113 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { $repair_link_dispatch_lines_supplier_order_lines = GETPOST('repair_link_dispatch_lines_supplier_order_lines', 'alpha'); - echo 'Repair llx_commande_fournisseur_dispatch.fk_commandefourndet'; - echo 'Repair in progress. This may take a while.'; + echo 'Repair llx_commande_fournisseur_dispatch.fk_commandefourndet'; + echo 'Repair in progress. This may take a while.'; - $sql_dispatch = 'SELECT * FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch WHERE COALESCE(fk_commandefourndet, 0) = 0'; - $db->begin(); - $resql_dispatch = $db->query($sql_dispatch); - $n_processed_rows = 0; - $errors = array(); - if ($resql_dispatch) { - if ($db->num_rows($resql_dispatch) == 0) { - echo 'Nothing to do.'; - exit; - } - while ($obj_dispatch = $db->fetch_object($resql_dispatch)) { - $sql_line = 'SELECT line.rowid, line.qty FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet AS line'; - $sql_line .= ' WHERE line.fk_commande = '.$obj_dispatch->fk_commande; - $sql_line .= ' AND line.fk_product = '.$obj_dispatch->fk_product; - $resql_line = $db->query($sql_line); + $sql_dispatch = 'SELECT * FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch WHERE COALESCE(fk_commandefourndet, 0) = 0'; + $db->begin(); + $resql_dispatch = $db->query($sql_dispatch); + $n_processed_rows = 0; + $errors = array(); + if ($resql_dispatch) { + if ($db->num_rows($resql_dispatch) == 0) { + echo 'Nothing to do.'; + exit; + } + while ($obj_dispatch = $db->fetch_object($resql_dispatch)) { + $sql_line = 'SELECT line.rowid, line.qty FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet AS line'; + $sql_line .= ' WHERE line.fk_commande = '.$obj_dispatch->fk_commande; + $sql_line .= ' AND line.fk_product = '.$obj_dispatch->fk_product; + $resql_line = $db->query($sql_line); - // s’il y a plusieurs lignes avec le même produit sur cette commande fournisseur, - // on divise la ligne de dispatch en autant de lignes qu’on en a sur la commande pour le produit - // et on met la quantité de la ligne dans la limite du "budget" indiqué par dispatch.qty + // s’il y a plusieurs lignes avec le même produit sur cette commande fournisseur, + // on divise la ligne de dispatch en autant de lignes qu’on en a sur la commande pour le produit + // et on met la quantité de la ligne dans la limite du "budget" indiqué par dispatch.qty - $remaining_qty = $obj_dispatch->qty; - $first_iteration = true; - if (!$resql_line) { - echo 'Unable to find a matching supplier order line for dispatch #'.$obj_dispatch->rowid.''; - $errors[] = $sql_line; - $n_processed_rows++; - continue; - } - if ($db->num_rows($resql_line) == 0) continue; - while ($obj_line = $db->fetch_object($resql_line)) { - if (!$remaining_qty) break; - if (!$obj_line->rowid) { - continue; - } - $qty_for_line = min($remaining_qty, $obj_line->qty); - if ($first_iteration) { - $sql_attach = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; - $sql_attach .= ' SET fk_commandefourndet = '.$obj_line->rowid.', qty = '.$qty_for_line; - $sql_attach .= ' WHERE rowid = '.$obj_dispatch->rowid; - $first_iteration = false; - } else { - $sql_attach_values = array( - $obj_dispatch->fk_commande, - $obj_dispatch->fk_product, - $obj_line->rowid, - $qty_for_line, - $obj_dispatch->fk_entrepot, - $obj_dispatch->fk_user, - $obj_dispatch->datec ? '"'.$db->escape($obj_dispatch->datec).'"' : 'NULL', - $obj_dispatch->comment ? '"'.$db->escape($obj_dispatch->comment).'"' : 'NULL', - $obj_dispatch->status ?: 'NULL', - $obj_dispatch->tms ? '"'.$db->escape($obj_dispatch->tms).'"' : 'NULL', - $obj_dispatch->batch ?: 'NULL', - $obj_dispatch->eatby ? '"'.$db->escape($obj_dispatch->eatby).'"' : 'NULL', - $obj_dispatch->sellby ? '"'.$db->escape($obj_dispatch->sellby).'"' : 'NULL' - ); - $sql_attach_values = join(', ', $sql_attach_values); + $remaining_qty = $obj_dispatch->qty; + $first_iteration = true; + if (!$resql_line) { + echo 'Unable to find a matching supplier order line for dispatch #'.$obj_dispatch->rowid.''; + $errors[] = $sql_line; + $n_processed_rows++; + continue; + } + if ($db->num_rows($resql_line) == 0) continue; + while ($obj_line = $db->fetch_object($resql_line)) { + if (!$remaining_qty) break; + if (!$obj_line->rowid) { + continue; + } + $qty_for_line = min($remaining_qty, $obj_line->qty); + if ($first_iteration) { + $sql_attach = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; + $sql_attach .= ' SET fk_commandefourndet = '.$obj_line->rowid.', qty = '.$qty_for_line; + $sql_attach .= ' WHERE rowid = '.$obj_dispatch->rowid; + $first_iteration = false; + } else { + $sql_attach_values = array( + $obj_dispatch->fk_commande, + $obj_dispatch->fk_product, + $obj_line->rowid, + $qty_for_line, + $obj_dispatch->fk_entrepot, + $obj_dispatch->fk_user, + $obj_dispatch->datec ? '"'.$db->escape($obj_dispatch->datec).'"' : 'NULL', + $obj_dispatch->comment ? '"'.$db->escape($obj_dispatch->comment).'"' : 'NULL', + $obj_dispatch->status ?: 'NULL', + $obj_dispatch->tms ? '"'.$db->escape($obj_dispatch->tms).'"' : 'NULL', + $obj_dispatch->batch ?: 'NULL', + $obj_dispatch->eatby ? '"'.$db->escape($obj_dispatch->eatby).'"' : 'NULL', + $obj_dispatch->sellby ? '"'.$db->escape($obj_dispatch->sellby).'"' : 'NULL' + ); + $sql_attach_values = join(', ', $sql_attach_values); - $sql_attach = 'INSERT INTO '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; - $sql_attach .= ' (fk_commande, fk_product, fk_commandefourndet, qty, fk_entrepot, fk_user, datec, comment, status, tms, batch, eatby, sellby)'; - $sql_attach .= ' VALUES ('.$sql_attach_values.')'; - } + $sql_attach = 'INSERT INTO '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; + $sql_attach .= ' (fk_commande, fk_product, fk_commandefourndet, qty, fk_entrepot, fk_user, datec, comment, status, tms, batch, eatby, sellby)'; + $sql_attach .= ' VALUES ('.$sql_attach_values.')'; + } - if ($repair_link_dispatch_lines_supplier_order_lines == 'confirmed') - { - $resql_attach = $db->query($sql_attach); - } else { - $resql_attach = true; // Force success in test mode - } + if ($repair_link_dispatch_lines_supplier_order_lines == 'confirmed') + { + $resql_attach = $db->query($sql_attach); + } else { + $resql_attach = true; // Force success in test mode + } - if ($resql_attach) { - $remaining_qty -= $qty_for_line; - } else { - $errors[] = $sql_attach; - } + if ($resql_attach) { + $remaining_qty -= $qty_for_line; + } else { + $errors[] = $sql_attach; + } - $first_iteration = false; - } - $n_processed_rows++; + $first_iteration = false; + } + $n_processed_rows++; - // report progress every 256th row - if (!($n_processed_rows & 0xff)) { - echo 'Processed '.$n_processed_rows.' rows with '.count($errors).' errors…'."\n"; - flush(); - ob_flush(); - } - } - } else { - echo 'Unable to find any dispatch without an fk_commandefourndet.'."\n"; - echo $sql_dispatch."\n"; - } - echo 'Fixed '.$n_processed_rows.' rows with '.count($errors).' errors…'."\n"; - echo 'DONE.'."\n"; + // report progress every 256th row + if (!($n_processed_rows & 0xff)) { + echo 'Processed '.$n_processed_rows.' rows with '.count($errors).' errors…'."\n"; + flush(); + ob_flush(); + } + } + } else { + echo 'Unable to find any dispatch without an fk_commandefourndet.'."\n"; + echo $sql_dispatch."\n"; + } + echo 'Fixed '.$n_processed_rows.' rows with '.count($errors).' errors…'."\n"; + echo 'DONE.'."\n"; - if (count($errors)) { - $db->rollback(); - echo 'The transaction was rolled back due to errors: nothing was changed by the script.'; - } else { - $db->commit(); - } - $db->close(); + if (count($errors)) { + $db->rollback(); + echo 'The transaction was rolled back due to errors: nothing was changed by the script.'; + } else { + $db->commit(); + } + $db->close(); - echo '

SQL queries with errors:

'; - echo ''.join('', $errors).''; + echo '

SQL queries with errors:

'; + echo ''.join('', $errors).''; } print ''; @@ -1469,7 +1469,7 @@ print ''; if (empty($actiondone)) { - print '
'.$langs->trans("ErrorWrongParameters").'
'; + print '
'.$langs->trans("ErrorWrongParameters").'
'; } if ($oneoptionset) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 90db6718a3b..0e656c7514b 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -646,7 +646,7 @@ if (!defined('NOLOGIN')) exit; } else { // User is loaded, we may need to change language for him according to its choice - if (! empty($user->conf->MAIN_LANG_DEFAULT)) { + if (!empty($user->conf->MAIN_LANG_DEFAULT)) { $langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT); } } @@ -1879,14 +1879,14 @@ function top_menu_quickadd() $html = ''; // Define $dropDownQuickAddHtml $dropDownQuickAddHtml = ''; + $dropDownQuickAddHtml .= $langs->trans('QuickAdd'); + $dropDownQuickAddHtml .= '
'; - $dropDownQuickAddHtml.= '