diff --git a/ChangeLog b/ChangeLog index d028491db42..f6a1c949bf5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -42,6 +42,8 @@ FIX: #12041 FIX: #12054 FIX: #12083 FIX: #12088 +FIX: CVE-2019-17578 CVE-2019-17577 CVE-2019-17576 +FIX: Clean the + of categories on the product view only in POS module FIX: access to public interface when origin email has an alias. FIX: Alias name is not into the email recipient label. FIX: allow standalone credit note even if no invoice diff --git a/dev/initdata/generate-invoice.php b/dev/initdata/generate-invoice.php index bfdda2896a1..0c754b1c874 100755 --- a/dev/initdata/generate-invoice.php +++ b/dev/initdata/generate-invoice.php @@ -152,7 +152,7 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0) $fuser = new User($db); $fuser->fetch(mt_rand(1, 2)); $fuser->getRights(); - + $result=$object->create($fuser); if ($result >= 0) { diff --git a/dev/initdata/generate-proposal.php b/dev/initdata/generate-proposal.php index 30c9471a281..ad8cf6025bb 100755 --- a/dev/initdata/generate-proposal.php +++ b/dev/initdata/generate-proposal.php @@ -176,7 +176,7 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0) $fuser = new User($db); $fuser->fetch(mt_rand(1, 2)); $fuser->getRights(); - + $object->contactid = $contids[$socids[$socid]][0]; $object->socid = $socids[$socid]; $object->datep = $dates[mt_rand(1, count($dates)-1)]; @@ -200,7 +200,7 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0) } $xnbp++; } - + $result=$object->valid($fuser); if ($result > 0) { diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 32c44ce91e4..8c01eea6d99 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -201,7 +201,7 @@ - + diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index f43ca801c25..c0e45916922 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -29,6 +29,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; // Load translation files required by the page @@ -65,6 +66,8 @@ $year_current = $year_start; // Validate History $action = GETPOST('action', 'aZ09'); +$chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); + /* * Actions @@ -101,7 +104,7 @@ if ($action == 'validatehistory') { $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind - if ($db->type == 'pgsql') { + /*if ($db->type == 'pgsql') { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; @@ -114,16 +117,83 @@ if ($action == 'validatehistory') { $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; $sql1 .= " AND fd.fk_code_ventilation = 0"; - } + }*/ + + // Customer Invoice lines (must be same request than into page list.php for manual binding) + $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,"; + $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; + $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; + $sql.= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; + $sql.= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; + $sql.= " co.code as country_code, co.label as country_label,"; + $sql.= " s.tva_intra"; + $sql.= " FROM " . MAIN_DB_PREFIX . "facture as f"; + $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; + $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; + $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql.= " AND l.product_type <= 2"; dol_syslog('htdocs/accountancy/customer/index.php'); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); + $result = $db->query($sql); + if (! $result) { + $error++; setEventMessages($db->lasterror(), null, 'errors'); } else { + $num_lines = $db->num_rows($result); + + $isSellerInEEC = isInEEC($mysoc); + + $i = 0; + while ($i < min($num_lines, 10000)) { // No more than 10000 at once + $objp = $db->fetch_object($result); + + // Search suggested account for product/service + $suggestedaccountingaccountfor = ''; + if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $objp->code_sell_p = $objp->code_sell; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $objp->code_sell_p = $objp->code_sell_intra; + $objp->aarowid_suggest = $objp->aarowid_intra; + $suggestedaccountingaccountfor = 'eec'; + } else { // Foreign sale + $objp->code_sell_p = $objp->code_sell_export; + $objp->aarowid_suggest = $objp->aarowid_export; + $suggestedaccountingaccountfor = 'export'; + } + } + + if ($objp->aarowid_suggest > 0) + { + $sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; + $sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + + $resqlupdate = $db->query($sqlupdate); + if (! $resqlupdate) + { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + + $i++; + } + } + + if ($error) + { + $db->rollback(); + } + else { $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 3385eb99b0e..6a5196288e2 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -358,6 +358,7 @@ if ($result) { // Ref Invoice print '' . $facture_static->getNomUrl(1) . ''; + // Date invoice print '' . dol_print_date($db->jdate($objp->datef), 'day') . ''; // Ref Product @@ -377,7 +378,13 @@ if ($result) { print '' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . ''; - print '' . $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')'; + // Country + print ''; + if ($objp->country_code) + { + print $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')'; + } + print ''; print '' . $objp->tva_intra . ''; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index c15ace96ffc..d4cc5f59388 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -219,9 +219,9 @@ $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; +$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; +$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; +$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql.= " AND l.product_type <= 2"; // Add search filter like @@ -247,7 +247,7 @@ if (strlen(trim($search_account))) { $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("l.tva_tx", $search_vat, 1); + $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } $sql.=dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); if (strlen(trim($search_country))) { @@ -406,7 +406,7 @@ if ($result) { $isSellerInEEC = isInEEC($mysoc); - while ( $i < min($num_lines, $limit) ) { + while ($i < min($num_lines, $limit)) { $objp = $db->fetch_object($result); $objp->code_sell_l = ''; @@ -518,6 +518,7 @@ if ($result) { print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')); print ''; + // Country print ''; $labelcountry=($objp->country_code && ($langs->trans("Country".$objp->country_code)!="Country".$objp->country_code))?$langs->trans("Country".$objp->country_code):$objp->country_label; print $labelcountry; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index faa48ac9176..bfb6e7b02e4 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -27,6 +27,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; // Load translation files required by the page @@ -63,6 +64,7 @@ $year_current = $year_start; // Validate History $action = GETPOST('action', 'aZ09'); +$chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); /* @@ -99,7 +101,7 @@ if ($action == 'validatehistory') { $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind - if ($db->type == 'pgsql') { + /*if ($db->type == 'pgsql') { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; @@ -112,16 +114,85 @@ if ($action == 'validatehistory') { $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; $sql1 .= " AND fd.fk_code_ventilation = 0"; - } + }*/ + + // Supplier Invoice Lines (must be same request than into page list.php for manual binding) + $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; + $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; + $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; + $sql.= " aa.rowid as aarowid,"; + $sql.= " co.code as country_code, co.label as country_label,"; + $sql.= " s.tva_intra"; + $sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; + $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; + $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql.= " AND l.product_type <= 2"; dol_syslog('htdocs/accountancy/supplier/index.php'); - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); + $result = $db->query($sql); + if (! $result) { + $error++; setEventMessages($db->lasterror(), null, 'errors'); } else { + $num_lines = $db->num_rows($result); + + $isSellerInEEC = isInEEC($mysoc); + + $i = 0; + while ($i < min($num_lines, 10000)) { // No more than 10000 at once + $objp = $db->fetch_object($result); + + // Search suggested account for product/service + $suggestedaccountingaccountfor = ''; + if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $objp->code_buy_p = $objp->code_buy; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + //$objp->code_buy_p = $objp->code_buy_intra; + $objp->code_buy_p = $objp->code_buy; + //$objp->aarowid_suggest = $objp->aarowid_intra; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = 'eec'; + } else { // Foreign sale + //$objp->code_buy_p = $objp->code_buy_export; + $objp->code_buy_p = $objp->code_buy; + //$objp->aarowid_suggest = $objp->aarowid_export; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = 'export'; + } + } + + if ($objp->aarowid_suggest > 0) + { + $sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; + $sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + + $resqlupdate = $db->query($sqlupdate); + if (! $resqlupdate) + { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + + $i++; + } + } + + if ($error) + { + $db->rollback(); + } + else { $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index a815e5b858b..730aecf9dc1 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -367,6 +367,7 @@ if ($result) { print $objp->invoice_label; print ''; + // Date invoice print '' . dol_print_date($db->jdate($objp->datef), 'day') . ''; // Ref product @@ -387,7 +388,12 @@ if ($result) { print '' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . ''; - print '' . $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')'; + print ''; + if ($objp->country_code) + { + print $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')'; + } + print ''; print '' . $objp->tva_intra . ''; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index f43749f6958..3c61b7a0608 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -222,7 +222,7 @@ $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; +$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql.= " AND l.product_type <= 2"; // Add search filter like @@ -307,8 +307,8 @@ if ($result) { $arrayofselected=is_array($toselect)?$toselect:array(); $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); 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); @@ -463,7 +463,7 @@ if ($result) { print '' . dol_print_date($db->jdate($objp->datef), 'day') . ''; - // Ref product + // Ref Product print ''; if ($product_static->id > 0) print $product_static->getNomUrl(1); @@ -471,7 +471,7 @@ if ($result) { print ''; // Description - print ''; + print ''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description); diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 6820521a6a4..a45f94760da 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -999,7 +999,7 @@ else print ''; // EMail - print ''.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').''; + print ''.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').''; // Address print ''.$langs->trans("Address").''; @@ -1036,13 +1036,13 @@ else } // Pro phone - print ''.$langs->trans("PhonePro").''; + print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").''; // Personal phone - print ''.$langs->trans("PhonePerso").''; + print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").''; // Mobile phone - print ''.$langs->trans("PhoneMobile").''; + print ''.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").''; if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { @@ -1258,7 +1258,7 @@ else print ''; // EMail - print ''.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">'; + print ''.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">'; // Address print ''.$langs->trans("Address").''; @@ -1288,13 +1288,13 @@ else } // Pro phone - print ''.$langs->trans("PhonePro").'phone).'">'; + print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").'phone).'">'; // Personal phone - print ''.$langs->trans("PhonePerso").'phone_perso).'">'; + print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").'phone_perso).'">'; // Mobile phone - print ''.$langs->trans("PhoneMobile").'phone_mobile).'">'; + print ''.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").'phone_mobile).'">'; if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index acf62a97068..3ac400509c9 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2129,7 +2129,11 @@ class Adherent extends CommonObject // Only picto if ($withpictoimg > 0) $picto=''.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).''; // Picto must be a photo - else $picto=''.Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg==-3?'small':''), 'mini', 0, 1).''; + else { + $picto=''; + $picto.=Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg==-3?'small':''), 'mini', 0, 1); + $picto.=''; + } $result.=$picto; } if ($withpictoimg > -2 && $withpictoimg != 2) @@ -2172,83 +2176,46 @@ class Adherent extends CommonObject // phpcs:enable global $langs; $langs->load("members"); - if ($mode == 0) + + if ($statut == -1) { - if ($statut == -1) return $langs->trans("MemberStatusDraft"); - elseif ($statut >= 1) { - if ($need_subscription == 0) return $langs->trans("MemberStatusNoSubscription"); - elseif (! $date_end_subscription) return $langs->trans("MemberStatusActive"); - elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLate"); - else return $langs->trans("MemberStatusPaid"); - } - elseif ($statut == 0) return $langs->trans("MemberStatusResiliated"); + $statusType = 'status0'; + $labelstatut = $langs->trans("MemberStatusDraft"); + $labelstatutShort = $langs->trans("MemberStatusDraftShort"); } - elseif ($mode == 1) + elseif ($statut >= 1) { + if ($need_subscription == 0) + { + $statusType = 'status4'; + $labelstatut = $langs->trans("MemberStatusNoSubscription"); + $labelstatutShort = $langs->trans("MemberStatusNoSubscriptionShort"); + } + elseif (! $date_end_subscription) + { + $statusType = 'status1'; + $labelstatut = $langs->trans("MemberStatusActive"); + $labelstatutShort = $langs->trans("MemberStatusActiveShort"); + } + elseif ($date_end_subscription < time()) + { + $statusType = 'status3'; + $labelstatut = $langs->trans("MemberStatusActiveLate"); + $labelstatutShort = $langs->trans("MemberStatusActiveLateShort"); + } + else { + $statusType = 'status4'; + $labelstatut = $langs->trans("MemberStatusPaid"); + $labelstatutShort = $langs->trans("MemberStatusPaidShort"); + } + } + elseif ($statut == 0) { - if ($statut == -1) return $langs->trans("MemberStatusDraftShort"); - elseif ($statut >= 1) { - if ($need_subscription == 0) return $langs->trans("MemberStatusNoSubscription"); - elseif (! $date_end_subscription) return $langs->trans("MemberStatusActiveShort"); - elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLateShort"); - else return $langs->trans("MemberStatusPaidShort"); - } - elseif ($statut == 0) return $langs->trans("MemberStatusResiliatedShort"); - } - elseif ($mode == 2) - { - if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'), 'statut0').' '.$langs->trans("MemberStatusDraftShort"); - elseif ($statut >= 1) { - if ($need_subscription == 0) return img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4').' '.$langs->trans("MemberStatusNoSubscriptionShort"); - elseif (! $date_end_subscription) return img_picto($langs->trans('MemberStatusActive'), 'statut1').' '.$langs->trans("MemberStatusActiveShort"); - elseif ($date_end_subscription < time()) return img_picto($langs->trans('MemberStatusActiveLate'), 'statut3').' '.$langs->trans("MemberStatusActiveLateShort"); - else return img_picto($langs->trans('MemberStatusPaid'), 'statut4').' '.$langs->trans("MemberStatusPaidShort"); - } - elseif ($statut == 0) return img_picto($langs->trans('MemberStatusResiliated'), 'statut5').' '.$langs->trans("MemberStatusResiliatedShort"); - } - elseif ($mode == 3) - { - if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'), 'statut0'); - elseif ($statut >= 1) { - if ($need_subscription == 0) return img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4'); - elseif (! $date_end_subscription) return img_picto($langs->trans('MemberStatusActive'), 'statut1'); - elseif ($date_end_subscription < time()) return img_picto($langs->trans('MemberStatusActiveLate'), 'statut3'); - else return img_picto($langs->trans('MemberStatusPaid'), 'statut4'); - } - elseif ($statut == 0) return img_picto($langs->trans('MemberStatusResiliated'), 'statut5'); - } - elseif ($mode == 4) - { - if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'), 'statut0').' '.$langs->trans("MemberStatusDraft"); - elseif ($statut >= 1) { - if ($need_subscription == 0) return img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4').' '.$langs->trans("MemberStatusNoSubscription"); - elseif (! $date_end_subscription) return img_picto($langs->trans('MemberStatusActive'), 'statut1').' '.$langs->trans("MemberStatusActive"); - elseif ($date_end_subscription < time()) return img_picto($langs->trans('MemberStatusActiveLate'), 'statut3').' '.$langs->trans("MemberStatusActiveLate"); - else return img_picto($langs->trans('MemberStatusPaid'), 'statut4').' '.$langs->trans("MemberStatusPaid"); - } - if ($statut == 0) return img_picto($langs->trans('MemberStatusResiliated'), 'statut5').' '.$langs->trans("MemberStatusResiliated"); - } - elseif ($mode == 5) - { - if ($statut == -1) return ''.$langs->trans("MemberStatusDraftShort").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0'); - elseif ($statut >= 1) { - if ($need_subscription == 0) return ''.$langs->trans("MemberStatusNoSubscriptionShort").' '.img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4'); - elseif (! $date_end_subscription) return ''.$langs->trans("MemberStatusActiveShort").' '.img_picto($langs->trans('MemberStatusActive'), 'statut1'); - elseif ($date_end_subscription < time()) return ''.$langs->trans("MemberStatusActiveLateShort").' '.img_picto($langs->trans('MemberStatusActiveLate'), 'statut3'); - else return ''.$langs->trans("MemberStatusPaidShort").' '.img_picto($langs->trans('MemberStatusPaid'), 'statut4'); - } - if ($statut == 0) return ''.$langs->trans("MemberStatusResiliated").' '.img_picto($langs->trans('MemberStatusResiliated'), 'statut5'); - } - elseif ($mode == 6) - { - if ($statut == -1) return $langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0'); - if ($statut >= 1) { - if ($need_subscription == 0) return $langs->trans("MemberStatusNoSubscription").' '.img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4'); - elseif (! $date_end_subscription) return $langs->trans("MemberStatusActive").' '.img_picto($langs->trans('MemberStatusActive'), 'statut1'); - elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLate").' '.img_picto($langs->trans('MemberStatusActiveLate'), 'statut3'); - else return $langs->trans("MemberStatusPaid").' '.img_picto($langs->trans('MemberStatusPaid'), 'statut4'); - } - if ($statut == 0) return $langs->trans("MemberStatusResiliated").' '.img_picto($langs->trans('MemberStatusResiliated'), 'statut5'); + $statusType = 'status6'; + $labelstatut = $langs->trans("MemberStatusResiliated"); + $labelstatutShort = $langs->trans("MemberStatusResiliatedShort"); } + + return dolGetStatus($labelstatut, $labelstatutShort, '', $statusType, $mode); } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index b858693255e..f8f21d2868a 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -227,10 +227,8 @@ $sql = "SELECT c.subscription, c.dateadh as dateh"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; $sql.= " WHERE d.entity IN (".getEntity('adherent').")"; $sql.= " AND d.rowid = c.fk_adherent"; -if(isset($date_select) && $date_select != '') -{ - $sql .= " AND c.dateadh LIKE '".$date_select."%'"; -} + + $result = $db->query($sql); if ($result) { @@ -251,21 +249,33 @@ if ($result) print '
'; print ''; print ''; -print ''; -print ''; +print ''; +print ''; print ''; print ''; print "\n"; krsort($Total); +$i = 0; foreach ($Total as $key=>$value) { - print ''; + if ($i >= 8) + { + print ''; + print ""; + print ""; + print ""; + print ""; + print "\n"; + break; + } + print ''; print ""; print ""; print ""; print ""; print "\n"; + $i++; } // Total diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 877dde34af0..0bcc11bf351 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -681,6 +681,7 @@ while ($i < min($num, $limit)) $memberstatic->datefin= $datefin; $memberstatic->socid = $obj->fk_soc; $memberstatic->photo = $obj->photo; + $memberstatic->morphy = $obj->morphy; if (! empty($obj->fk_soc)) { $memberstatic->fetch_thirdparty(); diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 912995d7817..09a4e95c0ae 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -476,7 +476,7 @@ if (! empty($conf->barcode->enabled)) { } // Logo -print ''; // Logo (squarred) -print '
'.$langs->trans("Subscriptions").''.$langs->trans("Number").''.$langs->trans("Year").''.$langs->trans("Subscriptions").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
...
$key".$Number[$key]."".price($value)."".price(price2num($value/$Number[$key], 'MT'))."
'; +print '
'; print '
'; print ''; print ''; @@ -493,7 +493,7 @@ print '
'; print '
'; +print '
'; print ''; + print ''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['p.import_key']['checked'])) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index e87333e4c01..d618a0702c8 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -32,6 +32,8 @@ if ($cancel) { + /*var_dump($cancel); + var_dump($backtopage);exit;*/ if (! empty($backtopage)) { header("Location: ".$backtopage); @@ -80,7 +82,8 @@ if ($action == 'add' && ! empty($permissiontoadd)) if ($result > 0) { // Creation OK - $urltogo=$backtopage?str_replace('__ID__', $result, $backtopage):$backurlforlist; + $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); exit; } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index c81c013bc08..7d8d621ff92 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -71,7 +71,9 @@ if (! $error && $massaction == 'confirm_presend') $listofobjectid=array(); $listofobjectthirdparties=array(); + $listofobjectcontacts = array(); $listofobjectref=array(); + $contactidtosend=array(); $attachedfilesThirdpartyObj=array(); $oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0); @@ -97,11 +99,21 @@ if (! $error && $massaction == 'confirm_presend') if ($objecttmp->element == 'holiday') $thirdpartyid=$objecttmp->fk_user; if (empty($thirdpartyid)) $thirdpartyid=0; - $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid; - $listofobjectref[$thirdpartyid][$toselectid]=$objecttmp; - } - } - } + if ($objectclass == 'Facture') { + $tmparraycontact = array(); + $tmparraycontact = $objecttmp->liste_contact(-1, 'external', 0, 'BILLING'); + if (is_array($tmparraycontact) && count($tmparraycontact) > 0) { + foreach ($tmparraycontact as $data_email) { + $listofobjectcontacts[$toselectid][$data_email['id']] = $data_email['email']; + } + } + } + + $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid; + $listofobjectref[$thirdpartyid][$toselectid]=$objecttmp; + } + } + } // Check mandatory parameters if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email)) @@ -248,6 +260,21 @@ if (! $error && $massaction == 'confirm_presend') $fuser->fetch($objectobj->fk_user); $sendto = $fuser->email; } + elseif ($objectobj->element == 'facture' && !empty($listofobjectcontacts[$objectid])) + { + $emails_to_sends = array(); + $objectobj->fetch_thirdparty(); + $contactidtosend=array(); + foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) { + $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid, 'email'); + if (!in_array($contactemailid, $contactidtosend)) { + $contactidtosend[] = $contactemailid; + } + } + if (count($emails_to_sends) > 0) { + $sendto = implode(',', $emails_to_sends); + } + } else { $objectobj->fetch_thirdparty(); @@ -498,8 +525,8 @@ if (! $error && $massaction == 'confirm_presend') } $actionmsg2=''; - // Initialisation donnees - $objectobj2->sendtoid = 0; + // Initialisation donnees + $objectobj2->sendtoid = (empty($contactidtosend)?0:$contactidtosend); $objectobj2->actionmsg = $actionmsg; // Long text $objectobj2->actionmsg2 = $actionmsg2; // Short text $objectobj2->fk_element = $objid2; diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index 84defbfd163..edbceec50fd 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -163,22 +163,24 @@ class Ccountry // extends CommonObject /** * Load object in memory from database * - * @param int $id Id object - * @param string $code Code + * @param int $id Id object + * @param string $code Code + * @param string $code_iso Code ISO * @return int >0 if OK, 0 if not found, <0 if KO */ - public function fetch($id, $code = '') + public function fetch($id, $code = '', $code_iso = '') { global $langs; - $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.code,"; - $sql.= " t.code_iso,"; - $sql.= " t.label,"; - $sql.= " t.active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_country as t"; - if ($id) $sql.= " WHERE t.rowid = ".$id; - elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; + $sql = "SELECT"; + $sql.= " t.rowid,"; + $sql.= " t.code,"; + $sql.= " t.code_iso,"; + $sql.= " t.label,"; + $sql.= " t.active"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_country as t"; + if ($id) $sql.= " WHERE t.rowid = ".$id; + elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; + elseif ($code_iso) $sql.= " WHERE t.code_iso = '".$this->db->escape($code_iso)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index ee5b97c502a..20889e1a742 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -224,15 +224,15 @@ abstract class CommonDocGenerator $extrafields->fetch_name_optionals_label($object->table_element, true); $object->fetch_optionals(); - foreach($extrafields->attribute_label as $key=>$label) + foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label) { - if($extrafields->attribute_type[$key] == 'price') + if($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_'.$key] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); } - elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { - $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; + $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } $array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key])); } @@ -298,15 +298,15 @@ abstract class CommonDocGenerator $extrafields->fetch_name_optionals_label($object->table_element, true); $object->fetch_optionals(); - foreach($extrafields->attribute_label as $key => $label) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $label) { - if ($extrafields->attribute_type[$key] == 'price') + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); } - elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { - $object->array_options['options_' . $key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_' . $key]]; + $object->array_options['options_' . $key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_' . $key]]; } $array_contact = array_merge($array_contact, array($array_key.'_options_' . $key => $object->array_options['options_'. $key])); } @@ -643,11 +643,11 @@ abstract class CommonDocGenerator $array_key.'_tracking_number'=>$object->tracking_number, $array_key.'_tracking_url'=>$object->tracking_url, $array_key.'_shipping_method'=>$object->listmeths[0]['libelle'], - $array_key.'_weight'=>$object->trueWeight.' '.measuring_units_string($object->weight_units, 'weight'), - $array_key.'_width'=>$object->trueWidth.' '.measuring_units_string($object->width_units, 'size'), - $array_key.'_height'=>$object->trueHeight.' '.measuring_units_string($object->height_units, 'size'), - $array_key.'_depth'=>$object->trueDepth.' '.measuring_units_string($object->depth_units, 'size'), - $array_key.'_size'=>$calculatedVolume.' '.measuring_units_string(0, 'volume'), + $array_key.'_weight'=>$object->trueWeight.' '.measuringUnitString(0, 'weight', $object->weight_units), + $array_key.'_width'=>$object->trueWidth.' '.measuringUnitString(0, 'size', $object->width_units), + $array_key.'_height'=>$object->trueHeight.' '.measuringUnitString(0, 'size', $object->height_units), + $array_key.'_depth'=>$object->trueDepth.' '.measuringUnitString(0, 'size', $object->depth_units), + $array_key.'_size'=>$calculatedVolume.' '.measuringUnitString(0, 'volume'), ); // Add vat by rates @@ -701,10 +701,10 @@ abstract class CommonDocGenerator 'line_price_ht'=>price($line->total_ht), 'line_price_ttc'=>price($line->total_ttc), 'line_price_vat'=>price($line->total_tva), - 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuring_units_string($line->weight_units, 'weight'), - 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuring_units_string($line->length_units, 'size'), - 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'), - 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'), + 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuringUnitString(0, 'weight', $line->weight_units), + 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuringUnitString(0, 'size', $line->length_units), + 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuringUnitString(0, 'surface', $line->surface_units), + 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuringUnitString(0, 'volume', $line->volume_units), ); // Retrieve extrafields @@ -765,30 +765,30 @@ abstract class CommonDocGenerator { // phpcs:enable global $conf; - foreach($extrafields->attribute_label as $key=>$label) + foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label) { - if($extrafields->attribute_type[$key] == 'price') + if($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]); $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); //Add value to store price with currency $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); } - elseif($extrafields->attribute_type[$key] == 'select') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select') { - $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; + $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } - elseif($extrafields->attribute_type[$key] == 'checkbox') { + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { $valArray=explode(',', $object->array_options['options_'.$key]); $output=array(); - foreach($extrafields->attribute_param[$key]['options'] as $keyopt=>$valopt) { + foreach($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) { if (in_array($keyopt, $valArray)) { $output[]=$valopt; } } $object->array_options['options_'.$key] = implode(', ', $output); } - elseif($extrafields->attribute_type[$key] == 'date') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'date') { if (strlen($object->array_options['options_'.$key])>0) { @@ -806,7 +806,7 @@ abstract class CommonDocGenerator $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); } - elseif($extrafields->attribute_type[$key] == 'datetime') + elseif($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime') { $datetime = $object->array_options['options_'.$key]; $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour'):''); // using company output language @@ -815,7 +815,7 @@ abstract class CommonDocGenerator $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); } - elseif($extrafields->attribute_type[$key] == 'link') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'link') { $id = $object->array_options['options_'.$key]; if ($id != "") diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index d834fcfe943..98a40c73c0b 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -538,7 +538,6 @@ abstract class CommonInvoice extends CommonObject } } - return dolGetStatus($labelstatut, $labelstatutShort, '', $statusType, $mode); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9625d31fc77..f8e65e2bb40 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1889,13 +1889,19 @@ abstract class CommonObject } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - if ($this->table_element == 'actioncomm') + if (! empty($this->fields['fk_project'])) // Common case + { + if ($projectid) $sql.= ' SET fk_project = '.$projectid; + else $sql.= ' SET fk_project = NULL'; + $sql.= ' WHERE rowid = '.$this->id; + } + elseif ($this->table_element == 'actioncomm') // Special case for actioncomm { if ($projectid) $sql.= ' SET fk_project = '.$projectid; else $sql.= ' SET fk_project = NULL'; $sql.= ' WHERE id = '.$this->id; } - else + else // Special case for old architecture objects { if ($projectid) $sql.= ' SET fk_projet = '.$projectid; else $sql.= ' SET fk_projet = NULL'; @@ -3824,17 +3830,18 @@ abstract class CommonObject $totalWeight += $weight * $qty * $trueWeightUnit; } else { - if ($weight_units == 99) { - // conversion 1 Pound = 0.45359237 KG - $trueWeightUnit = 0.45359237; - $totalWeight += $weight * $qty * $trueWeightUnit; - } elseif ($weight_units == 98) { - // conversion 1 Ounce = 0.0283495 KG - $trueWeightUnit = 0.0283495; - $totalWeight += $weight * $qty * $trueWeightUnit; - } - else + if ($weight_units == 99) { + // conversion 1 Pound = 0.45359237 KG + $trueWeightUnit = 0.45359237; + $totalWeight += $weight * $qty * $trueWeightUnit; + } elseif ($weight_units == 98) { + // conversion 1 Ounce = 0.0283495 KG + $trueWeightUnit = 0.0283495; + $totalWeight += $weight * $qty * $trueWeightUnit; + } + else { $totalWeight += $weight * $qty; // This may be wrong if we mix different units + } } if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) { @@ -5563,16 +5570,20 @@ abstract class CommonObject $type=''; $param = array(); $param['options']=array(); - $size =$this->fields[$key]['size']; + $reg=array(); + $size = $this->fields[$key]['size']; // Because we work on extrafields - if(preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)){ - $param['options']=array($reg[1].':'.$reg[2]=>'N'); - $type ='link'; - } elseif(preg_match('/^link:(.*):(.*)/i', $val['type'], $reg)) { - $param['options']=array($reg[1].':'.$reg[2]=>'N'); + 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'); + $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(); @@ -6085,16 +6096,26 @@ abstract class CommonObject } elseif ($type == 'link') { - $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' + $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]' + $param_list_array = explode(':', $param_list[0]); $showempty=(($required && $default != '')?0:1); - $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty); - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + + $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', '', '', 0, empty($val['disabled'])?0:1); + + if (! empty($param_list_array[2])) // If we set to add a create button { - list($class,$classfile)=explode(':', $param_list[0]); - if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); - else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.$class.'_card.php', 1); - $out.=''; - // TODO Add Javascript code to add input fields contents to new elements urls + if (! GETPOSTISSET('backtopage') && empty($val['disabled'])) // To avoid to open several infinitely the 'Create Object' button and to avoid to have button if field is protected by a "disabled". + { + list($class,$classfile)=explode(':', $param_list[0]); + if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); + else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1); + $paramforthenewlink = ''; + $paramforthenewlink .= (GETPOSTISSET('action')?'&action='.GETPOST('action', 'aZ09'):''); + $paramforthenewlink .= (GETPOSTISSET('id')?'&id='.GETPOST('id', 'int'):''); + $paramforthenewlink .= '&fk_'.strtolower($class).'=--IDFORBACKTOPAGE--'; + // TODO Add Javascript code to add input fields already filled into $paramforthenewlink so we won't loose them when going back to main page + $out.=''; + } } } elseif ($type == 'password') @@ -6174,6 +6195,7 @@ abstract class CommonObject $label = $val['label']; $type = $val['type']; $size = $val['css']; + $reg = array(); // Convert var to be able to share same code than showOutputField of extrafields if (preg_match('/varchar\((\d+)\)/', $type, $reg)) @@ -6189,7 +6211,9 @@ abstract class CommonObject $computed=$val['computed']; $unique=$val['unique']; $required=$val['required']; - $param=$val['param']; + $param=array(); + $param['options']=array(); + if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 72aa4bc4265..9ba90d00e62 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -353,6 +353,12 @@ class Conf $this->propal->dir_output=$rootfordata."/propale"; $this->propal->dir_temp=$rootfordata."/propale/temp"; + // For backward compatibility + $this->banque->multidir_output = array($this->entity => $rootfordata."/bank"); + $this->banque->multidir_temp = array($this->entity => $rootfordata."/bank/temp"); + $this->banque->dir_output=$rootfordata."/bank"; + $this->banque->dir_temp=$rootfordata."/bank/temp"; + // For medias storage $this->medias->multidir_output = array($this->entity => $rootfordata."/medias"); $this->medias->multidir_temp = array($this->entity => $rootfordata."/medias/temp"); diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 1837f82a2a4..e37849ff99a 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -234,8 +234,6 @@ class CUnits // extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - $records=array(); - $sql = 'SELECT'; $sql.= " t.rowid,"; $sql.= " t.code,"; @@ -249,8 +247,8 @@ class CUnits // extends CommonObject $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key=='t.rowid' || $key=='t.active') { - $sqlwhere[] = $key . '='. $value; + if ($key=='t.rowid' || $key=='t.active' || $key=='t.scale') { + $sqlwhere[] = $key . '='. (int) $value; } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; @@ -273,6 +271,7 @@ class CUnits // extends CommonObject if (!empty($limit)) { $sql .= ' ' . $this->db->plimit($limit, $offset); } + $resql = $this->db->query($sql); if ($resql) { $this->records=array(); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index f59aaab7bfa..6807e75ba80 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1573,9 +1573,9 @@ class ExtraFields if ($type == 'date') $out.=' (YYYY-MM-DD)'; elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; */ - if (! empty($help)) { + if (! empty($help) && $keyprefix != 'search_options_') { $out .= $form->textwithpicto('', $help, 1, 'help', '', 0, 3); - } + } return $out; } @@ -2088,6 +2088,7 @@ class ExtraFields else { $value_key=GETPOST("options_".$key); + if (in_array($key_type, array('link')) && $value_key == '-1') $value_key = ''; } $object->array_options["options_".$key]=$value_key; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 61558434105..865e06a4478 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2425,7 +2425,7 @@ class Form $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 . ' ' . measuring_units_string($objp->length_units, 'size'); + $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) { @@ -2802,7 +2802,7 @@ class Form $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 . ' ' . measuring_units_string($objp->length_units, 'size'); + $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) { @@ -2827,15 +2827,6 @@ class Form } } - $opt = '\n"; @@ -5614,7 +5618,7 @@ class Form }; var d = new Date();"; } - + // Generate the date part, depending on the use or not of the javascript calendar if($addnowlink==1) // server time expressed in user time setup { @@ -5815,7 +5819,7 @@ class Form * Generic method to select a component from a combo list. * This is the generic method that will replace all specific existing methods. * - * @param string $objectdesc Objectclassname:Objectclasspath + * @param string $objectdesc ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]] * @param string $htmlname Name of HTML select component * @param int $preselectedvalue Preselected value (ID of element) * @param string $showempty ''=empty values not allowed, 'string'=value show if we allow empty values (for example 'All', ...) @@ -5824,10 +5828,11 @@ class Form * @param string $morecss More CSS * @param string $moreparams More params provided to ajax call * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) + * @param int $disabled 1=Html component is disabled * @return string Return HTML string * @see selectForFormsList() select_thirdparty */ - public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0) + public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0) { global $conf, $user; @@ -5836,12 +5841,16 @@ class Form $InfoFieldList = explode(":", $objectdesc); $classname=$InfoFieldList[0]; $classpath=$InfoFieldList[1]; + $addcreatebuttonornot=empty($InfoFieldList[2])?0:$InfoFieldList[2]; + $filter=empty($InfoFieldList[3])?'':$InfoFieldList[3]; + if (! empty($classpath)) { dol_include_once($classpath); if ($classname && class_exists($classname)) { $objecttmp = new $classname($this->db); + $objecttmp->filter = $filter; } } if (! is_object($objecttmp)) @@ -5854,12 +5863,12 @@ class Form if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode='company'; $confkeyforautocompletemode=strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT - dol_syslog(get_class($this)."::selectForForms", LOG_DEBUG); + dol_syslog(get_class($this)."::selectForForms object->filter=".$objecttmp->filter, LOG_DEBUG); $out=''; if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->$confkeyforautocompletemode) && ! $forcecombo) { - $objectdesc=$classname.':'.$classpath; + $objectdesc=$classname.':'.$classpath.':'.$addcreatebuttonornot.':'.$filter; $urlforajaxcall = DOL_URL_ROOT.'/core/ajax/selectobject.php'; // No immediate load of all database @@ -5868,22 +5877,50 @@ class Form $out.= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array()); $out.= ''; if ($placeholder) $placeholder=' placeholder="'.$placeholder.'"'; - $out.= ''; + $out.= ''; } else { - // Immediate load of all database - $out.=$this->selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo); + // Immediate load of table record. Note: filter is inside $objecttmp->filter + $out.=$this->selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled); } return $out; } + /** + * Function to forge a SQL criteria + * + * @param array $matches Array of found string by regex search. Example: "t.ref:like:'SO-%'" or "t.date_creation:<:'20160101'" or "t.nature:is:NULL" + * @return string Forged criteria. Example: "t.field like 'abc%'" + */ + protected static function forgeCriteriaCallback($matches) + { + global $db; + + //dol_syslog("Convert matches ".$matches[1]); + if (empty($matches[1])) return ''; + $tmp=explode(':', $matches[1]); + if (count($tmp) < 3) return ''; + + $tmpescaped=$tmp[2]; + $regbis = array(); + if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) + { + $tmpescaped = "'".$db->escape($regbis[1])."'"; + } + else + { + $tmpescaped = $db->escape($tmpescaped); + } + return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped; + } + /** * Output html form to select an object. * Note, this function is called by selectForForms or by ajax selectobject.php * - * @param Object $objecttmp Object + * @param Object $objecttmp Object to knwo the table to scan for combo. * @param string $htmlname Name of HTML select component * @param int $preselectedvalue Preselected value (ID of element) * @param string $showempty ''=empty values not allowed, 'string'=value show if we allow empty values (for example 'All', ...) @@ -5893,13 +5930,16 @@ class Form * @param string $moreparams More params provided to ajax call * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) * @param int $outputmode 0=HTML select string, 1=Array + * @param int $disabled 1=Html component is disabled * @return string Return HTML string * @see selectForForms() */ - public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0) + public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0) { global $conf, $langs, $user; + //print "$objecttmp->filter, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled"; + $prefixforautocompletemode=$objecttmp->element; if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode='company'; $confkeyforautocompletemode=strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT @@ -5923,19 +5963,28 @@ class Form // Search data $sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX .$objecttmp->table_element." as t"; if ($objecttmp->ismultientitymanaged == 2) - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE 1=1"; if(! empty($objecttmp->ismultientitymanaged)) $sql.= " AND t.entity IN (".getEntity($objecttmp->table_element).")"; - if ($objecttmp->ismultientitymanaged == 1 && ! empty($user->societe_id)) - { - if ($objecttmp->element == 'societe') $sql.= " AND t.rowid = ".$user->societe_id; - else $sql.= " AND t.fk_soc = ".$user->societe_id; + if ($objecttmp->ismultientitymanaged == 1 && ! empty($user->socid)) { + if ($objecttmp->element == 'societe') $sql.= " AND t.rowid = ".$user->socid; + else $sql.= " AND t.fk_soc = ".$user->socid; } if ($searchkey != '') $sql.=natural_search(explode(',', $fieldstoshow), $searchkey); - if ($objecttmp->ismultientitymanaged == 2) - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND t.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($objecttmp->ismultientitymanaged == 2) { + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND t.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + } + if ($objecttmp->filter) { // Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + /*if (! DolibarrApi::_checkFilters($objecttmp->filter)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$objecttmp->filter); + }*/ + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'Form::forgeCriteriaCallback', $objecttmp->filter).")"; + } $sql.=$this->db->order($fieldstoshow, "ASC"); //$sql.=$this->db->plimit($limit, 0); + //print $sql; // Build output string $resql=$this->db->query($sql); @@ -5948,7 +5997,7 @@ class Form } // Construct $out and $outarray - $out.= ''."\n"; // Warning: Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. Seems it is no more true with selec2 v4 $textifempty=' '; @@ -7331,11 +7380,16 @@ class Form else { $nophoto='/public/theme/common/nophoto.png'; - if (in_array($modulepart, array('userphoto','contact'))) // For module that are "physical" users + if (in_array($modulepart, array('userphoto','contact','memberphoto'))) // For module that are "physical" users { - $nophoto='/public/theme/common/user_anonymous.png'; - if ($object->gender == 'man') $nophoto='/public/theme/common/user_man.png'; - if ($object->gender == 'woman') $nophoto='/public/theme/common/user_woman.png'; + if ($modulepart == 'memberphoto' && strpos($object->morphy, 'mor') !== false) { + $nophoto='/public/theme/common/company.png'; + } + else { + $nophoto='/public/theme/common/user_anonymous.png'; + if ($object->gender == 'man') $nophoto='/public/theme/common/user_man.png'; + if ($object->gender == 'woman') $nophoto='/public/theme/common/user_woman.png'; + } } if (! empty($conf->gravatar->enabled) && $email) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 8a0341135c7..d231dacab87 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -231,10 +231,10 @@ class FormFile if (empty($usewithoutform)) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; } $out .= '
'; @@ -1078,10 +1078,11 @@ class FormFile * @param string $sortorder Sort order ('ASC' or 'DESC') * @param int $disablemove 1=Disable move button, 0=Position move is possible. * @param int $addfilterfields Add line with filters + * @param int $disablecrop Disable crop feature on images (-1 = auto, prefer to set it explicitely to 0 or 1) * @return int <0 if KO, nb of files shown if OK * @see list_of_autoecmfiles() */ - 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) + 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 global $user, $conf, $langs, $hookmanager; @@ -1089,8 +1090,11 @@ class FormFile global $dolibarr_main_url_root; global $form; - $disablecrop=1; - if (in_array($modulepart, array('bom','expensereport','holiday','member','project','product','produit','service','societe','tax','ticket','user'))) $disablecrop=0; + if ($disablecrop == -1) + { + $disablecrop=1; + if (in_array($modulepart, array('bank','bom','expensereport','holiday','member','project','product','produit','service','societe','tax','ticket','user'))) $disablecrop=0; + } // Define relative path used to store the file if (empty($relativepath)) @@ -1168,6 +1172,7 @@ class FormFile if (GETPOST('action', 'aZ09') == 'editfile' && $permtoeditline) { print ''; + print ''; print ''; print ''; print ''; @@ -1485,6 +1490,7 @@ class FormFile if (! empty($addfilterfields)) { print ''; + print ''; print ''; } @@ -1772,10 +1778,13 @@ class FormFile $res = $link->fetchAll($links, $object->element, $object->id, $sortfield, $sortorder); $param .= (isset($object->id)?'&id=' . $object->id : ''); + print ''."\n"; + // Show list of associated links print load_fiche_titre($langs->trans("LinkedFiles")); print ''; + print ''; print '
'; print ''; print ''; diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 4f1fad15343..e5acf71857e 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -18,10 +18,10 @@ * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * -* @author PrestaShop SA -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA +* @author PrestaShop SA +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA * PrestaShop Webservice Library * @package PrestaShopWebservice */ @@ -395,52 +395,6 @@ class PrestaShopWebservice self::checkStatusCode($request['status_code']);// check the response validity return self::parseXML($request['response']); } - - /** - * Delete (DELETE) a resource. - * Unique parameter must take :

- * 'resource' => Resource name
- * 'id' => ID or array which contains IDs of a resource(s) you want to delete

- * - * delete(array('resource' => 'orders', 'id' => 1)); - * // Following code will not be executed if an exception is thrown. - * echo 'Successfully deleted.'; - * } - * catch (PrestaShopWebserviceException $ex) - * { - * echo 'Error : '.$ex->getMessage(); - * } - * ?> - * - * - * @param array $options Array representing resource to delete. - * @return boolean True - */ - public function delete($options) - { - if (isset($options['url'])) { - $url = $options['url']; - } elseif (isset($options['resource']) && isset($options['id'])) { - if (is_array($options['id'])) - $url = $this->url.'/api/'.$options['resource'].'/?id=['.implode(',', $options['id']).']'; - else - $url = $this->url.'/api/'.$options['resource'].'/'.$options['id']; - } - if (isset($options['id_shop'])) { - $url .= '&id_shop='.$options['id_shop']; - } - if (isset($options['id_group_shop'])) { - $url .= '&id_group_shop='.$options['id_group_shop']; - } - $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'DELETE')); - self::checkStatusCode($request['status_code']);// check the response validity - return true; - } } /** diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 79d152fb7bf..61fb0448c8b 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -65,27 +65,27 @@ complete_substitutions_array($substitutionarrayfortest, $langs); if ($action == 'update' && empty($_POST["cancel"])) { - dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT", 'int'), 'chaine', 0, '', $conf->entity); // Send mode parameters - dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE", 'aZ09'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW", 'none'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS", 'int'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_ENABLED", GETPOST("MAIN_MAIL_EMAIL_DKIM_ENABLED"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_DOMAIN", GETPOST("MAIN_MAIL_EMAIL_DKIM_DOMAIN"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_SELECTOR", GETPOST("MAIN_MAIL_EMAIL_DKIM_SELECTOR"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", GETPOST("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_ENABLED", GETPOST("MAIN_MAIL_EMAIL_DKIM_ENABLED", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_DOMAIN", GETPOST("MAIN_MAIL_EMAIL_DKIM_DOMAIN", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_SELECTOR", GETPOST("MAIN_MAIL_EMAIL_DKIM_SELECTOR", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", GETPOST("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", 'alphanohtml'), 'chaine', 0, '', $conf->entity); // Content parameters - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE', GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE', GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE', 'alphanohtml'), 'chaine', 0, '', $conf->entity); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; @@ -101,8 +101,8 @@ $mode='emailfortest'; $trackid=(($action == 'testhtml')?"testhtml":"test"); include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; -if ($action == 'presend' && GETPOST('trackid') == 'test') $action='test'; -if ($action == 'presend' && GETPOST('trackid') == 'testhtml') $action='testhtml'; +if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') $action='test'; +if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') $action='testhtml'; @@ -821,7 +821,7 @@ else $formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM); $formmail->fromid=$user->id; $formmail->fromalsorobot=1; - $formmail->fromtype=(GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); + $formmail->fromtype=(GETPOSTISSET('fromtype')?GETPOST('fromtype', 'aZ09'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); $formmail->withfromreadonly=1; $formmail->withsubstit=1; $formmail->withfrom=1; @@ -847,7 +847,7 @@ else $formmail->param["returnurl"]=$_SERVER["PHP_SELF"]; // Init list of files - if (GETPOST("mode")=='init') + if (GETPOST("mode", "aZ09")=='init') { $formmail->clear_attached_files(); } diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 7660144f7ca..074216dee3e 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -178,6 +178,7 @@ class DolibarrApi unset($object->lines[$i]->cond_reglement); unset($object->lines[$i]->fk_delivery_address); unset($object->lines[$i]->fk_projet); + unset($object->lines[$i]->fk_project); unset($object->lines[$i]->thirdparty); unset($object->lines[$i]->user); unset($object->lines[$i]->model_pdf); @@ -290,6 +291,7 @@ class DolibarrApi if (count($tmp) < 3) return ''; $tmpescaped=$tmp[2]; + $regbis = array(); if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) { $tmpescaped = "'".$db->escape($regbis[1])."'"; diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 60f5a54eeba..50102b76b93 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -197,13 +197,64 @@ class Setup extends DolibarrApi * @throws RestException */ public function getCountryByID($id, $lang = '') + { + return $this->_fetchCcountry($id, '', '', $lang); + } + + /** + * Get country by Code. + * + * @param string $code Code of country + * @param string $lang Code of the language the name of the + * country must be translated to + * @return array Array of cleaned object properties + * + * @url GET dictionary/countries/byCode/{code} + * + * @throws RestException + */ + public function getCountryByCode($code, $lang = '') + { + return $this->_fetchCcountry('', $code, '', $lang); + } + + /** + * Get country by Iso. + * + * @param string $iso ISO of country + * @param string $lang Code of the language the name of the + * country must be translated to + * @return array Array of cleaned object properties + * + * @url GET dictionary/countries/byISO/{iso} + * + * @throws RestException + */ + public function getCountryByISO($iso, $lang = '') + { + return $this->_fetchCcountry('', '', $iso, $lang); + } + + /** + * Get country. + * + * @param int $id ID of country + * @param string $code Code of country + * @param string $iso ISO of country + * @param string $lang Code of the language the name of the + * country must be translated to + * @return array Array of cleaned object properties + * + * @throws RestException + */ + private function _fetchCcountry($id, $code = '', $iso = '', $lang = '') { $country = new Ccountry($this->db); - if ($country->fetch($id) < 0) { + $result = $country->fetch($id, $code, $iso); + if ($result < 0) { throw new RestException(503, 'Error when retrieving country : '.$country->error); - } - elseif ($country->fetch($id) == 0) { + } elseif ($result == 0) { throw new RestException(404, 'country not found'); } @@ -320,6 +371,66 @@ class Setup extends DolibarrApi } } + /** + * Get the list of shipment methods. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param int $active Payment term is active or not {@min 0} {@max 1} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" + * + * @return array List of shipment methods + * + * @url GET dictionary/shipment_methods + * + * @throws RestException + */ + public function getListOfShipmentMethods($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + { + $list = array(); + $sql = "SELECT t.rowid, t.code, t.libelle, t.description, t.tracking"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t"; + $sql.= " WHERE t.active = ".$active; + // 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.= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(503, 'Error when retrieving list of shipment methods : '.$this->db->lasterror()); + } + + return $list; + } + /** * Get the list of events types. * diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 459bd2d8edc..916939b378e 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -615,7 +615,7 @@ if ($rowid > 0) if (empty($reshook)) { print '

'; - foreach($extrafields->attribute_label as $key=>$label) + foreach($extrafields->attributes[$object->element]['label'] as $key=>$label) { if (isset($_POST["options_" . $key])) { if (is_array($_POST["options_" . $key])) { diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 0949fa1a334..17fae31ef7d 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -79,6 +79,7 @@ $permissionnote=$user->rights->bom->write; // Used by the include of actions_set $permissiondellink=$user->rights->bom->write; // Used by the include of actions_dellink.inc.php $permissionedit=$user->rights->bom->write; // Used by the include of actions_lineupdown.inc.php $permissiontoadd=$user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0); /* @@ -93,11 +94,11 @@ if (empty($reshook)) { $error=0; - $permissiontoadd = $user->rights->bom->write; - $permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0); $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php'; - if (empty($backtopage)) { - if (empty($id) && $action != 'add' && $action != 'create') $backtopage = $backurlforlist; + + if (empty($backtopage) || ($cancel && empty($id))) { + //var_dump($backurlforlist);exit; + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; else $backtopage = DOL_URL_ROOT.'/bom/bom_card.php?id='.($id > 0 ? $id : '__ID__'); } $triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record @@ -218,7 +219,7 @@ if ($action == 'create') dol_fiche_head(array(), ''); - print '
'."\n"; + print '
'."\n"; // Common attributes include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; @@ -252,7 +253,9 @@ if (($id || $ref) && $action == 'edit') dol_fiche_head(); - print '
'."\n"; + //$object->fields['keyfield']['disabled'] = 1; + + print '
'."\n"; // Common attributes include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 46473d52ddb..6e192a06545 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -454,12 +454,12 @@ while ($i < min($num, $limit)) $cssforfield=(empty($val['css'])?'':$val['css']); if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; - + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; - + if (! empty($arrayfields['t.'.$key]['checked'])) { print ''; diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index f6b25d0cca7..471fb4f2cce 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -100,7 +100,7 @@ class Boms extends DolibarrApi $obj_ret = array(); $tmpobject = new BOM($db); - + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 07ae81e2994..b3163511150 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -91,7 +91,7 @@ class BOM extends CommonObject 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'noteditable'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of BOM", 'showoncombobox'=>'1',), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'1',), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp'), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp'), 'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth75imp'), 'efficiency' => array('type'=>'real', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>-1, 'default'=>1, 'position'=>100, 'notnull'=>0, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'), 'duration' => array('type'=>'real', 'label'=>'EstimatedDuration', 'enabled'=>1, 'visible'=>-1, 'position'=>101, 'notnull'=>-1, 'css'=>'maxwidth50imp', 'help'=>'EstimatedDurationDesc'), @@ -817,34 +817,10 @@ class BOM extends CommonObject $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle'); - } + $statusType = 'status'.$status; + if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + + return dolGetStatus($this->labelstatus[$status], $this->labelstatus[$status], '', $statusType, $mode); } /** diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index f569516e535..f68372c721d 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -92,9 +92,9 @@ $coldisplay++; echo $line->efficiency; print ''; -if ($this->statut == 0 && ($object_rights->write) && $action != 'selectlines' ) { - print '"; @@ -625,8 +634,8 @@ else print ''; print ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 5cd3902b7d1..cfecc31427b 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1082,38 +1082,27 @@ class Account extends CommonObject /** * Return label of given object status * - * @param int $statut Id statut + * @param int $status Id status * @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 */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; $langs->load('banks'); - if ($statut == self::STATUS_OPEN) { + if ($status == self::STATUS_OPEN) { $label = $langs->trans("StatusAccountOpened"); - $picto = img_picto($label, 'statut4'); + $labelshort = $langs->trans("StatusAccountOpened"); + $statusType = 'status4'; } else { $label = $langs->trans("StatusAccountClosed"); - $picto = img_picto($label, 'statut5'); + $labelshort = $langs->trans("StatusAccountClosed"); + $statusType = 'status5'; } - if ($mode == 2) { - return $picto.' '.$label; - } elseif ($mode == 3) { - return $picto; - } elseif ($mode == 4) { - return $picto.' '.$label; - } elseif ($mode == 5) { - return $label.' '.$picto; - } elseif ($mode == 6) { - return $label.' '.$picto; - } - - //There is no short mode for this label - return $label; + return dolGetStatus($label, $labelshort, '', $statusType, $mode); } @@ -2318,11 +2307,11 @@ class AccountLine extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut + * @param int $status Id statut * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -2330,33 +2319,33 @@ class AccountLine extends CommonObject /* if ($mode == 0) { - if ($statut==0) return $langs->trans("ActivityCeased"); - if ($statut==1) return $langs->trans("InActivity"); + if ($status==0) return $langs->trans("ActivityCeased"); + if ($status==1) return $langs->trans("InActivity"); } if ($mode == 1) { - if ($statut==0) return $langs->trans("ActivityCeased"); - if ($statut==1) return $langs->trans("InActivity"); + if ($status==0) return $langs->trans("ActivityCeased"); + if ($status==1) return $langs->trans("InActivity"); } if ($mode == 2) { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); + if ($status==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); + if ($status==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); } if ($mode == 3) { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); + if ($status==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); + if ($status==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); } if ($mode == 4) { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); + if ($status==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); + if ($status==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); } if ($mode == 5) { - if ($statut==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); - if ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); + if ($status==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); + if ($status==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); }*/ } diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 32bfe66f7d1..67a38e03cc6 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -52,8 +52,6 @@ if ($user->societe_id) { } if ($user->societe_id) $socid = $user->societe_id; -$result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', - $fieldtype); // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); @@ -69,8 +67,10 @@ if (!$sortfield) $sortfield = "name"; $object = new Account($db); -if ($id) - $object->fetch($id); +if ($id > 0 || ! empty($ref)) $object->fetch($id, $ref); + +$result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); + /* * Actions @@ -105,14 +105,14 @@ if ($id > 0 || !empty($ref)) { // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', - $sortfield, - (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); $totalsize = 0; foreach ($filearray as $key => $file) { $totalsize+=$file['size']; } + $morehtmlref = ''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 6a143d4a8d1..1b06a0e222b 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -98,13 +98,16 @@ $arrayfields=array( 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* diff --git a/htdocs/compta/deplacement/info.php b/htdocs/compta/deplacement/info.php index a0accd11a87..510675265a0 100644 --- a/htdocs/compta/deplacement/info.php +++ b/htdocs/compta/deplacement/info.php @@ -47,15 +47,15 @@ if ($id) $object = new Deplacement($db); $object->fetch($id); $object->info($id); - + $head = trip_prepare_head($object); - + dol_fiche_head($head, 'info', $langs->trans("TripCard"), 0, 'trip'); print '
'; - $coldisplay++; +if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' ) { + print ''; + $coldisplay++; if (($line->info_bits & 2) == 2 || ! empty($disableedit)) { } else { print 'id.'#line_'.$line->id.'">'.img_edit().''; diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 8a26b12f15b..abcb3145a80 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -66,6 +66,7 @@ function printBookmarksList() $ret.= ''."\n"; $ret.= '
'; + $ret.= ''; $ret.= '
'; $object->user_creation=$object->user_creat; $object->date_creation=$object->date_creat; @@ -70,7 +70,7 @@ if ($object->fetch($id) >= 0) $object->date_validation=$object->date_valid; dol_print_object_info($object, 0); //print '
'; - + dol_fiche_end(); } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 70cd74ac149..0f84fdd5552 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -58,7 +58,7 @@ if (!empty($conf->variants->enabled)) { } // Load translation files required by the page -$langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'sendings')); +$langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'sendings', 'other')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); if (! empty($conf->margin->enabled)) $langs->load('margins'); @@ -121,6 +121,7 @@ $usercancreateorder = $user->rights->commande->creer; $usercancreateinvoice = $user->rights->facture->creer; $usercancreatecontract = $user->rights->contrat->creer; $usercancreateintervention = $user->rights->ficheinter->creer; +$usercancreatepurchaseorder = $user->rights->fournisseur->commande->creer; $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php @@ -2499,13 +2500,23 @@ if ($action == 'create') print '' . $langs->trans('SendMail') . ''; } - // Create an order + // Create a sale order if (! empty($conf->commande->enabled) && $object->statut == Propal::STATUS_SIGNED) { if ($usercancreateorder) { print '' . $langs->trans("AddOrder") . ''; } } + // Create a purchase order + if (! empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL)) + { + if (! empty($conf->fournisseur->enabled) && $object->statut == Propal::STATUS_SIGNED) { + if ($usercancreatepurchaseorder) { + print '' . $langs->trans("AddPurchaseOrder") . ''; + } + } + } + // Create an intervention if (! empty($conf->service->enabled) && ! empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) { if ($usercancreateintervention) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 3854c51e29d..e645bf3cee6 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -106,6 +106,8 @@ $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancr $usercancancel = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler))); $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send); +$usercancreatepurchaseorder = $user->rights->fournisseur->commande->creer; + $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissionedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php @@ -2566,6 +2568,16 @@ if ($action == 'create' && $usercancreate) print '' . $langs->trans("AddAction") . ''; }*/ + // Create a purchase order + if (! empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) + { + if (! empty($conf->fournisseur->enabled) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { + if ($usercancreatepurchaseorder) { + print '' . $langs->trans("AddPurchaseOrder") . ''; + } + } + } + // Create intervention if ($conf->ficheinter->enabled) { $langs->load("interventions"); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 61278b9b9f5..71eb5faa6c9 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -157,13 +157,16 @@ $arrayfields=array( 'b.conciliated'=>array('label'=>$langs->trans("Conciliated"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile'?1:0), 'position'=>1020), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index fb6d723ad7e..702d3bbc113 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -47,12 +47,9 @@ $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); // Security check -if (isset($_GET["id"]) || isset($_GET["ref"])) -{ - $id = isset($_GET["id"])?GETPOST("id"):(isset($_GET["ref"])?GETPOST("ref"):''); -} -$fieldid = isset($_GET["ref"])?'ref':'rowid'; -if ($user->societe_id) $socid=$user->societe_id; +$id = GETPOST("id", 'int') ? GETPOST("id", 'int'): GETPOST('ref', 'alpha'); +$fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid'; + $result=restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); $object = new Account($db); @@ -79,12 +76,12 @@ if ($action == 'add') // Create account $object = new Account($db); - $object->ref = dol_sanitizeFileName(trim($_POST["ref"])); - $object->label = trim($_POST["label"]); - $object->courant = $_POST["type"]; - $object->clos = $_POST["clos"]; - $object->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1; - $object->url = $_POST["url"]; + $object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha'))); + $object->label = trim(GETPOST("label", 'alphanohtml')); + $object->courant = $_POST["type"]; + $object->clos = $_POST["clos"]; + $object->rappro = (GETPOST("norappro", 'alpha') ? 0 : 1); + $object->url = trim(GETPOST("url", 'alpha')); $object->bank = trim($_POST["bank"]); $object->code_banque = trim($_POST["code_banque"]); @@ -93,27 +90,34 @@ if ($action == 'add') $object->cle_rib = trim($_POST["cle_rib"]); $object->bic = trim($_POST["bic"]); $object->iban = trim($_POST["iban"]); - $object->domiciliation = trim($_POST["domiciliation"]); + $object->domiciliation = trim(GETPOST("domiciliation", "nohtml")); - $object->proprio = trim($_POST["proprio"]); - $object->owner_address = trim($_POST["owner_address"]); + $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); + $object->owner_address = trim(GETPOST("owner_address", 'nohtml')); - $account_number = GETPOST('account_number', 'alpha'); - if (empty($account_number) || $account_number == '-1') { $object->account_number = ''; } else { $object->account_number = $account_number; } + $account_number = GETPOST('account_number', 'alphanohtml'); + if (empty($account_number) || $account_number == '-1') + { + $object->account_number = ''; + } + else + { + $object->account_number = $account_number; + } $fk_accountancy_journal = GETPOST('fk_accountancy_journal', 'int'); if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = ''; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; } $object->solde = $_POST["solde"]; - $object->date_solde = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $object->date_solde = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST('reday', 'int'), GETPOST("reyear", 'int')); $object->currency_code = trim($_POST["account_currency_code"]); - $object->state_id = $_POST["account_state_id"]; - $object->country_id = $_POST["account_country_id"]; + $object->state_id = GETPOST("account_state_id", 'int'); + $object->country_id = GETPOST("account_country_id", 'int'); $object->min_allowed = GETPOST("account_min_allowed", 'int'); $object->min_desired = GETPOST("account_min_desired", 'int'); - $object->comment = trim(GETPOST("account_comment")); + $object->comment = trim(GETPOST("account_comment", 'none')); $object->fk_user_author = $user->id; @@ -176,14 +180,14 @@ if ($action == 'update') // Update account $object = new Account($db); - $object->fetch(GETPOST("id")); + $object->fetch(GETPOST("id", 'int')); - $object->ref = dol_string_nospecial(trim($_POST["ref"])); - $object->label = trim($_POST["label"]); + $object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha'))); + $object->label = trim(GETPOST("label", 'alphanohtml')); $object->courant = $_POST["type"]; $object->clos = $_POST["clos"]; - $object->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1; - $object->url = trim($_POST["url"]); + $object->rappro = (GETPOST("norappro", 'alpha') ? 0 : 1); + $object->url = trim(GETPOST("url", 'alpha')); $object->bank = trim($_POST["bank"]); $object->code_banque = trim($_POST["code_banque"]); @@ -192,10 +196,10 @@ if ($action == 'update') $object->cle_rib = trim($_POST["cle_rib"]); $object->bic = trim($_POST["bic"]); $object->iban = trim($_POST["iban"]); - $object->domiciliation = trim($_POST["domiciliation"]); + $object->domiciliation = trim(GETPOST("domiciliation", "nohtml")); - $object->proprio = trim($_POST["proprio"]); - $object->owner_address = trim($_POST["owner_address"]); + $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); + $object->owner_address = trim(GETPOST("owner_address", 'nohtml')); $account_number = GETPOST('account_number', 'alpha'); if (empty($account_number) || $account_number == '-1') @@ -211,12 +215,12 @@ if ($action == 'update') $object->currency_code = trim($_POST["account_currency_code"]); - $object->state_id = $_POST["account_state_id"]; - $object->country_id = $_POST["account_country_id"]; + $object->state_id = GETPOST("account_state_id", 'int'); + $object->country_id = GETPOST("account_country_id", 'int'); $object->min_allowed = GETPOST("account_min_allowed", 'int'); $object->min_desired = GETPOST("account_min_desired", 'int'); - $object->comment = trim(GETPOST("account_comment")); + $object->comment = trim(GETPOST("account_comment", 'none')); if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) { @@ -289,7 +293,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights-> } else { - setEventMessages($account->error, $account->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action=''; } } @@ -410,10 +414,15 @@ if ($action == 'create') { print '
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1); + + $arrayselected = array(); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT); - foreach($cats as $cat) { - $arrayselected[] = $cat->id; + if (is_array($cats)) + { + foreach($cats as $cat) { + $arrayselected[] = $cat->id; + } } print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); print "
'.$langs->trans("Conciliable").''; $conciliate=$object->canBeConciliated(); - if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; - elseif ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')'; + if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; + elseif ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')'; else print ($object->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')')); print '
'; dol_print_object_info($object); print '
'; - + print ''; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index cabd2c75fa4..fe88c9ec717 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2566,6 +2566,7 @@ $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); $formmargin = new FormMargin($db); +$soc = new Societe($db); $paymentstatic=new Paiement($db); $bankaccountstatic = new Account($db); if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } @@ -2586,7 +2587,6 @@ if ($action == 'create') print load_fiche_titre($langs->trans('NewBill'), '', 'invoicing'); - $soc = new Societe($db); if ($socid > 0) $res = $soc->fetch($socid); @@ -3465,7 +3465,6 @@ elseif ($id > 0 || ! empty($ref)) $result = $object->fetch_thirdparty(); - $soc = new Societe($db); $result=$soc->fetch($object->socid); if ($result < 0) dol_print_error($db); $selleruserevenustamp = $mysoc->useRevenueStamp(); diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index a4e115dfdb0..37614f7e36e 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -34,7 +34,7 @@ class Cpaiement * @var string Id to identify managed objects */ public $element = 'cpaiement'; - + /** * @var string Name of table without prefix where object is stored */ diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 026e7d73b77..4fd98fab90c 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke @@ -202,6 +202,7 @@ if (empty($reshook)) } } $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'); @@ -240,6 +241,22 @@ if (empty($reshook)) // Categories association $contcats = GETPOST('contcats', 'array'); $object->setCategories($contcats); + + // Add mass emailing flag into table mailing_unsubscribe + if (GETPOST('no_email', 'int') && $object->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); + if (empty($obj->nb)) + { + $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); + } + } + } } } @@ -370,6 +387,7 @@ if (empty($reshook)) $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'); @@ -404,6 +422,35 @@ if (empty($reshook)) $categories = GETPOST('contcats', 'array'); $object->setCategories($categories); + $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); + } + + $object->no_email = $no_email; + } + $object->old_lastname=''; $object->old_firstname=''; $action = 'view'; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index cf6af3c5926..4a6090d16f8 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -80,25 +80,41 @@ class Contact extends CommonObject 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), ); - public $civility_id; // In fact we store civility_code + public $civility_id; // In fact we store civility_code public $civility_code; public $civility; + + /** + * Address + * @var string + */ public $address; public $zip; public $town; public $state_id; // Id of department - public $state_code; // Code of department + public $state_code; // Code of department public $state; // Label of department public $poste; // Position public $socid; // fk_soc - public $statut; // 0=inactif, 1=actif + public $statut; // 0=inactif, 1=actif public $code; + + /** + * Email + * @var string + */ public $email; + /** + * Unsuscribe all : 1 = contact has globaly unsubscribe of all mass emailings + * @var int + */ + public $no_email; + /** * @var array array of socialnetworks */ @@ -433,6 +449,7 @@ class Contact extends CommonObject if (! $error && $this->user_id > 0) { + // If contact is linked to a user $tmpobj = new User($this->db); $tmpobj->fetch($this->user_id); $usermustbemodified = 0; @@ -1294,45 +1311,34 @@ class Contact extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut + * @param int $status Id statut * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle */ - public function LibStatut($statut, $mode) + public function LibStatut($status, $mode) { // phpcs:enable global $langs; - if ($mode == 0) + if (empty($this->status) || empty($this->statusshort)) { - if ($statut==0 || $statut==5) return $langs->trans('Disabled'); - elseif ($statut==1 || $statut==4) return $langs->trans('Enabled'); - } - elseif ($mode == 1) - { - if ($statut==0 || $statut==5) return $langs->trans('Disabled'); - elseif ($statut==1 || $statut==4) return $langs->trans('Enabled'); - } - elseif ($mode == 2) - { - if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); - } - elseif ($mode == 3) - { - if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"'); - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"'); - } - elseif ($mode == 4) - { - if ($statut==0) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); - } - elseif ($mode == 5) - { - if ($statut==0 || $statut==5) return ''.$langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"'); - elseif ($statut==1 || $statut==4) return ''.$langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"'); + $this->labelstatus[0] = 'ActivityCeased'; + $this->labelstatusshort[0] = 'ActivityCeased'; + $this->labelstatus[5] = 'ActivityCeased'; + $this->labelstatusshort[5] = 'ActivityCeased'; + $this->labelstatus[1] = 'InActivity'; + $this->labelstatusshort[1] = 'InActivity'; + $this->labelstatus[4] = 'InActivity'; + $this->labelstatusshort[4] = 'InActivity'; } + + $statusType = 'status4'; + if ($status==0 || $status==5) $statusType = 'status5'; + + $label = $langs->trans($this->labelstatus[$status]); + $labelshort = $langs->trans($this->labelstatusshort[$status]); + + return dolGetStatus($label, $labelshort, '', $statusType, $mode); } @@ -1340,14 +1346,14 @@ class Contact extends CommonObject /** * Return translated label of Public or Private * - * @param int $statut Type (0 = public, 1 = private) + * @param int $status Type (0 = public, 1 = private) * @return string Label translated */ - public function LibPubPriv($statut) + public function LibPubPriv($status) { // phpcs:enable global $langs; - if ($statut=='1') return $langs->trans('ContactPrivate'); + if ($status=='1') return $langs->trans('ContactPrivate'); else return $langs->trans('ContactPublic'); } @@ -1402,18 +1408,18 @@ class Contact extends CommonObject /** * Change status of a user * - * @param int $statut Status to set + * @param int $status Status to set * @return int <0 if KO, 0 if nothing is done, >0 if OK */ - public function setstatus($statut) + public function setstatus($status) { global $conf,$langs,$user; $error=0; // Check parameters - if ($this->statut == $statut) return 0; - else $this->statut = $statut; + if ($this->statut == $status) return 0; + else $this->statut = $status; $this->db->begin(); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 6bdd8d841c9..13c1a992a37 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -191,15 +191,18 @@ if (! empty($conf->socialnetworks->enabled)) { } } // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + -$object=new Contact($db); if (($id > 0 || ! empty($ref)) && $action != 'add') { $result=$object->fetch($id, $ref); @@ -950,7 +953,7 @@ while ($i < min($num, $limit)) // Status if (! empty($arrayfields['p.statut']['checked'])) { - print '
'.$contactstatic->getLibStatut(3).''.$contactstatic->getLibStatut(5).'
'; print ''; diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index 396991b6612..2da23504440 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -3900,4 +3900,4 @@ class lessc_formatter_lessjs extends lessc_formatter_classic { public $breakSelectors = true; public $assignSeparator = ": "; public $selectorSeparator = ","; -} \ No newline at end of file +} diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index cd6f64c3242..d950f92b3c2 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -496,10 +496,10 @@ class SMTPs return $_retVal; } } - + // Default authentication method is LOGIN if (empty($conf->global->MAIL_SMTP_AUTH_TYPE)) $conf->global->MAIL_SMTP_AUTH_TYPE = 'LOGIN'; - + // Send Authentication to Server // Check for errors along the way switch ($conf->global->MAIL_SMTP_AUTH_TYPE) { diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 3780ab35b06..e54de5a91d2 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -586,18 +586,18 @@ class Translate /** * Return text translated of text received as parameter (and encode it into HTML) - * Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif - * et si toujours pas trouve, il est retourne tel quel - * Les parametres de cette methode peuvent contenir de balises HTML. + * If there is no match for this text, we look in alternative file and if still not found, + * it is returned as it is + * The parameters of this method can contain HTML tags * * @param string $key Key to translate - * @param string $param1 chaine de param1 - * @param string $param2 chaine de param2 - * @param string $param3 chaine de param3 - * @param string $param4 chaine de param4 + * @param string $param1 param1 string + * @param string $param2 param2 string + * @param string $param3 param3 string + * @param string $param4 param4 string * @param int $maxsize Max length of text * @return string Translated string (encoded into HTML entities and UTF8) - */ + */ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $maxsize = 0) { global $conf; @@ -647,9 +647,9 @@ class Translate /** * Return translated value of a text string - * Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif - * et si toujours pas trouve, il est retourne tel quel. - * Parameters of this method must not contains any HTML tags. + * If there is no match for this text, we look in alternative file and if still not found + * it is returned as is. + * Parameters of this method must not contain any HTML tags. * * @param string $key Key to translate * @param string $param1 chaine de param1 @@ -667,9 +667,9 @@ class Translate /** * Return translated value of a text string - * Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif - * et si toujours pas trouve, il est retourne tel quel. - * No convert to encoding charset of lang object is done. + * If there is no match for this text, we look in alternative file and if still not found, + * it is returned as is. + * No conversion to encoding charset of lang object is done. * Parameters of this method must not contains any HTML tags. * * @param string $key Key to translate @@ -781,7 +781,7 @@ class Translate if (preg_match('/^[a-z]+_[A-Z]+/i', $dir)) { $this->load("languages"); - + if (! empty($conf->global->MAIN_LANGUAGES_ALLOWED) && ! in_array($dir, explode(',', $conf->global->MAIN_LANGUAGES_ALLOWED)) ) continue; if ($usecode == 2) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 43f1cfc1831..21bff7bc8b3 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1732,13 +1732,10 @@ function company_admin_prepare_head() $head[$h][2] = 'company'; $h++; - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) - { - $head[$h][0] = DOL_URL_ROOT."/admin/openinghours.php"; - $head[$h][1] = $langs->trans("OpeningHours"); - $head[$h][2] = 'openinghours'; - $h++; - } + $head[$h][0] = DOL_URL_ROOT."/admin/openinghours.php"; + $head[$h][1] = $langs->trans("OpeningHours"); + $head[$h][2] = 'openinghours'; + $h++; $head[$h][0] = DOL_URL_ROOT."/admin/accountant.php"; $head[$h][1] = $langs->trans("Accountant"); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b36733a91f2..a00c8d73d97 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4652,7 +4652,7 @@ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round $unit = $forceunitoutput; }*/ - $ret=price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuring_units_string(0, $type, $unit); + $ret=price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuringUnitString(0, $type, $unit); return $ret; } @@ -5945,6 +5945,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF__'] = '__REF__'; $substitutionarray['__REF_CLIENT__'] = '__REF_CLIENT__'; $substitutionarray['__REF_SUPPLIER__'] = '__REF_SUPPLIER__'; + $substitutionarray['__NOTE_PUBLIC__'] = '__NOTE_PUBLIC__'; + $substitutionarray['__NOTE_PRIVATE__'] = '__NOTE_PRIVATE__'; $substitutionarray['__EXTRAFIELD_XXX__'] = '__EXTRAFIELD_XXX__'; if (! empty($conf->societe->enabled)) @@ -5952,7 +5954,21 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__'; $substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__'; $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = '__THIRDPARTY_NAME_ALIAS__'; + $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = '__THIRDPARTY_CODE_CLIENT__'; + $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = '__THIRDPARTY_CODE_FOURNISSEUR__'; $substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__'; + $substitutionarray['__THIRDPARTY_PHONE__'] = '__THIRDPARTY_PHONE__'; + $substitutionarray['__THIRDPARTY_FAX__'] = '__THIRDPARTY_FAX__'; + $substitutionarray['__THIRDPARTY_ADRESSE__'] = '__THIRDPARTY_ADRESSE__'; + $substitutionarray['__THIRDPARTY_ZIP__'] = '__THIRDPARTY_ZIP__'; + $substitutionarray['__THIRDPARTY_TOWN__'] = '__THIRDPARTY_TOWN__'; + $substitutionarray['__THIRDPARTY_SIREN__'] = '__THIRDPARTY_SIREN__'; + $substitutionarray['__THIRDPARTY_SIRET__'] = '__THIRDPARTY_SIRET__'; + $substitutionarray['__THIRDPARTY_APE__'] = '__THIRDPARTY_APE__'; + $substitutionarray['__THIRDPARTY_RCSRM__'] = '__THIRDPARTY_RCSRM__'; + $substitutionarray['__THIRDPARTY_TVAINTRA__'] = '__THIRDPARTY_TVAINTRA__'; + /*$substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = '__THIRDPARTY_NOTE_PUBLIC__'; + $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = '__THIRDPARTY_NOTE_PRIVATE__';*/ } if (! empty($conf->adherent->enabled)) { @@ -5960,12 +5976,16 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__MEMBER_CIVILITY__'] = '__MEMBER_CIVILITY__'; $substitutionarray['__MEMBER_FIRSTNAME__'] = '__MEMBER_FIRSTNAME__'; $substitutionarray['__MEMBER_LASTNAME__'] = '__MEMBER_LASTNAME__'; + /*$substitutionarray['__MEMBER_NOTE_PUBLIC__'] = '__MEMBER_NOTE_PUBLIC__'; + $substitutionarray['__MEMBER_NOTE_PRIVATE__'] = '__MEMBER_NOTE_PRIVATE__';*/ } if (! empty($conf->projet->enabled)) { $substitutionarray['__PROJECT_ID__'] = '__PROJECT_ID__'; $substitutionarray['__PROJECT_REF__'] = '__PROJECT_REF__'; $substitutionarray['__PROJECT_NAME__'] = '__PROJECT_NAME__'; + /*$substitutionarray['__PROJECT_NOTE_PUBLIC__'] = '__PROJECT_NOTE_PUBLIC__'; + $substitutionarray['__PROJECT_NOTE_PRIVATE__'] = '__PROJECT_NOTE_PRIVATE__';*/ } if (! empty($conf->contrat->enabled)) { @@ -5998,13 +6018,17 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF__'] = $object->ref; $substitutionarray['__REF_CLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); - $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs): ''); + $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); + $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); + + $substitutionarray['__DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs): ''); + // For backward compatibility $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); - - // TODO Remove this - $msgishtml = 0; + $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); + $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); + $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs): ''); $birthday = dol_print_date($object->birth, 'day'); @@ -6012,22 +6036,22 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, { $substitutionarray['__MEMBER_ID__']=$object->id; if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); - $substitutionarray['__MEMBER_FIRSTNAME__']=$msgishtml?dol_htmlentitiesbr($object->firstname):$object->firstname; - $substitutionarray['__MEMBER_LASTNAME__']=$msgishtml?dol_htmlentitiesbr($object->lastname):$object->lastname; - if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($outputlangs)):$object->getFullName($outputlangs); - $substitutionarray['__MEMBER_COMPANY__']=$msgishtml?dol_htmlentitiesbr($object->societe):$object->societe; - $substitutionarray['__MEMBER_ADDRESS__']=$msgishtml?dol_htmlentitiesbr($object->address):$object->address; - $substitutionarray['__MEMBER_ZIP__']=$msgishtml?dol_htmlentitiesbr($object->zip):$object->zip; - $substitutionarray['__MEMBER_TOWN__']=$msgishtml?dol_htmlentitiesbr($object->town):$object->town; - $substitutionarray['__MEMBER_COUNTRY__']=$msgishtml?dol_htmlentitiesbr($object->country):$object->country; - $substitutionarray['__MEMBER_EMAIL__']=$msgishtml?dol_htmlentitiesbr($object->email):$object->email; - $substitutionarray['__MEMBER_BIRTH__']=$msgishtml?dol_htmlentitiesbr($birthday):$birthday; - $substitutionarray['__MEMBER_PHOTO__']=$msgishtml?dol_htmlentitiesbr($object->photo):$object->photo; - $substitutionarray['__MEMBER_LOGIN__']=$msgishtml?dol_htmlentitiesbr($object->login):$object->login; - $substitutionarray['__MEMBER_PASSWORD__']=$msgishtml?dol_htmlentitiesbr($object->pass):$object->pass; - $substitutionarray['__MEMBER_PHONE__']=$msgishtml?dol_htmlentitiesbr($object->phone):$object->phone; - $substitutionarray['__MEMBER_PHONEPRO__']=$msgishtml?dol_htmlentitiesbr($object->phone_perso):$object->phone_perso; - $substitutionarray['__MEMBER_PHONEMOBILE__']=$msgishtml?dol_htmlentitiesbr($object->phone_mobile):$object->phone_mobile; + $substitutionarray['__MEMBER_FIRSTNAME__']=$object->firstname; + $substitutionarray['__MEMBER_LASTNAME__']=$object->lastname; + if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$object->getFullName($outputlangs); + $substitutionarray['__MEMBER_COMPANY__']=$object->societe; + $substitutionarray['__MEMBER_ADDRESS__']=$object->address; + $substitutionarray['__MEMBER_ZIP__']=$object->zip; + $substitutionarray['__MEMBER_TOWN__']=$object->town; + $substitutionarray['__MEMBER_COUNTRY__']=$object->country; + $substitutionarray['__MEMBER_EMAIL__']=$object->email; + $substitutionarray['__MEMBER_BIRTH__']=$birthday; + $substitutionarray['__MEMBER_PHOTO__']=$object->photo; + $substitutionarray['__MEMBER_LOGIN__']=$object->login; + $substitutionarray['__MEMBER_PASSWORD__']=$object->pass; + $substitutionarray['__MEMBER_PHONE__']=$object->phone; + $substitutionarray['__MEMBER_PHONEPRO__']=$object->phone_perso; + $substitutionarray['__MEMBER_PHONEMOBILE__']=$object->phone_mobile; $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE__'] = dol_print_date($object->first_subscription_date, 'dayrfc'); $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->first_subscription_date_start, 'dayrfc'); $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->first_subscription_date_end, 'dayrfc'); @@ -6041,14 +6065,38 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object)?$object->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object)?$object->name:''); $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object)?$object->name_alias:''); + $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object)?$object->code_client:''); + $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object)?$object->code_fournisseur:''); $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object)?$object->email:''); + $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object)?$object->phone:''); + $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object)?$object->name_fax:''); + $substitutionarray['__THIRDPARTY_ADRESSE__'] = (is_object($object)?$object->address:''); + $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object)?$object->zip:''); + $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object)?$object->town:''); + $substitutionarray['__THIRDPARTY_SIREN__'] = (is_object($object)?$object->idprof1:''); + $substitutionarray['__THIRDPARTY_SIRET__'] = (is_object($object)?$object->idprof2:''); + $substitutionarray['__THIRDPARTY_APE__'] = (is_object($object)?$object->idprof3:''); + $substitutionarray['__THIRDPARTY_RCSRM__'] = (is_object($object)?$object->idprof4:''); + $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object)?$object->tva_intra:''); } elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0) { $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty)?$object->thirdparty->name_alias:''); + $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty)?$object->thirdparty->code_client:''); + $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty)?$object->thirdparty->code_fournisseur:''); $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); + $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty)?$object->phone:''); + $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty)?$object->name_fax:''); + $substitutionarray['__THIRDPARTY_ADRESSE__'] = (is_object($object->thirdparty)?$object->address:''); + $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty)?$object->zip:''); + $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty)?$object->town:''); + $substitutionarray['__THIRDPARTY_SIREN__'] = (is_object($object->thirdparty)?$object->idprof1:''); + $substitutionarray['__THIRDPARTY_SIRET__'] = (is_object($object->thirdparty)?$object->idprof2:''); + $substitutionarray['__THIRDPARTY_APE__'] = (is_object($object->thirdparty)?$object->idprof3:''); + $substitutionarray['__THIRDPARTY_RCSRM__'] = (is_object($object->thirdparty)?$object->idprof4:''); + $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty)?$object->tva_intra:''); } if (is_object($object->project) && $object->project->id > 0) @@ -8074,7 +8122,7 @@ 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:'') + 'class'=>'badge badge-status'.(!empty($mode)?' badge-'.$mode:'').(!empty($type)?' badge-'.$type:'') ); if(empty($html)){ @@ -8135,26 +8183,12 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st global $conf; $return = ''; - $dolGetBadgeParams = array(); - if(!empty($params['badgeParams'])){ + + if (!empty($params['badgeParams'])){ $dolGetBadgeParams = $params['badgeParams']; } - // image's filename are still in French - $statusImg=array( - 'status0' => 'statut0' - ,'status1' => 'statut1' - ,'status2' => 'statut2' - ,'status3' => 'statut3' - ,'status4' => 'statut4' - ,'status5' => 'statut5' - ,'status6' => 'statut6' - ,'status7' => 'statut7' - ,'status8' => 'statut8' - ,'status9' => 'statut9' - ); - // TODO : add a hook if ($displayMode == 0) { @@ -8164,12 +8198,34 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st $return = !empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel); } // use status with images - elseif (empty($conf->global->MAIN_STATUS_USES_CSS)){ + elseif (empty($conf->global->MAIN_STATUS_USES_CSS)) { $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))?'':''); - if(!empty($statusImg[$statusType])){ + // For small screen, we 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; + } + + // 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); diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 7780c7d3b12..a05a62f5957 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2250,13 +2250,16 @@ function colorValidateHex($color, $allow_white = true) /** * Change color to make it less aggressive (ratio is negative) or more aggressive (ratio is positive) * - * @param string $hex Color in hex ('#AA1122' or 'AA1122' or '#a12' or 'a12') - * @param integer $ratio Default=-50. Note: 0=Component color is unchanged, -100=Component color become 88, +100=Component color become 00 or FF + * @param string $hex Color in hex ('#AA1122' or 'AA1122' or '#a12' or 'a12') + * @param integer $ratio Default=-50. Note: 0=Component color is unchanged, -100=Component color become 88, +100=Component color become 00 or FF + * @param integer $brightness Default=0. Adjust brightness. -100=Decrease brightness by 100%, +100=Increase of 100%. * @return string New string of color * @see colorAdjustBrightness() */ -function colorAgressivity($hex, $ratio = -50) +function colorAgressiveness($hex, $ratio = -50, $brightness = 0) { + if (empty($ratio)) $ratio = 0; // To avoid null + // Steps should be between -255 and 255. Negative = darker, positive = lighter $ratio = max(-100, min(100, $ratio)); @@ -2277,12 +2280,21 @@ function colorAgressivity($hex, $ratio = -50) if ($color > 127) $color += ((255 - $color) * ($ratio / 100)); if ($color < 128) $color -= ($color * ($ratio / 100)); } - else // We decrease agressivity + else // We decrease agressiveness { if ($color > 128) $color -= (($color - 128) * (abs($ratio) / 100)); if ($color < 127) $color += ((128 - $color) * (abs($ratio) / 100)); } - $color = max(0, min(255, $color)); // Adjust color + if ($brightness > 0) + { + $color = ($color * (100 + abs($brightness)) / 100); + } + else + { + $color = ($color * (100 - abs($brightness)) / 100); + } + + $color = max(0, min(255, $color)); // Adjust color to stay into valid range $return .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT); // Make two char hex code } @@ -2294,7 +2306,7 @@ function colorAgressivity($hex, $ratio = -50) * @param string $hex Color in hex ('#AA1122' or 'AA1122' or '#a12' or 'a12') * @param integer $steps Step/offset added to each color component. It should be between -255 and 255. Negative = darker, positive = lighter * @return string New color with format '#AA1122' - * @see colorAgressivity() + * @see colorAgressiveness() */ function colorAdjustBrightness($hex, $steps) { diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 739e115efb1..0b06d21c95d 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -136,14 +136,14 @@ function invoice_admin_prepare_head() $head[$h][1] = $langs->trans("Payments"); $head[$h][2] = 'payment'; $h++; - + if($conf->global->INVOICE_USE_SITUATION){ $head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php'; $head[$h][1] = $langs->trans("InvoiceSituation"); $head[$h][2] = 'situation'; $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 diff --git a/htdocs/core/lib/loan.lib.php b/htdocs/core/lib/loan.lib.php index bc7b0034b35..4d47c79e6da 100644 --- a/htdocs/core/lib/loan.lib.php +++ b/htdocs/core/lib/loan.lib.php @@ -40,7 +40,7 @@ function loan_prepare_head($object) $head[$tab][1] = $langs->trans('Card'); $head[$tab][2] = 'card'; $tab++; - + $head[$tab][0] = DOL_URL_ROOT.'/loan/schedule.php?loanid='.$object->id; $head[$tab][1] = $langs->trans('FinancialCommitment'); $head[$tab][2] = 'FinancialCommitment'; diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index 93146738f66..6068246341e 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -127,7 +127,7 @@ function member_type_prepare_head(AdherentType $object) $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; - + // Multilangs if (! empty($conf->global->MAIN_MULTILANGS)) { diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index d353cca0097..22e660b2e22 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -55,7 +55,7 @@ function dol_setcache($memoryid, $data) $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); if (! $result) return -1; } - + $memoryid=session_name().'_'.$memoryid; //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); $dolmemcache->add($memoryid, $data); // This fails if key already exists @@ -79,7 +79,7 @@ function dol_setcache($memoryid, $data) $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); if (! $result) return -1; } - + $memoryid=session_name().'_'.$memoryid; //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); $result=$dolmemcache->add($memoryid, $data); // This fails if key already exists @@ -122,7 +122,7 @@ function dol_getcache($memoryid) $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); if (! $result) return -1; } - + $memoryid=session_name().'_'.$memoryid; //$m->setOption(Memcached::OPT_COMPRESSION, false); //print "Get memoryid=".$memoryid; @@ -149,7 +149,7 @@ function dol_getcache($memoryid) $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); if (! $result) return -1; } - + $memoryid=session_name().'_'.$memoryid; //$m->setOption(Memcached::OPT_COMPRESSION, false); $data=$m->get($memoryid); diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 170421cecfd..544ca40fcf6 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -479,6 +479,22 @@ function show_stats_for_company($product, $socid) return $nblines++; } +/** + * Return translation label of a unit key. + * Function kept for backward compatibility. + * + * @param string $scale Scale of unit: '0', '-3', '6', ... + * @param string $measuring_style Style of unit: weight, volume,... + * @param int $unit ID of unit (rowid in llx_c_units table) + * @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated. + * @return string Unit string + * @see measuringUnitString() formproduct->selectMeasuringUnits() + */ +function measuring_units_string($scale = '', $measuring_style = '', $unit = 0, $use_short_label = 0) +{ + return measuringUnitString($unit, $measuring_style, $scale, $use_short_label); +} + /** * Return translation label of a unit key * @@ -487,9 +503,9 @@ function show_stats_for_company($product, $socid) * @param string $scale Scale of unit: '0', '-3', '6', ... * @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated. * @return string Unit string - * @see formproduct->selectMeasuringUnits + * @see formproduct->selectMeasuringUnits() */ -function measuring_units_string($unit, $measuring_style = '', $scale = '', $use_short_label = 0) +function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_short_label = 0) { global $langs, $db; require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; diff --git a/htdocs/core/menus/standard/auguria_menu.php b/htdocs/core/menus/standard/auguria_menu.php index b3c5814240c..adee27687dd 100644 --- a/htdocs/core/menus/standard/auguria_menu.php +++ b/htdocs/core/menus/standard/auguria_menu.php @@ -113,7 +113,7 @@ class MenuManager $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'auguria', $tabMenu); $this->tabMenu=$tabMenu; //var_dump($tabMenu); - + //if ($forcemainmenu == 'all') { var_dump($this->tabMenu); exit; } } @@ -152,7 +152,7 @@ class MenuManager if ($mode == 'top') print_left_auguria_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0); if ($mode == 'left') print_auguria_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode); } - + if ($mode == 'topnb') { print_auguria_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); @@ -327,7 +327,7 @@ class MenuManager } unset($this->menu); - + //print 'xx'.$mode; return 0; } diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 8389db029be..089194aec2a 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -65,7 +65,7 @@ class MenuManager public function loadMenu($forcemainmenu = '', $forceleftmenu = '') { global $conf, $user, $langs; - + // On sauve en session le menu principal choisi if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 21658ed32d0..9235cddc90f 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -509,12 +509,12 @@ class pdf_espadon extends ModelePdfExpedition $weighttxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { - $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units, "weight"); + $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units); } $voltxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { - $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0, "volume"); + $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0); } diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index b180994b7e5..7757e3c9b56 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -525,12 +525,12 @@ class pdf_rouget extends ModelePdfExpedition $weighttxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { - $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units, "weight"); + $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units); } $voltxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { - $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0, "volume"); + $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0); } if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 623f67ddd72..ac59960cf59 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -25,7 +25,7 @@ /** * \file htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php * \ingroup ficheinter - * \brief Fichier de la classe permettant de generer les fiches d'intervention au modele Soleil + * \brief File of Class to build interventions documents with model Soleil */ require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -142,7 +142,7 @@ class pdf_soleil extends ModelePDFFicheinter $this->option_condreg = 0; // Display payment terms $this->option_codeproduitservice = 0; // Display product-service code $this->option_multilang = 1; // Available in several languages - $this->option_draft_watermark = 1; //Support add of a watermark on drafts + $this->option_draft_watermark = 1; // Support add of a watermark on drafts // Get source company $this->emetteur=$mysoc; @@ -266,7 +266,7 @@ class pdf_soleil extends ModelePDFFicheinter $tab_height = 130; $tab_height_newpage = 150; - // Affiche notes + // Display notes $notetoshow=empty($object->note_public)?'':$object->note_public; if ($notetoshow) { @@ -394,7 +394,7 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -573,7 +573,7 @@ class pdf_soleil extends ModelePDFFicheinter pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FICHINTER_DRAFT_WATERMARK); } - //Prepare la suite + //Prepare next $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index 6ec78b1ac1a..4d8ea35e4d9 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -82,7 +82,7 @@ class mod_arctic extends ModeleNumRefFicheinter $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("InterventionCard"), $langs->transnoentities("InterventionCard")); $tooltip.=$langs->trans("GenericMaskCodes5"); - // Parametrage du prefix + // Setting the prefix $texte.= ''; $texte.= ''; @@ -130,7 +130,7 @@ class mod_arctic extends ModeleNumRefFicheinter require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; - // On défini critere recherche compteur + // We define the search criteria of the counter $mask=$conf->global->FICHINTER_ARTIC_MASK; if (! $mask) diff --git a/htdocs/core/modules/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php index 269fc1d650a..0b2ac1a6136 100644 --- a/htdocs/core/modules/modFicheinter.class.php +++ b/htdocs/core/modules/modFicheinter.class.php @@ -164,7 +164,12 @@ class modFicheinter extends DolibarrModules 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InterId",'f.ref'=>"InterRef",'f.datec'=>"InterDateCreation", - 'f.duree'=>"InterDuration",'f.fk_statut'=>'InterStatus','f.description'=>"InterNote", 'pj.ref'=>'ProjectRef', 'fd.rowid'=>'InterLineId', + 'f.duree'=>"InterDuration",'f.fk_statut'=>'InterStatus','f.description'=>"InterNote"); + $keyforselect='fichinter'; $keyforelement='intervention'; $keyforaliasextra='extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $this->export_fields_array[$r]+=array( + 'pj.ref'=>'ProjectRef','pj.title'=>'ProjectLabel', + 'fd.rowid'=>'InterLineId', 'fd.date'=>"InterLineDate",'fd.duree'=>"InterLineDuration",'fd.description'=>"InterLineDesc" ); //$this->export_TypeFields_array[$r]=array( @@ -175,24 +180,30 @@ class modFicheinter extends DolibarrModules // 'fd.total_ht'=>"Numeric" //); $this->export_TypeFields_array[$r]=array( - 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label','s.phone'=>'Text','s.siren'=>'Text', - 's.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date", - 'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text",'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean", 'pj.ref'=>'Text', - 'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text",'fd.total_ht'=>"Numeric" + 's.rowid'=>"Numeric",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label','s.phone'=>'Text','s.siren'=>'Text', + 's.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text', + 'f.rowid'=>'Numeric','f.ref'=>"Text",'f.datec'=>"Date", + 'f.duree'=>"Duree",'f.fk_statut'=>'Numeric','f.description'=>"Text",'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean", + 'pj.ref'=>'Text','pj.title'=>'Text', + 'fd.rowid'=>"Numeric",'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text",'fd.total_ht'=>"Numeric" ); $this->export_entities_array[$r]=array( 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company', 's.code_compta_fournisseur'=>'company','f.rowid'=>"intervention",'f.ref'=>"intervention",'f.datec'=>"intervention",'f.duree'=>"intervention", - 'f.fk_statut'=>"intervention",'f.description'=>"intervention", 'pj.ref'=>'project', 'fd.rowid'=>"inter_line",'fd.date'=>"inter_line", + 'f.fk_statut'=>"intervention",'f.description'=>"intervention", 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>"inter_line",'fd.date'=>"inter_line", 'fd.duree'=>'inter_line','fd.description'=>'inter_line' ); $this->export_dependencies_array[$r]=array('inter_line'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them + $keyforselect='fichinterdet'; $keyforelement='inter_line'; $keyforaliasextra='extradet'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'fichinter as f'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter_extrafields as extra ON f.rowid = extra.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter,'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet_extrafields as extradet ON fd.rowid = extradet.fk_object,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('intervention').')'; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 1db0db2e6f5..b6a9f968a02 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -85,7 +85,7 @@ class modProduct extends DolibarrModules $this->const[$r][3] = 'Module to control product codes'; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "PRODUCT_PRICE_UNIQ"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "1"; @@ -182,7 +182,8 @@ class modProduct extends DolibarrModules 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', - 'p.weight'=>"Weight",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface",'p.volume'=>"Volume", + 'p.weight'=>"Weight", 'p.weight_units'=>"WeightUnits", 'p.length'=>"Length", 'p.width'=>"Width", 'p.height'=>"Height", 'p.length_units'=>"SizeUnits", + 'p.surface'=>"Surface", 'p.surface_units'=>"SurfaceUnits", 'p.volume'=>"Volume", 'p.volume_units'=>"VolumeUnits", 'p.duration'=>"Duration", 'p.finished' => 'Nature', 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC", diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 0d4f86ca82a..319f563ad28 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -198,7 +198,7 @@ class pdf_cyan extends ModelePDFPropales if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - + // Translations $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 3a8b1a78a3e..a84b86e908b 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -450,12 +450,12 @@ class pdf_squille extends ModelePdfReception $weighttxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) { - $weighttxt=round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units, "weight"); + $weighttxt=round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->product->weight_units); } $voltxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) { - $voltxt=round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units?$object->lines[$i]->product->volume_units:0, "volume"); + $voltxt=round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->product->volume_units?$object->lines[$i]->product->volume_units:0); } $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt, 0, 0, false, true, 'C'); diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 3bb59685449..826ed5fdd45 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -55,22 +55,10 @@ elseif ($modulepart == 'project') } elseif ($modulepart == 'bom') { - $result=restrictedArea($user, 'bom', $id, 'bom_bom'); + $result=restrictedArea($user, $modulepart, $id, 'bom_bom'); if (! $user->rights->bom->read) accessforbidden(); $accessallowed=1; } -elseif ($modulepart == 'expensereport') -{ - $result=restrictedArea($user, 'expensereport', $id, 'expensereport'); - if (! $user->rights->expensereport->lire) accessforbidden(); - $accessallowed=1; -} -elseif ($modulepart == 'holiday') -{ - $result=restrictedArea($user, 'holiday', $id, 'holiday'); - if (! $user->rights->holiday->read) accessforbidden(); - $accessallowed=1; -} elseif ($modulepart == 'member') { $result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid'); @@ -79,26 +67,26 @@ elseif ($modulepart == 'member') } elseif ($modulepart == 'user') { - $result=restrictedArea($user, 'user', $id, 'user'); + $result=restrictedArea($user, $modulepart, $id, $modulepart); if (! $user->rights->user->user->lire) accessforbidden(); $accessallowed=1; } -elseif ($modulepart == 'societe') -{ - $result=restrictedArea($user, 'societe', $id, 'societe'); - if (! $user->rights->societe->lire) accessforbidden(); - $accessallowed=1; -} elseif ($modulepart == 'tax') { - $result=restrictedArea($user, 'tax', $id, 'chargesociales', 'charges'); + $result=restrictedArea($user, $modulepart, $id, 'chargesociales', 'charges'); if (! $user->rights->tax->charges->lire) accessforbidden(); $accessallowed=1; } -elseif ($modulepart == 'ticket') +elseif ($modulepart == 'bank') { - $result=restrictedArea($user, 'ticket', $id, 'ticket'); - if (! $user->rights->ticket->read) accessforbidden(); + $result=restrictedArea($user, 'banque', $id, 'bank_account'); + if (! $user->rights->banque->lire) accessforbidden(); + $accessallowed=1; +} +else // ticket, holiday, expensereport, societe... +{ + $result=restrictedArea($user, $modulepart, $id, $modulepart); + if (empty($user->rights->$modulepart->read) && empty($user->rights->$modulepart->lire)) accessforbidden(); $accessallowed=1; } @@ -142,7 +130,7 @@ elseif ($modulepart == 'holiday') { $result = $object->fetch($id); if ($result <= 0) dol_print_error($db, 'Failed to load object'); - $dir=$conf->holiday->dir_output; // By default + $dir=$conf->$modulepart->dir_output; // By default } } elseif ($modulepart == 'member') @@ -164,7 +152,7 @@ elseif ($modulepart == 'societe') { $result = $object->fetch($id); if ($result <= 0) dol_print_error($db, 'Failed to load object'); - $dir=$conf->societe->dir_output; + $dir=$conf->$modulepart->dir_output; } } elseif ($modulepart == 'user') @@ -175,7 +163,7 @@ elseif ($modulepart == 'user') { $result = $object->fetch($id); if ($result <= 0) dol_print_error($db, 'Failed to load object'); - $dir=$conf->user->dir_output; // By default + $dir=$conf->$modulepart->dir_output; // By default } } elseif ($modulepart == 'expensereport') @@ -197,7 +185,7 @@ elseif ($modulepart == 'tax') { $result = $object->fetch($id); if ($result <= 0) dol_print_error($db, 'Failed to load object'); - $dir=$conf->tax->dir_output; // By default + $dir=$conf->$modulepart->dir_output; // By default } } elseif ($modulepart == 'ticket') @@ -208,7 +196,7 @@ elseif ($modulepart == 'ticket') { $result = $object->fetch($id); if ($result <= 0) dol_print_error($db, 'Failed to load object'); - $dir=$conf->ticket->dir_output; // By default + $dir=$conf->$modulepart->dir_output; // By default } } elseif ($modulepart == 'bom') @@ -219,7 +207,18 @@ elseif ($modulepart == 'bom') { $result = $object->fetch($id); if ($result <= 0) dol_print_error($db, 'Failed to load object'); - $dir=$conf->bom->dir_output; // By default + $dir=$conf->$modulepart->dir_output; // By default + } +} +elseif ($modulepart == 'bank') +{ + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $object = new Account($db); + if ($id > 0) + { + $result = $object->fetch($id); + if ($result <= 0) dol_print_error($db, 'Failed to load object'); + $dir=$conf->banque->dir_output; // By default } } else { @@ -237,6 +236,7 @@ if (empty($backtourl)) elseif (in_array($modulepart, array('tax'))) $backtourl=DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('ticket'))) $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + elseif (in_array($modulepart, array('bank'))) $backtourl=DOL_URL_ROOT."/compta/bank/document.php?id=".$id.'&file='.urldecode($_POST["file"]); else $backtourl=DOL_URL_ROOT."/".$modulepart."/".$modulepart."_document.php?id=".$id.'&file='.urldecode($_POST["file"]); } @@ -422,6 +422,7 @@ print '
'."\n"; print ''."\n"; print ''; +print ''; print '
'; print ''.$langs->trans("Resize").''; @@ -472,7 +473,9 @@ if (! empty($conf->use_javascript_ajax)) print ''; print ''; print '
'; - print ' + print ''; + print ''; + print '
'.$langs->trans("NewSizeAfterCropping").': diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php index 35aefb9f719..ca30eb5ae92 100644 --- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php @@ -50,7 +50,7 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ $value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1); //var_dump($value); } - + print $extrafields->showOutputField($key, $value, '', $extrafieldsobjectkey); print ''; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/core/tpl/extrafields_list_search_title.tpl.php b/htdocs/core/tpl/extrafields_list_search_title.tpl.php index e8b1e396f1a..c6d3776cfe4 100644 --- a/htdocs/core/tpl/extrafields_list_search_title.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_title.tpl.php @@ -23,8 +23,15 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ $align=$extrafields->getAlignFlag($key); $sortonfield = $extrafieldsobjectprefix.$key; if (! empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) $sortonfield=''; - if ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] == 'separate') print '
'; - else print getTitleFieldOfList($extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder)."\n"; + if ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] == 'separate') { + print ''; + } + else + { + $tooltip = empty($extrafields->attributes[$extrafieldsobjectkey]['help'][$key]) ? '' : $extrafields->attributes[$extrafieldsobjectkey]['help'][$key]; + + print getTitleFieldOfList($extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder, '', 0, $tooltip)."\n"; + } } } } diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 6f52cbcab7a..f19cfff136e 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -85,6 +85,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] else { $value = $object->array_options["options_" . $key]; + //var_dump($key.' - '.$value); } if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') { @@ -178,7 +179,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] } else { - //print $key.'-'.$value.'-'.$object->table_element; + //var_dump($key.'-'.$value.'-'.$object->table_element); print $extrafields->showOutputField($key, $value, '', $object->table_element); } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index b0d4596a711..cb8138eedae 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -138,22 +138,20 @@ if ($nolinesbefore) { print ''; } if (! empty($usemargins)) - { - if (!empty($user->rights->margins->creer)) { - ?> - '; + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) echo ''; + if (! empty($conf->global->DISPLAY_MARK_RATES)) echo ''; } - else $colspan++; - - if ($conf->global->MARGIN_TYPE == "1") - echo $langs->trans('BuyingPrice'); - else - echo $langs->trans('CostPrice'); - echo ''; - if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARGIN_RATES)) echo ''; - if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARK_RATES)) echo ''; } ?> @@ -438,20 +436,16 @@ if ($nolinesbefore) { { if (!empty($user->rights->margins->creer)) { $coldisplay++; - ?> - - rights->margins->creer) - { + ?> + + global->DISPLAY_MARGIN_RATES)) { echo ''; diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index f98bea150de..0b275202d92 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -217,10 +217,10 @@ $coldisplay=0; subprice < 0) echo ''; else - echo ''; + echo ''; $coldisplay++; } elseif (! empty($conf->global->DISPLAY_MARK_RATES)) @@ -242,7 +242,7 @@ $coldisplay=0; if ($line->subprice < 0) echo ''; else - echo ''; + echo ''; $coldisplay++; } } diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index f9d33495764..2e14d0c7f47 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -131,7 +131,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $ret = 0; - + // First classify billed the order to allow the proposal classify process if (! empty($conf->commande->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) { @@ -175,7 +175,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } } - + return $ret; } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 70fabfcdc29..fc95009846b 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2019 Thibault FOUCART - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -62,7 +62,15 @@ class Don extends CommonObject */ public $picto = 'generic'; + /** + * @var string Date of the donation + */ public $date; + + /** + * amount of donation + * @var double + */ public $amount; /** @@ -133,7 +141,7 @@ class Don extends CommonObject /** - * Retourne le libelle du statut d'un don (brouillon, validee, abandonnee, payee) + * Returns the donation status label (draft, valid, abandoned, paid) * * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle @@ -145,7 +153,7 @@ class Don extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * * @param int $statut Id statut * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index dc12f5a1d68..607d6555337 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/don/class/dontats.class.php + * \file htdocs/don/class/donstats.class.php * \ingroup donations * \brief File of class to manage donations statistics */ @@ -39,11 +39,22 @@ class DonationStats extends Stats */ public $table_element; - public $socid; + public $socid; public $userid; + /** + * @var string FROM + */ public $from; + + /** + * @var string field + */ public $field; + + /** + * @var string WHERE + */ public $where; diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 5728e6fc2aa..bdc6c45168d 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -211,7 +211,7 @@ if ($resql) if (! empty($conf->projet->enabled)) { $langs->load("projects"); - print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "fk_projet", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "d.fk_projet", "", $param, "", $sortfield, $sortorder); } print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "d.amount", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index d1dbb129a19..a101f3964c0 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -379,7 +379,7 @@ if (empty($reshook)) if (! $error) { - $ret=$object->create($user); // This create shipment (like Odoo picking) and line of shipments. Stock movement will when validating shipment. + $ret=$object->create($user); // This create shipment (like Odoo picking) and lines of shipments. Stock movement will be done when validating shipment. if ($ret <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -994,7 +994,7 @@ if ($action == 'create') print ''; @@ -1005,7 +1005,7 @@ if ($action == 'create') print ' x '; print ' x '; print ' '; - $text=$formproduct->selectMeasuringUnits("size_units", "size"); + $text=$formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); print ''; @@ -1707,7 +1707,6 @@ elseif ($id || $ref) // Print form confirm print $formconfirm; - // Calculate totalWeight and totalVolume for all products // by adding weight and volume of each product line. $tmparray=$object->getTotalWeightVolume(); @@ -1850,16 +1849,14 @@ elseif ($id || $ref) else { print $object->trueWeight; - print ($object->trueWeight && $object->weight_units!='')?' '.measuring_units_string(0, "weight", $object->weight_units):''; + print ($object->trueWeight && $object->weight_units!='')?' '.measuringUnitString(0, "weight", $object->weight_units):''; } // Calculated if ($totalWeight > 0) { if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': '; - //print $totalWeight.' '.measuring_units_string(0, "weight"); print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); - //if (empty($object->trueWeight)) print ' ('.$langs->trans("Calculated").')'; if (!empty($object->trueWeight)) print ')'; } print ''; @@ -1867,7 +1864,7 @@ elseif ($id || $ref) // Width print ''; // Height @@ -1887,7 +1884,7 @@ elseif ($id || $ref) else { print $object->trueHeight; - print ($object->trueHeight && $object->height_units!='')?' '.measuring_units_string(0, "size", $object->height_units):''; + print ($object->trueHeight && $object->height_units!='')?' '.measuringUnitString(0, "size", $object->height_units):''; } print ''; @@ -1895,7 +1892,7 @@ elseif ($id || $ref) // Depth print ''; // Volume @@ -1915,15 +1912,13 @@ elseif ($id || $ref) { if ($volumeUnit < 50) { - //print $calculatedVolume.' '.measuring_units_string($volumeUnit, "volume"); print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); } - else print $calculatedVolume.' '.measuring_units_string($volumeUnit, "volume"); + else print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); } if ($totalVolume > 0) { if ($calculatedVolume) print ' ('.$langs->trans("SumOfProductVolumes").': '; - //print $totalVolume.' '.measuring_units_string(0, "volume"); print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; if ($calculatedVolume) print ')'; @@ -2199,6 +2194,20 @@ elseif ($id || $ref) $product_static->id=$lines[$i]->fk_product; $product_static->ref=$lines[$i]->ref; $product_static->status_batch=$lines[$i]->product_tobatch; + + $product_static->weight=$lines[$i]->weight; + $product_static->weight_units=$lines[$i]->weight_units; + $product_static->length=$lines[$i]->length; + $product_static->length_units=$lines[$i]->length_units; + $product_static->width=$lines[$i]->width; + $product_static->width_units=$lines[$i]->width_units; + $product_static->height=$lines[$i]->height; + $product_static->height_units=$lines[$i]->height_units; + $product_static->surface=$lines[$i]->surface; + $product_static->surface_units=$lines[$i]->surface_units; + $product_static->volume=$lines[$i]->volume; + $product_static->volume_units=$lines[$i]->volume_units; + $text=$product_static->getNomUrl(1); $text.= ' - '.$label; $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->description)); @@ -2252,7 +2261,7 @@ elseif ($id || $ref) if (! empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0) { $warehousestatic->fetch($shipmentline_var['warehouse']); - $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1); + $htmltext .= '
'.$langs->trans("FromLocation").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); } print ' '.$form->textwithpicto('', $htmltext, 1); } @@ -2409,18 +2418,18 @@ elseif ($id || $ref) // Weight print ''; // Volume print ''; // Size - //print ''; + //print ''; if ($action == 'editline' && $lines[$i]->id == $line_id) { @@ -2433,10 +2442,10 @@ elseif ($id || $ref) { // edit-delete buttons print ''; print ''; // Display lines extrafields diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 16b08a8c183..0c340bc8695 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -324,8 +324,8 @@ class Expedition extends CommonObject $sql.= ", ".$this->sizeS; // TODO Should use this->trueDepth $sql.= ", ".$this->sizeW; // TODO Should use this->trueWidth $sql.= ", ".$this->sizeH; // TODO Should use this->trueHeight - $sql.= ", ".($this->weight_units>0?$this->weight_units:'NULL'); - $sql.= ", ".($this->size_units>0?$this->size_units:'NULL'); + $sql.= ", ".($this->weight_units != '' ? (int) $this->weight_units : 'NULL'); + $sql.= ", ".($this->size_units != '' ? (int) $this->size_units : 'NULL'); $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null"); diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 34a89233f1e..293c00a2319 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -42,7 +42,7 @@ if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propa if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; // Load translation files required by the page -$langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm')); +$langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm','other')); $id = GETPOST('id', 'int'); // id of order $ref = GETPOST('ref', 'alpha'); @@ -618,7 +618,9 @@ if ($id > 0 || ! empty($ref)) $sql.= ' cd.date_start,'; $sql.= ' cd.date_end,'; $sql.= ' cd.special_code,'; - $sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc'; + $sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc,'; + $sql.= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,'; + $sql.= ' p.surface, p.surface_units, p.volume, p.volume_units'; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; $sql.= " WHERE cd.fk_commande = ".$object->id; @@ -705,6 +707,20 @@ if ($id > 0 || ! empty($ref)) $product_static->id=$objp->fk_product; $product_static->ref=$objp->ref; $product_static->entity = $objp->entity; + + $product_static->weight=$objp->weight; + $product_static->weight_units=$objp->weight_units; + $product_static->length=$objp->length; + $product_static->length_units=$objp->length_units; + $product_static->width=$objp->width; + $product_static->width_units=$objp->width_units; + $product_static->height=$objp->height; + $product_static->height_units=$objp->height_units; + $product_static->surface=$objp->surface; + $product_static->surface_units=$objp->surface_units; + $product_static->volume=$objp->volume; + $product_static->volume_units=$objp->volume_units; + $text=$product_static->getNomUrl(1); $text.= ' - '.$label; $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'
'; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 95b9e0cd1f5..7a62903dfe6 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -57,7 +57,7 @@ $confirm = GETPOST('confirm', 'alpha'); $date_start = dol_mktime(0, 0, 0, GETPOST('date_debutmonth', 'int'), GETPOST('date_debutday', 'int'), GETPOST('date_debutyear', 'int')); $date_end = dol_mktime(0, 0, 0, GETPOST('date_finmonth', 'int'), GETPOST('date_finday', 'int'), GETPOST('date_finyear', 'int')); $date = dol_mktime(0, 0, 0, GETPOST('datemonth', 'int'), GETPOST('dateday', 'int'), GETPOST('dateyear', 'int')); -$fk_projet=GETPOST('fk_projet', 'int'); +$fk_project=GETPOST('fk_project', 'int'); $vatrate=GETPOST('vatrate', 'alpha'); $ref=GETPOST("ref", 'alpha'); $comments=GETPOST('comments', 'none'); @@ -145,7 +145,7 @@ if (empty($reshook)) } $action=''; - $fk_projet=''; + $fk_project=''; $date_start=''; $date_end=''; $date=''; @@ -1232,7 +1232,7 @@ if (empty($reshook)) $type = 0; // TODO What if service ? We should take the type product/service from the type of expense report llx_c_type_fees // Insert line - $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_projet, $fk_c_exp_tax_cat, $type, $fk_ecm_files); + $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_project, $fk_c_exp_tax_cat, $type, $fk_ecm_files); if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records @@ -1257,7 +1257,7 @@ if (empty($reshook)) unset($vatrate); unset($comments); unset($fk_c_type_fees); - unset($fk_projet); + unset($fk_project); unset($date); } else { @@ -1334,7 +1334,7 @@ if (empty($reshook)) $rowid = $_POST['rowid']; $type_fees_id = GETPOST('fk_c_type_fees', 'int'); $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat', 'int'); - $projet_id = $fk_projet; + $projet_id = $fk_project; $comments = GETPOST('comments', 'none'); $qty = GETPOST('qty', 'int'); $vatrate = GETPOST('vatrate', 'alpha'); @@ -2372,7 +2372,7 @@ else if (! empty($conf->projet->enabled)) { print ''; } @@ -2527,7 +2527,7 @@ else if (! empty($conf->projet->enabled)) { print ''; } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index f6f8f2246b9..e635fd1e1fb 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -136,6 +136,51 @@ class ExpenseReport extends CommonObject const STATUS_CLOSED = 6; + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'ref' =>array('type'=>'varchar(50)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>15), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20), + 'ref_number_int' =>array('type'=>'integer', 'label'=>'Ref number int', 'enabled'=>1, 'visible'=>-1, 'position'=>25), + 'ref_ext' =>array('type'=>'integer', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>-1, 'position'=>30), + 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'Total ht', 'enabled'=>1, 'visible'=>-1, 'position'=>35), + 'total_tva' =>array('type'=>'double(24,8)', 'label'=>'Total tva', 'enabled'=>1, 'visible'=>-1, 'position'=>40), + 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>45), + 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>50), + 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Total ttc', 'enabled'=>1, 'visible'=>-1, 'position'=>55), + 'date_debut' =>array('type'=>'date', 'label'=>'Date debut', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>60), + 'date_fin' =>array('type'=>'date', 'label'=>'Date fin', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>65), + 'date_valid' =>array('type'=>'datetime', 'label'=>'Date valid', 'enabled'=>1, 'visible'=>-1, 'position'=>75), + 'date_approve' =>array('type'=>'datetime', 'label'=>'Date approve', 'enabled'=>1, 'visible'=>-1, 'position'=>80), + 'date_refuse' =>array('type'=>'datetime', 'label'=>'Date refuse', 'enabled'=>1, 'visible'=>-1, 'position'=>85), + 'date_cancel' =>array('type'=>'datetime', 'label'=>'Date cancel', 'enabled'=>1, 'visible'=>-1, 'position'=>90), + 'fk_user_author' =>array('type'=>'integer', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>100), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'Fk user modif', 'enabled'=>1, 'visible'=>-1, 'position'=>105), + 'fk_user_valid' =>array('type'=>'integer', 'label'=>'Fk user valid', 'enabled'=>1, 'visible'=>-1, 'position'=>110), + 'fk_user_validator' =>array('type'=>'integer', 'label'=>'Fk user validator', 'enabled'=>1, 'visible'=>-1, 'position'=>115), + 'fk_user_approve' =>array('type'=>'integer', 'label'=>'Fk user approve', 'enabled'=>1, 'visible'=>-1, 'position'=>120), + 'fk_user_refuse' =>array('type'=>'integer', 'label'=>'Fk user refuse', 'enabled'=>1, 'visible'=>-1, 'position'=>125), + 'fk_user_cancel' =>array('type'=>'integer', 'label'=>'Fk user cancel', 'enabled'=>1, 'visible'=>-1, 'position'=>130), + 'fk_c_paiement' =>array('type'=>'integer', 'label'=>'Fk c paiement', 'enabled'=>1, 'visible'=>-1, 'position'=>140), + 'paid' =>array('type'=>'integer', 'label'=>'Paid', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>145), + 'note_public' =>array('type'=>'text', 'label'=>'Note public', 'enabled'=>1, 'visible'=>0, 'position'=>150), + 'note_private' =>array('type'=>'text', 'label'=>'Note private', 'enabled'=>1, 'visible'=>0, 'position'=>155), + 'detail_refuse' =>array('type'=>'varchar(255)', 'label'=>'Detail refuse', 'enabled'=>1, 'visible'=>-1, 'position'=>160), + 'detail_cancel' =>array('type'=>'varchar(255)', 'label'=>'Detail cancel', 'enabled'=>1, 'visible'=>-1, 'position'=>165), + 'integration_compta' =>array('type'=>'integer', 'label'=>'Integration compta', 'enabled'=>1, 'visible'=>-1, 'position'=>170), + 'fk_bank_account' =>array('type'=>'integer', 'label'=>'Fk bank account', 'enabled'=>1, 'visible'=>-1, 'position'=>175), + 'model_pdf' =>array('type'=>'varchar(50)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>180), + 'fk_multicurrency' =>array('type'=>'integer', 'label'=>'Fk multicurrency', 'enabled'=>1, 'visible'=>-1, 'position'=>185), + 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'Multicurrency code', 'enabled'=>1, 'visible'=>-1, 'position'=>190), + 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency tx', 'enabled'=>1, 'visible'=>-1, 'position'=>195), + 'multicurrency_total_ht' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ht', 'enabled'=>1, 'visible'=>-1, 'position'=>200), + 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total tva', 'enabled'=>1, 'visible'=>-1, 'position'=>205), + 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ttc', 'enabled'=>1, 'visible'=>-1, 'position'=>210), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportKey', 'enabled'=>1, 'visible'=>-1, 'position'=>215), + 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>220), + 'date_create' =>array('type'=>'datetime', 'label'=>'Date create', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>300), + 'tms' =>array('type'=>'timestamp', 'label'=>'Tms', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>305), + 'fk_statut' =>array('type'=>'integer', 'label'=>'Fk statut', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), + ); /** * Constructor diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 5b8e7e60a3b..6190de933d7 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -1198,7 +1198,7 @@ if ($step == 5 && $datatoexport) } } } - print ''; + print ''; print ''; } diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index fcdf155955d..caead930491 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -158,12 +158,10 @@ if ($action == 'add') { // on récupère les enregistrements $object->fetch($id); - // on transfert les données de l'un vers l'autre if ($object->socid > 0) { $newinter->socid=$object->socid; - $newinter->fk_projet=$object->fk_projet; - $newinter->fk_project=$object->fk_projet; + $newinter->fk_project=$object->fk_project; $newinter->fk_contrat=$object->fk_contrat; } else { $newinter->socid=GETPOST("socid"); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index f260ec07491..1941c321458 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1271,12 +1271,12 @@ elseif ($id > 0 || ! empty($ref)) print ''; print ''; @@ -845,7 +844,7 @@ if ($action == 'create') print ' x '; print ' x '; print ' '; - $text=$formproduct->selectMeasuringUnits("size_units", "size"); + $text=$formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); print ''; @@ -869,17 +868,16 @@ if ($action == 'create') $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) { + // Here $object can be of an object Order + $extrafields->fetch_name_optionals_label($object->table_element); + if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element]['label'])) { // copy from order - $orderExtrafields = new Extrafields($db); - $orderExtrafieldLabels = $orderExtrafields->fetch_name_optionals_label($object->table_element); - if ($object->fetch_optionals($object->id, $orderExtrafieldLabels) > 0) { + if ($object->fetch_optionals() > 0) { $recept->array_options = array_merge($recept->array_options, $object->array_options); } print $object->showOptionals($extrafields, 'edit'); } - // Incoterms if (!empty($conf->incoterm->enabled)) { @@ -1446,7 +1444,7 @@ elseif ($id || $ref) print ''; print ''; print ''; - print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units); + print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); print ' '; print ' '; print ''; @@ -1454,16 +1452,14 @@ elseif ($id || $ref) else { print $object->trueWeight; - print ($object->trueWeight && $object->weight_units!='')?' '.measuring_units_string($object->weight_units, "weight"):''; + print ($object->trueWeight && $object->weight_units!='')?' '.measuringUnitString(0, "weight", $object->weight_units):''; } // Calculated if ($totalWeight > 0) { if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': '; - //print $totalWeight.' '.measuring_units_string(0,"weight"); print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); - //if (empty($object->trueWeight)) print ' ('.$langs->trans("Calculated").')'; if (!empty($object->trueWeight)) print ')'; } print ''; @@ -1471,19 +1467,19 @@ elseif ($id || $ref) // Width print ''; // Height print ''; @@ -1499,7 +1495,7 @@ elseif ($id || $ref) // Depth print ''; // Volume @@ -1519,15 +1515,13 @@ elseif ($id || $ref) { if ($volumeUnit < 50) { - //print $calculatedVolume.' '.measuring_units_string($volumeUnit,"volume"); print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); } - else print $calculatedVolume.' '.measuring_units_string($volumeUnit, "volume"); + else print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); } if ($totalVolume > 0) { if ($calculatedVolume) print ' ('.$langs->trans("SumOfProductVolumes").': '; - //print $totalVolume.' '.measuring_units_string(0,"volume"); print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; if ($calculatedVolume) print ')'; @@ -1792,8 +1786,6 @@ elseif ($id || $ref) print ''; // Volume print ''; diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index f90f1f73df1..f5f605532b8 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -34,10 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -$langs->load("receptions"); -$langs->load("deliveries"); -$langs->load('companies'); -$langs->load('bills'); +$langs->loadLangs(array("sendings", "receptions", "deliveries", 'companies', 'bills')); $socid=GETPOST('socid', 'int'); $massaction=GETPOST('massaction', 'alpha'); @@ -79,12 +76,14 @@ $contextpage='receptionlist'; $viewstatut=GETPOST('viewstatut'); +$object = new Reception($db); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('receptionlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label('reception'); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost(null, '', 'search_'); // List of fields to search into when doing a "search in all" @@ -111,15 +110,17 @@ $arrayfields=array( 'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), 'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_RECEPTION))) ); - // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* @@ -145,7 +146,6 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_town=''; $search_zip=""; $search_state=""; - $search_type=''; $search_country=''; $search_type_thirdparty=''; $search_billed=''; @@ -628,8 +628,9 @@ if ($resql) print '
'; print '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' - rights->margins->creer)) { + $colspan++; + } + else { + print ''; + if ($conf->global->MARGIN_TYPE == "1") + echo $langs->trans('BuyingPrice'); + else + echo $langs->trans('CostPrice'); + echo ''.$langs->trans('MarginRate').''.$langs->trans('MarkRate').''.$langs->trans('MarginRate').''.$langs->trans('MarkRate').'  - - product->enabled) || ! empty($conf->service->enabled)) { ?> - - - - "> - + + product->enabled) || ! empty($conf->service->enabled)) { ?> + + + + "> + % product->enabled) || ! empty($conf->service->enabled)) { ?> - + - + '.$margin_rate.'%%%'.$mark_rate.'%%%
'; print $langs->trans("Weight"); print ' '; - $text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int')); + $text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'), 0, 2); $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); print '
'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).''; print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer); - print ($object->trueWidth && $object->width_units!='')?' '.measuring_units_string(0, "size", $object->width_units):''; + print ($object->trueWidth && $object->width_units!='')?' '.measuringUnitString(0, "size", $object->width_units):''; print '
'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).''; print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer); - print ($object->trueDepth && $object->depth_units!='')?' '.measuring_units_string(0, "size", $object->depth_units):''; + print ($object->trueDepth && $object->depth_units!='')?' '.measuringUnitString(0, "size", $object->depth_units):''; print '
'; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string(0, "weight", $lines[$i]->weight_units); + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "weight", $lines[$i]->weight_units); else print ' '; print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string(0, "volume", $lines[$i]->volume_units); + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units); else print ' '; print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units, "volume").''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units).''; - print 'id . '">' . img_edit() . ''; + print 'id . '">' . img_edit() . ''; print ''; - print 'id . '">' . img_delete() . ''; + print 'id . '">' . img_delete() . ''; print ''; - $formproject->select_projects(-1, $line->fk_project, 'fk_projet', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); + $formproject->select_projects(-1, $line->fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); print ''; - $formproject->select_projects(-1, $fk_projet, 'fk_projet', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); + $formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); print ''.(! empty($list)?$list:$langs->trans("None")).''.(! empty($list)?$list:''.$langs->trans("None").'').'
'; - print ''; - // Net Measure - print ''; - // Brut Weight print ''; } + + if (! empty($conf->global->PRODUCT_ADD_NET_MEASURE)) + { + // Net Measure + print ''; + } } // Units @@ -1450,18 +1465,12 @@ else print $form->selectarray('finished', $statutarray, $object->finished); print ''; - // Net Measure - print ''; - // Brut Weight print ''; + if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { // Brut Length @@ -1488,6 +1497,15 @@ else print $formproduct->selectMeasuringUnits("volume_units", "volume", $object->volume_units, 0, 2); print ''; } + + if (! empty($conf->global->PRODUCT_ADD_NET_MEASURE)) + { + // Net Measure + print ''; + } } // Units if($conf->global->PRODUCT_USE_UNITS) @@ -1818,7 +1836,7 @@ else print ''; } - //Parent product. + // Parent product. if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { $combination = new ProductCombination($db); @@ -1863,28 +1881,18 @@ else print $object->getLibFinished(); print ''; - // Net Measure - print '\n"; + if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { // Brut Length @@ -1894,7 +1902,7 @@ else print $object->length; if ($object->width) print " x ".$object->width; if ($object->height) print " x ".$object->height; - print ' '.measuring_units_string(0, "size", $object->length_units); + print ' '.measuringUnitString(0, "size", $object->length_units); } else { @@ -1908,7 +1916,7 @@ else print '\n"; } + + if (! empty($conf->global->PRODUCT_ADD_NET_MEASURE)) + { + // Net Measure + print ''; @@ -1115,9 +1115,9 @@ if ($resql) } if (! empty($arrayfields['m.fk_projet']['checked'])) { - // fk_projet + // fk_project print ''; } // Action column diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 9596c87c9d3..fbbec95f2df 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -105,13 +105,16 @@ $arrayfields=array( //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); // Load object if id or ref is provided as parameter if (($id > 0 || ! empty($ref)) && $action != 'add') diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index b992be282d4..3536088cab5 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -140,7 +140,6 @@ if ($action == 'order' && isset($_POST['valid'])) if ($qty) { //might need some value checks - $obj = $db->fetch_object($resql); $line = new CommandeFournisseurLigne($db); $line->qty = $qty; $line->fk_product = $idprod; @@ -179,7 +178,7 @@ if ($action == 'order' && isset($_POST['valid'])) $error=$db->lasterror(); dol_print_error($db); } - $db->free($resql); + unset($_POST['fourn' . $i]); } unset($_POST[$i]); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 73d41e72196..f15499d4682 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -205,9 +205,11 @@ if (empty($reshook)) { $db->commit(); - if ($backtopage) + if (! empty($backtopage)) { - header("Location: ".$backtopage.'&projectid='.$object->id); + $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation + $backtopage = $backtopage.'&projectid='.$object->id; // Old method + header("Location: ".$backtopage); exit; } else @@ -595,7 +597,7 @@ if ($action == 'create' && $user->rights->projet->creer) print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1); } else print $text; - print ' '.$langs->trans("AddThirdParty").''; + if (! GETPOSTISSET('backtopage')) print ' '.$langs->trans("AddThirdParty").''; print ''; } diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 8b718f1d898..57be29b1bb2 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -377,6 +377,8 @@ if (count($tasksarray)>0) //var_dump($dateformatinput); //var_dump($dateformatinput2); + print '
'; + print '
'; print '
'."\n"; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 8524e940f36..2c311de7792 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -76,7 +76,6 @@ $search_categ=GETPOST("search_categ", 'alpha'); $search_ref=GETPOST("search_ref", 'alpha'); $search_label=GETPOST("search_label", 'alpha'); $search_societe=GETPOST("search_societe", 'alpha'); -$search_year=GETPOST("search_year", 'int'); $search_status=GETPOST("search_status", 'int'); $search_opp_status=GETPOST("search_opp_status", 'alpha'); $search_opp_percent=GETPOST("search_opp_percent", 'alpha'); @@ -141,13 +140,16 @@ $arrayfields=array( 'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); @@ -175,7 +177,6 @@ if (empty($reshook)) $search_ref=""; $search_label=""; $search_societe=""; - $search_year=""; $search_status=-1; $search_opp_status=-1; $search_opp_amount=''; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 2abfea6e64e..2395f5f0bd1 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -66,8 +66,7 @@ $search_progressdeclare=GETPOST('search_progressdeclare'); $object = new Project($db); $taskstatic = new Task($db); -$extrafields_project = new ExtraFields($db); -$extrafields_task = new ExtraFields($db); +$extrafields = new ExtraFields($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); @@ -75,9 +74,9 @@ if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($ob if ($id > 0 || ! empty($ref)) { // fetch optionals attributes and labels - $extrafields_project->fetch_name_optionals_label($object->table_element); + $extrafields->fetch_name_optionals_label($object->table_element); } -$extrafields_task->fetch_name_optionals_label($taskstatic->table_element); +$extrafields->fetch_name_optionals_label($taskstatic->table_element); // Security check $socid=0; @@ -115,14 +114,17 @@ $arrayfields=array( 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), //'t.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); -// Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +// Extra fields project +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* @@ -260,8 +262,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) $task->progress = $progress; // Fill array 'array_options' with data from add form - $extrafields->fetch_name_optionals_label($task->table_element); - $ret = $extrafields_task->setOptionalsFromPost(null, $task); + $ret = $extrafields->setOptionalsFromPost(null, $task); $taskid = $task->create($user); @@ -604,9 +605,9 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields_task->attribute_label)) + if (empty($reshook) && ! empty($extrafields[$taskstatic->table_element]['label'])) { - print $taskstatic->showOptionals($extrafields_task, 'edit'); // Do not use $object here that is object of project + print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic } print '
'; + print ''; if ($action != 'contrat') { - print ''; } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 24a42a034a9..429341cb490 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -701,51 +701,36 @@ class Fichinter extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Returns the label of a statut + * Returns the label of a status * - * @param int $statut id statut + * @param int $status Id status * @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 */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable // Init/load array of translation of status - if (empty($this->statuts) || empty($this->statuts_short)) + if (empty($this->statuts) || empty($this->statuts_short) || empty($this->statuts_logo)) { global $langs; $langs->load("fichinter"); - $this->statuts[0]=$langs->trans('Draft'); - $this->statuts[1]=$langs->trans('Validated'); - $this->statuts[2]=$langs->trans('StatusInterInvoiced'); - $this->statuts[3]=$langs->trans('Done'); - $this->statuts_short[0]=$langs->trans('Draft'); - $this->statuts_short[1]=$langs->trans('Validated'); - $this->statuts_short[2]=$langs->trans('StatusInterInvoiced'); - $this->statuts_short[3]=$langs->trans('Done'); - $this->statuts_logo[0]='statut0'; - $this->statuts_logo[1]='statut1'; - $this->statuts_logo[2]='statut6'; - $this->statuts_logo[3]='statut6'; + $this->statuts[self::STATUS_DRAFT]=$langs->trans('Draft'); + $this->statuts[self::STATUS_VALIDATED]=$langs->trans('Validated'); + $this->statuts[self::STATUS_BILLED]=$langs->trans('StatusInterInvoiced'); + $this->statuts[self::STATUS_CLOSED]=$langs->trans('Done'); + $this->statuts_short[self::STATUS_DRAFT]=$langs->trans('Draft'); + $this->statuts_short[self::STATUS_VALIDATED]=$langs->trans('Validated'); + $this->statuts_short[self::STATUS_BILLED]=$langs->trans('StatusInterInvoiced'); + $this->statuts_short[self::STATUS_CLOSED]=$langs->trans('Done'); + $this->statuts_logo[self::STATUS_DRAFT]='status0'; + $this->statuts_logo[self::STATUS_VALIDATED]='status1'; + $this->statuts_logo[self::STATUS_BILLED]='status6'; + $this->statuts_logo[self::STATUS_CLOSED]='status6'; } - if ($mode == 0) - return $this->statuts[$statut]; - elseif ($mode == 1) - return $this->statuts_short[$statut]; - elseif ($mode == 2) - return img_picto($this->statuts_short[$statut], $this->statuts_logo[$statut]).' '.$this->statuts_short[$statut]; - elseif ($mode == 3) - return img_picto($this->statuts_short[$statut], $this->statuts_logo[$statut]); - elseif ($mode == 4) - return img_picto($this->statuts_short[$statut], $this->statuts_logo[$statut]).' '.$this->statuts[$statut]; - elseif ($mode == 5) - return ''.$this->statuts_short[$statut].' '.img_picto($this->statuts[$statut], $this->statuts_logo[$statut]); - elseif ($mode == 6) - return ''.$this->statuts[$statut].' '.img_picto($this->statuts[$statut], $this->statuts_logo[$statut]); - - return ''; + return dolGetStatus($this->statuts[$status], $this->statuts_short[$status], '', $this->statuts_logo[$status], $mode); } /** diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 7df7eac69b0..d45dadf2589 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -116,13 +116,16 @@ $arrayfields=array( 'fd.duree'=>array('label'=>'DurationOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 77d8d1c119a..1d8f385fd05 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1106,12 +1106,19 @@ if (empty($reshook)) // If creation from another object of another module (Example: origin=propal, originid=1) if (! empty($origin) && ! empty($originid)) { - if ($origin == 'order' || $origin == 'commande') + if ($origin == 'propal' || $origin == 'proposal') { + $classname = 'Propal'; + $element = 'comm/propal'; $subelement = 'propal'; + } + elseif ($origin == 'order' || $origin == 'commande') + { + $classname = 'Commande'; $element = $subelement = 'commande'; } else { + $classname = 'SupplierProposal'; $element = 'supplier_proposal'; $subelement = 'supplier_proposal'; } @@ -1131,7 +1138,6 @@ if (empty($reshook)) { dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - $classname = 'SupplierProposal'; $srcobject = new $classname($db); dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); @@ -1167,7 +1173,6 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if - // trigger used { $lines[$i]->fetch_optionals($lines[$i]->rowid); $array_option = $lines[$i]->array_options; @@ -1442,7 +1447,7 @@ llxHeader('', $langs->trans("Order"), $help_url); $now=dol_now(); if ($action=='create') { - print load_fiche_titre($langs->trans('NewOrder')); + print load_fiche_titre($langs->trans('NewOrderSupplier')); dol_htmloutput_events(); @@ -1459,17 +1464,31 @@ if ($action=='create') { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; + $regs=array(); if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { - $element = $regs [1]; - $subelement = $regs [2]; + $element = $regs[1]; + $subelement = $regs[2]; } - $element = 'supplier_proposal'; - $subelement = 'supplier_proposal'; + if ($origin == 'propal' || $origin == 'proposal') + { + $classname = 'Propal'; + $element = 'comm/propal'; $subelement = 'propal'; + } + elseif ($origin == 'order' || $origin == 'commande') + { + $classname = 'Commande'; + $element = $subelement = 'commande'; + } + else + { + $classname = 'SupplierProposal'; + $element = 'supplier_proposal'; + $subelement = 'supplier_proposal'; + } dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - $classname = 'SupplierProposal'; $objectsrc = new $classname($db); $objectsrc->fetch($originid); if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 367f360da37..c08178bc932 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -376,9 +376,9 @@ if (! $search_all) $sql.= ' country.code,'; $sql.= " p.rowid, p.ref, p.title"; - foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) //prevent error with sql_mode=only_full_group_by { - $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); + $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key : ''); } } else diff --git a/htdocs/hrm/admin/admin_hrm.php b/htdocs/hrm/admin/admin_hrm.php index 243a1ce3222..343e6fa54e9 100644 --- a/htdocs/hrm/admin/admin_hrm.php +++ b/htdocs/hrm/admin/admin_hrm.php @@ -42,15 +42,15 @@ $list = array ( */ if ($action == 'update') { $error = 0; - + 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("SetupSaved"), null, 'mesgs'); } else { @@ -87,13 +87,13 @@ print "\n"; foreach ($list as $key) { $var = ! $var; - + print ''; - + // Param $label = $langs->trans($key); print ''; - + // Value print '\n"; if (count($menus)) @@ -2483,7 +2747,7 @@ elseif (! empty($module)) print $menu['target']; print ''; - print ''; @@ -2747,6 +3011,110 @@ elseif (! empty($module)) } } + if ($tab == 'css') + { + if ($action != 'editfile' || empty($file)) + { + print ''.$langs->trans("CSSDesc").'
'; + print '
'; + + print '
'; print $langs->trans('Contract'); print 'id.'">'; + print 'id.'">'; print img_edit($langs->trans('SetContract'), 1); print '
'; print ''; diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index a3a7369c015..31ed3c7e693 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -49,6 +49,8 @@ UPDATE llx_c_units SET label = 'SurfaceUnitm2' WHERE code IN ('M2'); -- For v11 +ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_origin_line (fk_origin_line); + ALTER TABLE llx_rights_def ADD COLUMN module_position INTEGER NOT NULL DEFAULT 0; ALTER TABLE llx_rights_def ADD COLUMN family_position INTEGER NOT NULL DEFAULT 0; @@ -378,3 +380,33 @@ create table llx_fichinterdet_rec ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_start datetime DEFAULT NULL AFTER product_type; ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_end datetime DEFAULT NULL AFTER date_start; + +--List of parcels details related to an expedition +create table llx_expedition_package +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_expedition integer NOT NULL, + description varchar(255), --Description of goods in the package (required by the custom) + value double(24,8) DEFAULT 0,--Value (Price of the content, for insurance & custom) + fk_parcel_type integer, -- Type or package, linked to llx_c_shipment_parcel_type (eg: 1=enveloppe, 2=package, 3=palette, 4=other) + height float, -- height + width float, -- width + size float, -- depth + size_units integer, -- unit of all sizes (height, width, depth) + weight float, -- weight + weight_units integer, -- unit of weight + dangerous_goods smallint DEFAULT 0, -- 0 = no dangerous goods or 1 = Explosives, 2 = Flammable Gases, 3 = Flammable Liquids, 4 = Flammable solids, 5 = Oxidizing, 6 = Toxic & Infectious, 7 = Radioactive, 8 = Corrosives, 9 = Miscellaneous (see https://en.wikipedia.org/wiki/Dangerous_goods). I'm not sure if just register 0 (no) or 1 (yes) is enough. + tail_lift smallint DEFAULT 0, -- 0 = no tail lift required to load/unload package(s), 1 = a tail lift is required to load/unload package(s). Sometime tail lift load can be different than tail lift delivery so maybe adding a new table line. + rang integer DEFAULT 0 +)ENGINE=innodb; + +--Dictionary of package type +create table llx_c_shipment_package_type +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + label varchar(50) NOT NULL, -- Short name + description varchar(255), -- Description + active integer DEFAULT 1 NOT NULL, -- Active or not + entity integer DEFAULT 1 NOT NULL -- Multi company id +)ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_c_shipment_package_type b/htdocs/install/mysql/tables/llx_c_shipment_package_type new file mode 100644 index 00000000000..e510352eba2 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_shipment_package_type @@ -0,0 +1,9 @@ +--Dictionary of package type +create table llx_c_shipment_package_type +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + label varchar(50) NOT NULL, -- Short name + description varchar(255), -- Description + active integer DEFAULT 1 NOT NULL, -- Active or not + entity integer DEFAULT 1 NOT NULL -- Multi company id +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_expedition_package.sql b/htdocs/install/mysql/tables/llx_expedition_package.sql new file mode 100644 index 00000000000..2f8d97a26a9 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_expedition_package.sql @@ -0,0 +1,18 @@ +--List of parcels details related to an expedition +create table llx_expedition_package +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_expedition integer NOT NULL, + description varchar(255), --Description of goods in the package (required by the custom) + value double(24,8) DEFAULT 0,--Value (Price of the content, for insurance & custom) + fk_package_type integer, -- Type or package, linked to llx_c_shipment_parcel_type (eg: 1=enveloppe, 2=package, 3=palette, 4=other) + height float, -- height + width float, -- width + size float, -- depth + size_units integer, -- unit of all sizes (height, width, depth) + weight float, -- weight + weight_units integer, -- unit of weight + dangerous_goods smallint DEFAULT 0, -- 0 = no dangerous goods or 1 = Explosives, 2 = Flammable Gases, 3 = Flammable Liquids, 4 = Flammable solids, 5 = Oxidizing, 6 = Toxic & Infectious, 7 = Radioactive, 8 = Corrosives, 9 = Miscellaneous (see https://en.wikipedia.org/wiki/Dangerous_goods). I'm not sure if just register 0 (no) or 1 (yes) is enough. + tail_lift smallint DEFAULT 0, -- 0 = no tail lift required to load/unload package(s), 1 = a tail lift is required to load/unload package(s). Sometime tail lift load can be different than tail lift delivery so maybe adding a new table line. + rang integer DEFAULT 0 +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_expeditiondet.key.sql b/htdocs/install/mysql/tables/llx_expeditiondet.key.sql index 915602f51ae..b37ae457fe3 100644 --- a/htdocs/install/mysql/tables/llx_expeditiondet.key.sql +++ b/htdocs/install/mysql/tables/llx_expeditiondet.key.sql @@ -19,4 +19,5 @@ ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_expedition (fk_expedition); +ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_origin_line (fk_origin_line); ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_expedition FOREIGN KEY (fk_expedition) REFERENCES llx_expedition (rowid); diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index b7f7037c94d..eee7d7dcfac 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -66,6 +66,7 @@ NoContractedProducts=No products/services contracted NoRecordedContracts=No recorded contracts NoRecordedInterventions=No recorded interventions BoxLatestSupplierOrders=Latest purchase orders +BoxLatestSupplierOrdersAwaitingReception=Latest Purchase Orders (with a pending reception) NoSupplierOrder=No recorded purchase order BoxCustomersInvoicesPerMonth=Customer Invoices per month BoxSuppliersInvoicesPerMonth=Vendor Invoices per month diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index e7667ef6946..e65b966ea09 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -60,6 +60,7 @@ InterDateCreation=Date creation intervention InterDuration=Duration intervention InterStatus=Status intervention InterNote=Note intervention +InterLine=Line of intervention InterLineId=Line id intervention InterLineDate=Line date intervention InterLineDuration=Line duration intervention diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 04f45f8de4b..0b47f9b5e54 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -169,6 +169,7 @@ ToValidate=To validate NotValidated=Not validated Save=Save SaveAs=Save As +SaveAndStay=Save and stay TestConnection=Test connection ToClone=Clone ConfirmClone=Choose data you want to clone: @@ -475,7 +476,9 @@ Categories=Tags/categories Category=Tag/category By=By From=From +FromLocation=From to=to +To=to and=and or=or Other=Other diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index a1c35515f9d..1f8399d939a 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -60,6 +60,8 @@ HooksFile=File for hooks code ArrayOfKeyValues=Array of key-val ArrayOfKeyValuesDesc=Array of keys and values if field is a combo list with fixed values WidgetFile=Widget file +CSSFile=CSS file +JSFile=Javascript file ReadmeFile=Readme file ChangeLog=ChangeLog file TestClassFile=File for PHP Unit Test class @@ -77,6 +79,7 @@ NoTrigger=No trigger NoWidget=No widget GoToApiExplorer=Go to API explorer ListOfMenusEntries=List of menu entries +ListOfDictionariesEntries=List of dictionaries entries ListOfPermissionsDefined=List of defined permissions SeeExamples=See examples here EnabledDesc=Condition to have this field active (Examples: 1 or $conf->global->MYMODULE_MYOPTION) @@ -86,8 +89,10 @@ SearchAllDesc=Is the field used to make a search from the quick search tool? (Ex SpecDefDesc=Enter here all documentation you want to provide with your module that is not already defined by other tabs. You can use .md or better, the rich .asciidoc syntax. LanguageDefDesc=Enter in this files, all the key and the translation for each language file. MenusDefDesc=Define here the menus provided by your module +DictionariesDefDesc=Define here the dictionaries provided by your module PermissionsDefDesc=Define here the new permissions provided by your module MenusDefDescTooltip=The menus provided by your module/application are defined into the array $this->menus into the module descriptor file. You can edit manually this file or use the embedded editor.

Note: Once defined (and module re-activated), menus are also visible into the menu editor available to administrator users on %s. +DictionariesDefDescTooltip=The dictionaries provided by your module/application are defined into the array $this->dictionaries into the module descriptor file. You can edit manually this file or use the embedded editor.

Note: Once defined (and module re-activated), dictionaries are also visible into the setup area to administrator users on %s. PermissionsDefDescTooltip=The permissions provided by your module/application are defined into the array $this->rights into the module descriptor file. You can edit manually this file or use the embedded editor.

Note: Once defined (and module re-activated), permissions are visible into the default permissions setup %s. HooksDefDesc=Define in the module_parts['hooks'] property, in the module descriptor, the context of hooks you want to manage (list of contexts can be found by a search on 'initHooks(' in core code).
Edit the hook file to add code of your hooked functions (hookable functions can be found by a search on 'executeHooks' in core code). TriggerDefDesc=Define in the trigger file the code you want to execute for each business event executed. @@ -109,6 +114,8 @@ ContentOfREADMECustomized=Note: The content of the README.md file has been repla RealPathOfModule=Real path of module ContentCantBeEmpty=Content of file can't be empty WidgetDesc=You can generate and edit here the widgets that will be embedded with your module. +CSSDesc=You can generate and edit here a file with personalized CSS embedded with your module. +JSDesc=You can generate and edit here a file with personalized Javascript embedded with your module. CLIDesc=You can generate here some command line scripts you want to provide with your module. CLIFile=CLI File NoCLIFile=No CLI files diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 9fbbe6a7161..5d51be56e56 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -1,4 +1,5 @@ Mrp=Manufacturing Orders +MO=Manufacturing Order MRPDescription=Module to manage Manufacturing Orders (MO). MRPArea=MRP Area MrpSetupPage=Setup of module MO diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index a010a64b907..3d22b338166 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -11,6 +11,7 @@ OrderDate=Order date OrderDateShort=Order date OrderToProcess=Order to process NewOrder=New order +NewOrderSupplier=New Purchase Order ToOrder=Make order MakeOrder=Make order SupplierOrder=Purchase order @@ -70,6 +71,7 @@ DeleteOrder=Delete order CancelOrder=Cancel order OrderReopened= Order %s Reopened AddOrder=Create order +AddPurchaseOrder=Create purchase order AddToDraftOrders=Add to draft order ShowOrder=Show order OrdersOpened=Orders to process diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 480a2aa91e5..b66d501f3ce 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -292,6 +292,7 @@ ProductWeight=Weight for 1 product ProductVolume=Volume for 1 product WeightUnits=Weight unit VolumeUnits=Volume unit +SurfaceUnits=Surface unit SizeUnits=Size unit DeleteProductBuyPrice=Delete buying price ConfirmDeleteProductBuyPrice=Are you sure you want to delete this buying price? diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index b375a3e16e0..afeed4b318d 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -476,6 +476,7 @@ Category=Tag/catégorie By=Par From=Du to=au +To=à and=et or=ou Other=Autre diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f522ad29fa8..0a225bb3aaf 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1277,7 +1277,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr if (GETPOSTISSET('dol_optimize_smallscreen')) { $themeparam.='&dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen', 'int'); } if (GETPOSTISSET('dol_no_mouse_hover')) { $themeparam.='&dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover', 'int'); } if (GETPOSTISSET('dol_use_jmobile')) { $themeparam.='&dol_use_jmobile='.GETPOST('dol_use_jmobile', 'int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile', 'int'); } - if (GETPOSTISSET('THEME_AGRESSIVITY_RATIO')) { $themeparam.='&THEME_AGRESSIVITY_RATIO='.GETPOST('THEME_AGRESSIVITY_RATIO', 'int'); } + if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) { $themeparam.='&THEME_AGRESSIVENESS_RATIO='.GETPOST('THEME_AGRESSIVENESS_RATIO', 'int'); } if (! defined('DISABLE_JQUERY') && ! $disablejs && $conf->use_javascript_ajax) { diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 970d4841fbf..0bb48af3b46 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -153,6 +153,12 @@ if ($dirins && $action == 'initmodule' && $modulename) dol_delete_file($destdir.'/class/api_'.strtolower($modulename).'.class.php'); dol_delete_dir($destdir.'/class'); + dol_delete_file($destdir.'/css/'.strtolower($modulename).'.css.php'); + dol_delete_dir($destdir.'/css'); + + dol_delete_file($destdir.'/js/'.strtolower($modulename).'.js.php'); + dol_delete_dir($destdir.'/js'); + dol_delete_file($destdir.'/scripts/'.strtolower($modulename).'.php'); dol_delete_dir($destdir.'/scripts'); @@ -163,7 +169,7 @@ if ($dirins && $action == 'initmodule' && $modulename) dol_delete_file($destdir.'/myobject_agenda.php'); dol_delete_file($destdir.'/myobject_list.php'); dol_delete_file($destdir.'/lib/'.strtolower($modulename).'_myobject.lib.php'); - dol_delete_file($destdir.'/test/phpunit/MyObjectFunctionnalTest.php'); + dol_delete_file($destdir.'/test/phpunit/MyModuleFunctionnalTest.php'); dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); dol_delete_file($destdir.'/test/phpunit'); dol_delete_file($destdir.'/test'); @@ -259,6 +265,11 @@ if ($dirins && $action == 'initapi' && !empty($module)) dolReplaceInFile($destfile, $arrayreplacement); } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } } if ($dirins && $action == 'initphpunit' && !empty($module)) { @@ -270,9 +281,7 @@ if ($dirins && $action == 'initphpunit' && !empty($module)) $srcfile = $srcdir.'/test/phpunit/MyObjectTest.php'; $destfile = $dirins.'/'.strtolower($module).'/test/phpunit/'.strtolower($objectname).'Test.php'; $result = dol_copy($srcfile, $destfile, 0, 0); - /*$srcfile = $srcdir.'/test/phpunit/MyModuleFunctionnalTest.class.php'; - $destfile = $dirins.'/'.strtolower($module).'/test/phpunit/'.strtolower($module).'FunctionnalTest.class.php'; - $result = dol_copy($srcfile, $destfile, 0, 0);*/ + if ($result > 0) { //var_dump($phpfileval['fullname']); @@ -295,6 +304,8 @@ if ($dirins && $action == 'initphpunit' && !empty($module)) } else { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); } } if ($dirins && $action == 'initsqlextrafields' && !empty($module)) @@ -327,13 +338,21 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) 'Mon module'=>$modulename, 'mon module'=>$modulename, 'htdocs/modulebuilder/template'=>strtolower($modulename), + 'My Object'=>$objectname, + 'MyObject'=>$objectname, + 'my object'=>strtolower($objectname), + 'myobject'=>strtolower($objectname), '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') ); dolReplaceInFile($destfile1, $arrayreplacement); dolReplaceInFile($destfile2, $arrayreplacement); } - + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', ''), null, 'errors'); + } // TODO Enable in class the property $isextrafieldmanaged = 1 } if ($dirins && $action == 'inithook' && !empty($module)) @@ -364,6 +383,11 @@ if ($dirins && $action == 'inithook' && !empty($module)) dolReplaceInFile($destfile, $arrayreplacement); } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } } if ($dirins && $action == 'inittrigger' && !empty($module)) { @@ -393,6 +417,11 @@ if ($dirins && $action == 'inittrigger' && !empty($module)) dolReplaceInFile($destfile, $arrayreplacement); } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } } if ($dirins && $action == 'initwidget' && !empty($module)) { @@ -422,6 +451,79 @@ if ($dirins && $action == 'initwidget' && !empty($module)) dolReplaceInFile($destfile, $arrayreplacement); } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } +} +if ($dirins && $action == 'initcss' && !empty($module)) +{ + dol_mkdir($dirins.'/'.strtolower($module).'/css'); + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $srcfile = $srcdir.'/css/mymodule.css.php'; + $destfile = $dirins.'/'.strtolower($module).'/css/'.strtolower($module).'.css.php'; + //var_dump($srcfile);var_dump($destfile); + $result = dol_copy($srcfile, $destfile, 0, 0); + + if ($result > 0) + { + $modulename = ucfirst($module); // Force first letter in uppercase + + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'my module'=>$modulename, + 'Mon module'=>$modulename, + 'mon module'=>$modulename, + 'htdocs/modulebuilder/template'=>strtolower($modulename), + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + ); + + dolReplaceInFile($destfile, $arrayreplacement); + } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } +} +if ($dirins && $action == 'initjs' && !empty($module)) +{ + dol_mkdir($dirins.'/'.strtolower($module).'/js'); + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $srcfile = $srcdir.'/js/mymodule.js.php'; + $destfile = $dirins.'/'.strtolower($module).'/js/'.strtolower($module).'.js.php'; + //var_dump($srcfile);var_dump($destfile); + $result = dol_copy($srcfile, $destfile, 0, 0); + + if ($result > 0) + { + $modulename = ucfirst($module); // Force first letter in uppercase + + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'my module'=>$modulename, + 'Mon module'=>$modulename, + 'mon module'=>$modulename, + 'htdocs/modulebuilder/template'=>strtolower($modulename), + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + ); + + dolReplaceInFile($destfile, $arrayreplacement); + } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } } if ($dirins && $action == 'initcli' && !empty($module)) { @@ -456,6 +558,11 @@ if ($dirins && $action == 'initcli' && !empty($module)) dolReplaceInFile($destfile, $arrayreplacement); } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } } if ($dirins && $action == 'initdoc' && !empty($module)) { @@ -502,6 +609,11 @@ if ($dirins && $action == 'initdoc' && !empty($module)) dol_delete_file($outputfiledoc, 0, 0, 0, null, false, 0); dol_delete_file($outputfiledocpdf, 0, 0, 0, null, false, 0); } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); + } } if ($dirins && $action == 'addlanguage' && !empty($module)) @@ -595,12 +707,15 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', // visible $visible = -1; if ($fieldname == 'entity') $visible = -2; - if ($fieldname == 'model_pdf') $visible = 0; + if (in_array($fieldname, array('model_pdf', 'note_public', 'note_private'))) $visible = 0; // enabled $enabled = 1; // default $default = ''; if ($fieldname == 'entity') $default=1; + // position + $position = $i; + if (in_array($fieldname, array('status', 'statut', 'fk_status', 'fk_statut'))) $position = 500; $string.= "'".$obj->Field."' =>array('type'=>'".$type."', 'label'=>'".$label."',"; if ($default != '') $string.= " 'default'=>".$default.","; @@ -608,7 +723,7 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', $string.= " 'visible'=>".$visible; if ($notnull) $string.= ", 'notnull'=>".$notnull; if ($fieldname == 'ref') $string.= ", 'showoncombobox'=>1"; - $string.= ", 'position'=>".$i."),\n"; + $string.= ", 'position'=>".$position."),\n"; $string.="
"; $i+=5; } @@ -668,8 +783,9 @@ if ($dirins && $action == 'initobject' && $module && $objectname) 'lib/mymodule_myobject.lib.php'=>'lib/'.strtolower($module).'_'.strtolower($objectname).'.lib.php', //'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.strtolower($objectname).'Test.php', 'sql/llx_mymodule_myobject.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql', - 'sql/llx_mymodule_myobject_extrafields.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.sql', 'sql/llx_mymodule_myobject.key.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql', + 'sql/llx_mymodule_myobject_extrafields.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.sql', + 'sql/llx_mymodule_myobject_extrafields.key.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.key.sql', //'scripts/mymodule.php'=>'scripts/'.strtolower($objectname).'.php', 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', @@ -1536,6 +1652,11 @@ elseif (! empty($module)) $head2[$h][2] = 'languages'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=dictionaries&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("Dictionaries"); + $head2[$h][2] = 'dictionaries'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:''); $head2[$h][1] = $langs->trans("Objects"); $head2[$h][2] = 'objects'; @@ -1566,6 +1687,16 @@ elseif (! empty($module)) $head2[$h][2] = 'widgets'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=css&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("CSS"); + $head2[$h][2] = 'css'; + $h++; + + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=js&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("JS"); + $head2[$h][2] = 'js'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cli&module='.$module.($forceddirread?'@'.$dirread:''); $head2[$h][1] = $langs->trans("CLI"); $head2[$h][2] = 'cli'; @@ -1819,6 +1950,139 @@ elseif (! empty($module)) } } + if ($tab == 'dictionaries') + { + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + + $dicts = $moduleobj->dictionaries; + + if ($action != 'editfile' || empty($file)) + { + print ''; + $htmlhelp=$langs->trans("DictionariesDefDescTooltip", ''.$langs->trans('Setup').' - '.$langs->trans('Dictionaries').''); + print $form->textwithpicto($langs->trans("DictionariesDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'
'; + print '
'; + print '
'; + + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("LanguageFile").' : '.$dicts['langs'].'
'; + + print load_fiche_titre($langs->trans("ListOfDictionariesEntries"), '', ''); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print ''; + + print ''; + print_liste_field_titre("#", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Table", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("SQL", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("SQLSort", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("FieldsView", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("FieldsEdit", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("FieldsInsert", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Rowid", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Condition", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print "\n"; + + if (is_array($dicts)) + { + $i = 0; + $maxi = count($dicts['tabname']); + while ($i < $maxi) + { + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + $i++; + } + } + else + { + print ''; + } + + print '
'; + print ($i + 1); + print ''; + print $dicts['tabname'][$i]; + print ''; + print $dicts['tablib'][$i]; + print ''; + print $dicts['tabsql'][$i]; + print ''; + print $dicts['tabsqlsort'][$i]; + print ''; + print $dicts['tabfield'][$i]; + print ''; + print $dicts['tabfieldvalue'][$i]; + print ''; + print $dicts['tabfieldinsert'][$i]; + print ''; + print $dicts['tabrowid'][$i]; + print ''; + print $dicts['tabcond'][$i]; + print '
'.$langs->trans("None").'
'; + print '
'; + + print ''; + } + else + { + $fullpathoffile=dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print '
'; + } + } + if ($tab == 'objects') { $head3 = array(); @@ -1973,14 +2237,14 @@ elseif (! empty($module)) print '
'; print ' '.$langs->trans("ClassFile").' : '.($realpathtoclass?'':'').$pathtoclass.($realpathtoclass?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("ApiClassFile").' : '.($realpathtoapi?'':'').$pathtoapi.($realpathtoapi?'':'').''; if ($realpathtoapi) { - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; print '   '; if (empty($conf->global->$const_name)) // If module is not activated { @@ -1994,7 +2258,7 @@ elseif (! empty($module)) else { //print ''.$langs->trans("FileNotYetGenerated").' '; - print ''; + print ''; } // PHPUnit print '
'; @@ -2002,24 +2266,24 @@ elseif (! empty($module)) if ($realpathtophpunit) { - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } else { //print ''.$langs->trans("FileNotYetGenerated").' '; - print ''; + print ''; } print '
'; print '
'; print ' '.$langs->trans("PageForLib").' : '.($realpathtolib?'':'').$pathtolib.($realpathtolib?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("PageForObjLib").' : '.($realpathtoobjlib?'':'').$pathtoobjlib.($realpathtoobjlib?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("Image").' : '.($realpathtopicto?'':'').$pathtopicto.($realpathtopicto?'':'').''; //print ' '.img_picto($langs->trans("Edit"), 'edit').''; @@ -2027,34 +2291,34 @@ elseif (! empty($module)) print '
'; print ' '.$langs->trans("SqlFile").' : '.($realpathtosql?'':'').$pathtosql.($realpathtosql?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '   '.$langs->trans("DropTableIfEmpty").''; //print '   '.$langs->trans("RunSql").''; print '
'; + print ' '.$langs->trans("SqlFileKey").' : '.($realpathtosqlkey?'':'').$pathtosqlkey.($realpathtosqlkey?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + //print '   '.$langs->trans("RunSql").''; + print '
'; print ' '.$langs->trans("SqlFileExtraFields").' : '.($realpathtosqlextra?'':'').$pathtosqlextra.($realpathtosqlextra?'':'').''; if ($realpathtosqlextra) { - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; print '   '; - print ''.$langs->trans("DropTableIfEmpty").''; + print ''.$langs->trans("DropTableIfEmpty").''; } else { - print ''; + print ''; } //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileKey").' : '.($realpathtosqlkey?'':'').$pathtosqlkey.($realpathtosqlkey?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - //print '   '.$langs->trans("RunSql").''; - print '
'; print ' '.$langs->trans("SqlFileKeyExtraFields").' : '.($realpathtosqlextrakey?'':'').$pathtosqlextrakey.($realpathtosqlextrakey?'':'').''; if ($realpathtosqlextrakey) { - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } //print '   '.$langs->trans("RunSql").''; print '
'; @@ -2067,33 +2331,33 @@ elseif (! empty($module)) print '
'; print ' '.$langs->trans("PageForList").' : '.($realpathtolist?'':'').$pathtolist.($realpathtolist?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("PageForCreateEditView").' : '.($realpathtocard?'':'').$pathtocard.($realpathtocard?'':'').'?action=create'; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("PageForAgendaTab").' : '.($realpathtoagenda?'':'').$pathtoagenda.($realpathtoagenda?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; if ($realpathtoagenda) { print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } print '
'; print ' '.$langs->trans("PageForDocumentTab").' : '.($realpathtodocument?'':'').$pathtodocument.($realpathtodocument?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; if ($realpathtodocument) { print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } print '
'; print ' '.$langs->trans("PageForNoteTab").' : '.($realpathtonote?'':'').$pathtonote.($realpathtonote?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; if ($realpathtonote) { print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } print '
'; @@ -2428,9 +2692,9 @@ elseif (! empty($module)) print_liste_field_titre("LanguageFile", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Position", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Enabled", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("perms", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Permission", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Target", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("UserType", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("UserType", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'right '); print "
'; + print ''; print $menu['user']; print '
'; + + print ''; + print ''; + } + else + { + print ''.$langs->trans("FileNotYetGenerated").''; + print ''; + } + print ''; + } + else + { + $fullpathoffile=dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print ''; + } + } + + if ($tab == 'js') + { + if ($action != 'editfile' || empty($file)) + { + print ''.$langs->trans("JSDesc").'
'; + print '
'; + + print '
'; + $pathtohook = strtolower($module).'/css/'.strtolower($module).'.css.php'; + print ' '.$langs->trans("CSSFile").' : '; + if (dol_is_file($dirins.'/'.$pathtohook)) + { + print ''.$pathtohook.''; + print ''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').'
'; + + print ''; + print ''; + } + else + { + print ''.$langs->trans("FileNotYetGenerated").''; + print ''; + } + print ''; + } + else + { + $fullpathoffile=dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print ''; + } + } + if ($tab == 'widgets') { require_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; diff --git a/htdocs/modulebuilder/template/.gitignore b/htdocs/modulebuilder/template/.gitignore index e950cee245d..942cb8b03ba 100644 --- a/htdocs/modulebuilder/template/.gitignore +++ b/htdocs/modulebuilder/template/.gitignore @@ -13,4 +13,6 @@ /doc/user/build /.settings/ /.buildpath -/.project \ No newline at end of file +/.project +# Other +*.back \ No newline at end of file diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 1f83308f1d7..d6474a480dc 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -64,7 +64,8 @@ class MyObject extends CommonObject /** - * 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') + * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'enabled' is a condition when the field must be managed. * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing) @@ -81,6 +82,7 @@ class MyObject extends CommonObject * 'comment' is not used. You can store here any text of your choice. It is not used by application. * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. */ // BEGIN MODULEBUILDER PROPERTIES @@ -94,8 +96,9 @@ class MyObject extends CommonObject 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'), 'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), - 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>0, 'position'=>60), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), + 'fk_project' =>array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,), + 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60), 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500), @@ -652,43 +655,22 @@ class MyObject extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelstatus)) + if (empty($this->labelstatus) || empty($this->labelstatusshort)) { global $langs; //$langs->load("mymodule"); $this->labelstatus[self::STATUS_DRAFT] = $langs->trans('Draft'); $this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); + $this->labelstatusshort[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelstatusshort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelstatusshort[self::STATUS_CANCELED] = $langs->trans('Disabled'); } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } + $statusType = 'status'.$status; + if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + + return dolGetStatus($this->labelstatus[$status], $this->labelstatusshort[$status], '', $statusType, $mode); } /** diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index aa21942cf2a..026f46fb925 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -125,7 +125,7 @@ class modMyModule extends DolibarrModules $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) $this->langfiles = array("mymodule@mymodule"); $this->phpmin = array(5,5); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(8,0); // Minimum version of Dolibarr required by module + $this->need_dolibarr_version = array(11,-3); // Minimum version of Dolibarr required by module $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) //$this->automatic_activation = array('FR'=>'MyModuleWasAutomaticallyActivatedBecauseOfYourCountryChoice'); @@ -183,25 +183,25 @@ class modMyModule extends DolibarrModules $this->dictionaries=array(); /* Example: $this->dictionaries=array( - 'langs'=>'mylangfile@mymodule', + 'langs'=>'mymodule@mymodule', // List of tables we want to see into dictonnary editor - 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), + 'tabname'=>array(MAIN_DB_PREFIX."table1", MAIN_DB_PREFIX."table2", MAIN_DB_PREFIX."table3"), // Label of tables - 'tablib'=>array("Table1","Table2","Table3"), + 'tablib'=>array("Table1", "Table2", "Table3"), // Request to select fields - 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Sort order - 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), + 'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"), // List of fields (result of select to show dictionary) - 'tabfield'=>array("code,label","code,label","code,label"), + 'tabfield'=>array("code,label", "code,label", "code,label"), // List of fields (list of fields to edit a record) - 'tabfieldvalue'=>array("code,label","code,label","code,label"), + 'tabfieldvalue'=>array("code,label", "code,label", "code,label"), // List of fields (list of fields for insert) - 'tabfieldinsert'=>array("code,label","code,label","code,label"), + 'tabfieldinsert'=>array("code,label", "code,label", "code,label"), // Name of columns with primary key (try to always name it 'rowid') - 'tabrowid'=>array("rowid","rowid","rowid"), + 'tabrowid'=>array("rowid", "rowid", "rowid"), // Condition to show each dictionary - 'tabcond'=>array($conf->mymodule->enabled,$conf->mymodule->enabled,$conf->mymodule->enabled) + 'tabcond'=>array($conf->mymodule->enabled, $conf->mymodule->enabled, $conf->mymodule->enabled) ); */ @@ -246,18 +246,18 @@ class modMyModule extends DolibarrModules /* BEGIN MODULEBUILDER PERMISSIONS */ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Read objects of MyModule'; // Permission label - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) $r++; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/Update objects of MyModule'; // Permission label - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) $r++; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label - $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) $r++; /* END MODULEBUILDER PERMISSIONS */ @@ -276,14 +276,28 @@ class modMyModule extends DolibarrModules 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); /* END MODULEBUILDER TOPMENU */ /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT $this->menu[$r++]=array( - 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Top menu entry + 'titre'=>'MyObject', + 'mainmenu'=>'mymodule', + 'leftmenu'=>'myobject', + 'url'=>'/mymodule/mymoduleindex.php', + 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry 'titre'=>'List MyObject', 'mainmenu'=>'mymodule', @@ -292,12 +306,12 @@ class modMyModule extends DolibarrModules 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); $this->menu[$r++]=array( - 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry 'titre'=>'New MyObject', 'mainmenu'=>'mymodule', @@ -306,7 +320,7 @@ class modMyModule extends DolibarrModules 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->mymodule->myobject->write', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 5727d596a6d..fcf8b1f8a06 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -105,10 +105,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); -$permissionnote=$user->rights->mymodule->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->mymodule->write; // Used by the include of actions_dellink.inc.php -$permissionedit=$user->rights->mymodule->write; // Used by the include of actions_lineupdown.inc.php -$permissiontoadd=$user->rights->mymodule->write; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->rights->mymodule->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->mymodule->write; // Used by the include of actions_dellink.inc.php +$permissionedit = $user->rights->mymodule->write; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd = $user->rights->mymodule->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); @@ -124,11 +125,11 @@ if (empty($reshook)) { $error=0; - $permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1); - if (empty($backtopage)) { - if (empty($id) && $action != 'add' && $action != 'create') $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); } $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record @@ -141,6 +142,18 @@ if (empty($reshook)) // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + if ($action == 'set_thirdparty' && $permissiontoadd) + { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MYOBJECT_MODIFY'); + } + if ($action == 'classin' && $permissiontoadd) + { + $object->setProject(GETPOST('projectid', 'int')); + } + // Actions to send emails $trigger_name='MYOBJECT_SENTBYMAIL'; $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; @@ -226,7 +239,7 @@ if (($id || $ref) && $action == 'edit') dol_fiche_head(); - print '
'; + $pathtohook = strtolower($module).'/js/'.strtolower($module).'.js.php'; + print ' '.$langs->trans("JSFile").' : '; + if (dol_is_file($dirins.'/'.$pathtohook)) + { + print ''.$pathtohook.''; + print ''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').'
'."\n"; + print '
'."\n"; // Common attributes include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; @@ -309,7 +322,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project if (! empty($conf->projet->enabled)) { @@ -354,6 +367,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Common attributes //$keyforbreak='fieldkeytoswitchonsecondcolumn'; + //unset($object->fields['fk_project']); // Hide field already shown in banner + //unset($object->fields['fk_soc']); // Hide field already shown in banner include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; // Other attributes. Fields from hook formObjectOptions and Extrafields. diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 5e40b12a076..8deb44b9009 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -53,11 +53,6 @@ $confirm=GETPOST('confirm'); $id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); -// Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; -//$result = restrictedArea($user, 'mymodule', $id); - // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -84,6 +79,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu //if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity?$object->entity:$conf->entity] . "/myobject/" . dol_sanitizeFileName($object->id); if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity?$object->entity:$conf->entity] . "/myobject/" . dol_sanitizeFileName($object->ref); +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'mymodule', $object->id); + + /* * Actions diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index bf24be61023..525fa879562 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -360,7 +360,7 @@ print ''; print ''; print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/mymodule/myobject_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->mymodule->write); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/mymodule/myobject_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->mymodule->write); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); diff --git a/htdocs/mrp/ajax/ajax_bom.php b/htdocs/mrp/ajax/ajax_bom.php new file mode 100644 index 00000000000..76f1572353b --- /dev/null +++ b/htdocs/mrp/ajax/ajax_bom.php @@ -0,0 +1,56 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/mrp/ajax/ajax.php + * \brief Ajax search component for Mrp. It get BOM content. + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); + +require '../../main.inc.php'; // Load $user and permissions +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; + +$idbom = GETPOST('idbom', 'alpha'); +$action = GETPOST('action', 'alpha'); + + +/* + * View + */ + +$object = new BOM($db); +$result=$object->fetch($idbom); +if ($result > 0) +{ + // We remove properties we don't need in answer + unset($object->fields); + unset($object->db); + echo json_encode($object); +} +else +{ + echo 'Failed to load category with id='.$idbom; +} diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 5bac2320b24..4f069e885bd 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -96,19 +96,19 @@ class Mo extends CommonObject 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>-1, 'position'=>20, 'notnull'=>1, 'default'=>'1', 'index'=>1,), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',), 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'index'=>1, 'comment'=>"Qty to produce",), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-1, 'position'=>61, 'notnull'=>-1,), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-1, 'position'=>62, 'notnull'=>-1,), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'notnull'=>-1,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>-1,), 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid',), 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",), 'date_start_planned' => array('type'=>'datetime', 'label'=>'DateStartPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'notnull'=>-1, 'index'=>1, 'help'=>'KeepEmptyForAsap'), 'date_end_planned' => array('type'=>'datetime', 'label'=>'DateEndPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>56, 'notnull'=>-1, 'index'=>1,), - 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,), + 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,), 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>4, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated', '2'=>'InProgress', '3'=>'Done', '-1'=>'Canceled')), ); public $rowid; @@ -475,7 +475,7 @@ class Mo extends CommonObject $result = ''; - $label = '' . $langs->trans("Mo") . ''; + $label = '' . $langs->trans("MO") . ''; $label.= '
'; $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; @@ -553,34 +553,10 @@ class Mo extends CommonObject $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } + $statusType = 'status'.$status; + //if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + + return dolGetStatus($this->labelstatus[$status], $this->labelstatus[$status], '', $statusType, $mode); } /** diff --git a/htdocs/mrp/lib/mrp_mo.lib.php b/htdocs/mrp/lib/mrp_mo.lib.php index 6189761269e..fe29c774f44 100644 --- a/htdocs/mrp/lib/mrp_mo.lib.php +++ b/htdocs/mrp/lib/mrp_mo.lib.php @@ -36,11 +36,16 @@ function moPrepareHead($object) $h = 0; $head = array(); - $head[$h][0] = dol_buildpath("/mrp/mo_card.php", 1).'?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/mrp/mo_production.php?id='.$object->id; + $head[$h][1] = $langs->trans("Production"); + $head[$h][2] = 'production'; + $h++; + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { $nbNote = 0; diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index aab1ff10581..a86d062c5e4 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -23,19 +23,7 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -142,7 +130,7 @@ if ($object->id > 0) $head = moPrepareHead($object); - dol_fiche_head($head, 'agenda', $langs->trans("Mo"), -1, $object->picto); + dol_fiche_head($head, 'agenda', $langs->trans("MO"), -1, $object->picto); // Object card // ------------------------------------------------------------ diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index f15b45b96e5..7a26660d6dc 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,22 +42,11 @@ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; dol_include_once('/mrp/class/mo.class.php'); dol_include_once('/mrp/lib/mrp_mo.lib.php'); @@ -109,7 +97,7 @@ $permissionnote=$user->rights->mrp->write; // Used by the include of actions_set $permissiondellink=$user->rights->mrp->write; // Used by the include of actions_dellink.inc.php $permissionedit=$user->rights->mrp->write; // Used by the include of actions_lineupdown.inc.php $permissiontoadd=$user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php - +$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object->status == 0); /* @@ -126,11 +114,12 @@ if (empty($reshook)) { $error=0; - $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object->status == 0); $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); - if (empty($backtopage)) { - if (empty($id)) $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/mrp/mo_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + + if (empty($backtopage) || ($cancel && empty($id))) { + //var_dump($backurlforlist);exit; + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); } $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record @@ -143,6 +132,18 @@ if (empty($reshook)) // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + if ($action == 'set_thirdparty' && $permissiontoadd) + { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); + } + if ($action == 'classin' && $permissiontoadd) + { + $object->setProject(GETPOST('projectid', 'int')); + } + // Actions to send emails $trigger_name='MO_SENTBYMAIL'; $autocopy='MAIN_MAIL_AUTOCOPY_MO_TO'; @@ -155,12 +156,10 @@ if (empty($reshook)) /* * View - * - * Put here all code to build page */ $form=new Form($db); -$formfile=new FormFile($db); +$formproject=new FormProjets($db); llxHeader('', $langs->trans('Mo'), ''); @@ -204,16 +203,37 @@ if ($action == 'create') dol_fiche_end(); - print ' + ?> - '; + '; print ''; @@ -227,7 +247,7 @@ if ($action == 'create') // Part to edit record if (($id || $ref) && $action == 'edit') { - print load_fiche_titre($langs->trans("Mo"), '', 'cubes'); + print load_fiche_titre($langs->trans("MO"), '', 'cubes'); print '
'; print ''; @@ -237,7 +257,9 @@ if (($id || $ref) && $action == 'edit') dol_fiche_head(); - print '
'."\n"; + $object->fields['fk_bom']['disabled'] = 1; + + print '
'."\n"; // Common attributes include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; @@ -259,10 +281,11 @@ 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_thirdparty(); + $res = $object->fetch_optionals(); $head = moPrepareHead($object); - dol_fiche_head($head, 'card', $langs->trans("Mo"), -1, $object->picto); + dol_fiche_head($head, 'card', $langs->trans("MO"), -1, $object->picto); $formconfirm = ''; @@ -283,23 +306,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - // Confirmation of action xxxx - if ($action == 'xxx') - { - $formquestion=array(); - /* - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) - ); - */ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); - } - // Call Hook formConfirm $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -318,9 +324,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea /* // Ref bis $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/ // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project if (! empty($conf->projet->enabled)) { @@ -331,15 +337,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.=''; $morehtmlref.=''; $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=$formproject->select_projects($object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=''; $morehtmlref.=''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'none', 0, 0, 0, 1); } } else { if (! empty($object->fk_project)) { @@ -351,7 +357,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } } - */ $morehtmlref.=''; @@ -364,7 +369,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'."\n"; // Common attributes - //$keyforbreak='fieldkeytoswitchonsecondcolumn'; + $keyforbreak='qty'; + unset($object->fields['fk_project']); + unset($object->fields['fk_soc']); include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; // Other attributes @@ -459,23 +466,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Clone if (! empty($user->rights->mrp->write)) { - print ''; + print ''; } - /* - if ($user->rights->mrp->write) - { - if ($object->status == 1) - { - print ''.$langs->trans("Disable").''."\n"; - } - else - { - print ''.$langs->trans("Enable").''."\n"; - } - } - */ - // Delete (need delete permission, or if draft, just need create/modify permission) if (! empty($user->rights->mrp->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mrp->write))) { diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php index 09f34ae583e..3732754a62f 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_document.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,19 +22,7 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -111,7 +98,7 @@ if ($object->id) */ $head = moPrepareHead($object); - dol_fiche_head($head, 'document', $langs->trans("Mo"), -1, $object->picto); + dol_fiche_head($head, 'document', $langs->trans("MO"), -1, $object->picto); // Build file list diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 2f32058a41f..96f19540a95 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,6 +42,7 @@ // Load Dolibarr environment require '../main.inc.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php index a006f79a609..f815dfbaef6 100644 --- a/htdocs/mrp/mo_note.php +++ b/htdocs/mrp/mo_note.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,19 +22,7 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +require '../main.inc.php'; dol_include_once('/mrp/class/mo.class.php'); dol_include_once('/mrp/lib/mrp_mo.lib.php'); @@ -96,7 +83,7 @@ if ($id > 0 || ! empty($ref)) $head = moPrepareHead($object); - dol_fiche_head($head, 'note', $langs->trans("Mo"), -1, $object->picto); + dol_fiche_head($head, 'note', $langs->trans("MO"), -1, $object->picto); // Object card // ------------------------------------------------------------ diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php new file mode 100644 index 00000000000..70de7155f39 --- /dev/null +++ b/htdocs/mrp/mo_production.php @@ -0,0 +1,421 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file mo_production.php + * \ingroup mrp + * \brief Page to make production on a MO + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies + + +// Load Dolibarr environment +require '../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +dol_include_once('/mrp/class/mo.class.php'); +dol_include_once('/mrp/lib/mrp_mo.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mrp", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'mocard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); + +// Initialize technical objects +$object=new Mo($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('mocard','globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all", 'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); +} + +if (empty($action) && empty($id) && empty($ref)) $action='view'; + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$isdraft = (($object->statut == Mo::STATUS_DRAFT) ? 1 : 0); +//$result = restrictedArea($user, 'mrp', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); + +$permissionnote=$user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->mrp->write; // Used by the include of actions_dellink.inc.php +$permissionedit=$user->rights->mrp->write; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd=$user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object->status == 0); + + +/* + * Actions + * + * Put here all code to do according to value of "action" parameter + */ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + $error=0; + + $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); + + if (empty($backtopage) || ($cancel && empty($id))) { + //var_dump($backurlforlist);exit; + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); + } + $triggermodname = 'MRP_MO_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'; + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + if ($action == 'set_thirdparty' && $permissiontoadd) + { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); + } + if ($action == 'classin' && $permissiontoadd) + { + $object->setProject(GETPOST('projectid', 'int')); + } + + // Actions to send emails + $trigger_name='MO_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_MO_TO'; + $trackid='mo'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + + + +/* + * View + */ + +$form=new Form($db); +$formproject=new FormProjets($db); + +llxHeader('', $langs->trans('Mo'), ''); + +// Example : Adding jquery code +print ''; + + + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ + $res = $object->fetch_optionals(); + + $head = moPrepareHead($object); + dol_fiche_head($head, 'production', $langs->trans("MO"), -1, $object->picto); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); + } + // Confirmation to delete line + if ($action == 'deleteline') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + } + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') + { + $formquestion=array(); + /* + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/ + // Thirdparty + $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->mrp->write) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(); + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + print '
'."\n"; + + // Common attributes + $keyforbreak='qty'; + unset($object->fields['fk_project']); + unset($object->fields['fk_soc']); + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print ''; + print ''; + + print '
'; + + dol_fiche_end(); + + + /* + * Lines + */ + + if (! empty($object->table_element_line)) + { + // Show object lines + $result = $object->getLinesArray(); + + print '
+ + + + + '; + + 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 == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') + { + print ''; + } + + if (! empty($object->lines)) + { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); + } + + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') + { + if ($action != 'editline') + { + // Add products/services form + $object->formAddObjectLine(1, $mysoc, $soc); + + $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 == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') + { + print '
'; + } + print '
'; + + 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'); + + if (empty($reshook)) + { + // Send + print '' . $langs->trans('SendMail') . ''."\n"; + + // Modify + if (! empty($user->rights->mrp->write)) + { + print ''.$langs->trans("Modify").''."\n"; + } + else + { + print ''.$langs->trans('Modify').''."\n"; + } + + // Clone + if (! empty($user->rights->mrp->write)) + { + print ''; + } + + // Delete (need delete permission, or if draft, just need create/modify permission) + if (! empty($user->rights->mrp->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mrp->write))) + { + print ''.$langs->trans('Delete').''."\n"; + } + else + { + print ''.$langs->trans('Delete').''."\n"; + } + } + print '
'."\n"; + }*/ + + + if ($action != 'presend') + { + print '
'; + print ''; // ancre + + + + print '
'; + + + + print '
'; + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index a5365545f62..9c02fc35d16 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -181,19 +181,19 @@ class ActionsCardProduct // Weight $this->tpl['weight'] = $this->object->weight; - $this->tpl['weight_units'] = $formproduct->selectMeasuringUnits("weight_units", "weight", $this->object->weight_units); + $this->tpl['weight_units'] = $formproduct->selectMeasuringUnits("weight_units", "weight", $this->object->weight_units, 0, 2); // Length $this->tpl['length'] = $this->object->length; - $this->tpl['length_units'] = $formproduct->selectMeasuringUnits("length_units", "size", $this->object->length_units); + $this->tpl['length_units'] = $formproduct->selectMeasuringUnits("length_units", "size", $this->object->length_units, 0, 2); // Surface $this->tpl['surface'] = $this->object->surface; - $this->tpl['surface_units'] = $formproduct->selectMeasuringUnits("surface_units", "surface", $this->object->surface_units); + $this->tpl['surface_units'] = $formproduct->selectMeasuringUnits("surface_units", "surface", $this->object->surface_units, 0, 2); // Volume $this->tpl['volume'] = $this->object->volume; - $this->tpl['volume_units'] = $formproduct->selectMeasuringUnits("volume_units", "volume", $this->object->volume_units); + $this->tpl['volume_units'] = $formproduct->selectMeasuringUnits("volume_units", "volume", $this->object->volume_units, 0, 2); } if ($action == 'view') @@ -211,25 +211,25 @@ class ActionsCardProduct // Weight if ($this->object->weight != '') { - $this->tpl['weight'] = $this->object->weight." ".measuring_units_string($this->object->weight_units, "weight"); + $this->tpl['weight'] = $this->object->weight." ".measuringUnitString(0, "weight", $this->object->weight_units); } // Length if ($this->object->length != '') { - $this->tpl['length'] = $this->object->length." ".measuring_units_string($this->object->length_units, "size"); + $this->tpl['length'] = $this->object->length." ".measuringUnitString(0, "size", $this->object->length_units); } // Surface if ($this->object->surface != '') { - $this->tpl['surface'] = $this->object->surface." ".measuring_units_string($this->object->surface_units, "surface"); + $this->tpl['surface'] = $this->object->surface." ".measuringUnitString(0, "surface", $this->object->surface_units); } // Volume if ($this->object->volume != '') { - $this->tpl['volume'] = $this->object->volume." ".measuring_units_string($this->object->volume_units, "volume"); + $this->tpl['volume'] = $this->object->volume." ".measuringUnitString(0, "volume", $this->object->volume_units); } $this->tpl['fiche_end']=dol_get_fiche_end(); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 5ee8c502009..fa131e1df6e 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -73,6 +73,7 @@ $ref=GETPOST('ref', 'alpha'); $type=GETPOST('type', 'int'); $action=(GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view'); $cancel=GETPOST('cancel', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); $confirm=GETPOST('confirm', 'alpha'); $socid=GETPOST('socid', 'int'); $duration_value = GETPOST('duration_value', 'int'); @@ -357,8 +358,18 @@ if (empty($reshook)) $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - exit; + if (! empty($backtopage)) + { + $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation + if (preg_match('/\?/', $backtopage)) $backtopage.='&socid='.$object->id; // Old method + header("Location: ".$backtopage); + exit; + } + else + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + exit; + } } else { @@ -950,6 +961,7 @@ else print ''; if (! empty($modBarCodeProduct->code_auto)) print ''; + print ''; if ($type==1) $title=$langs->trans("NewService"); else $title=$langs->trans("NewProduct"); @@ -1070,12 +1082,6 @@ else print $form->selectarray('finished', $statutarray, GETPOST('finished', 'alpha'), 1); print '
'.$langs->trans("NetMeasure").''; - print ''; - print $formproduct->selectMeasuringUnits("net_measure_units", "net_measure", GETPOSTISSET('net_measure_units')?GETPOST('net_measure_units', 'alpha'):(empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT), 0, 2); - print '
'.$langs->trans("Weight").''; print ''; @@ -1108,6 +1114,15 @@ else print $formproduct->selectMeasuringUnits("volume_units", "volume", GETPOSTISSET('volume_units')?GETPOST('volume_units', 'alpha'):'0', 0, 2); print '
'.$langs->trans("NetMeasure").''; + print ''; + print $formproduct->selectMeasuringUnits("net_measure_units", '', GETPOSTISSET('net_measure_units')?GETPOST('net_measure_units', 'alpha'):(empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT), 0, 0); + print '
'.$langs->trans("NetMeasure").''; - print ' '; - print $form->selectUnits($object->net_measure_units, 'units'); - //print $formproduct->selectMeasuringUnits("net_measure_units", "weight", $object->net_measure_units, 0, 2); - print '
'.$langs->trans("Weight").''; print ' '; print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); print '
'.$langs->trans("NetMeasure").''; + print ' '; + print $formproduct->selectMeasuringUnits($object->net_measure_units, '', 0, 0, 0); + print '
'.$langs->trans("NetMeasure").''; - if ($object->net_measure != '') - { - print $object->net_measure." ".measuring_units_string(0, "weight", $object->net_measure_units); - } - else - { - print ' '; - } - // Brut Weight print '
'.$langs->trans("Weight").''; if ($object->weight != '') { - print $object->weight." ".measuring_units_string(0, "weight", $object->weight_units); + print $object->weight." ".measuringUnitString(0, "weight", $object->weight_units); } else { print ' '; } print "
'.$langs->trans("Surface").''; if ($object->surface != '') { - print $object->surface." ".measuring_units_string(0, "surface", $object->surface_units); + print $object->surface." ".measuringUnitString(0, "surface", $object->surface_units); } else { @@ -1922,7 +1930,7 @@ else print '
'.$langs->trans("Volume").''; if ($object->volume != '') { - print $object->volume." ".measuring_units_string(0, "volume", $object->volume_units); + print $object->volume." ".measuringUnitString(0, "volume", $object->volume_units); } else { @@ -1930,6 +1938,20 @@ else } print "
'.$langs->trans("NetMeasure").''; + if ($object->net_measure != '') + { + print $object->net_measure." ".measuringUnitString(0, "weight", $object->net_measure_units); + } + else + { + print ' '; + } + } } // Unit diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 33bf1240c92..72fd475e6ae 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -258,12 +258,25 @@ class FormProduct if ($empty) $out.=''; foreach($this->cache_warehouses as $id => $arraytypes) { + $label=''; + if ($showfullpath) $label.=$arraytypes['full_label']; + else $label.=$arraytypes['label']; + if (($fk_product || ($showstock > 0)) && ($arraytypes['stock'] != 0 || ($showstock > 0))) + { + if ($arraytypes['stock'] <= 0) { + $label.=' ('.$langs->trans("Stock").':'.$arraytypes['stock'].')'; + } + else + { + $label.=' ('.$langs->trans("Stock").':'.$arraytypes['stock'].')'; + } + } + $out.=''; } $out.=''; @@ -327,12 +340,12 @@ class FormProduct /** * Return a combo box with list of units - * For the moment, units labels are defined in measuring_units_string + * Units labels are defined in llx_c_units * * @param string $name Name of HTML field * @param string $measuring_style Unit to show: weight, size, surface, volume, time * @param string $default Preselected value - * @param int $adddefault Add empty unit called "Default" + * @param int|string $adddefault 1=Add empty unit called "Default", ''=Add empty value * @param int $mode 1=Use short label as value, 0=Use rowid, 2=Use scale (power) * @return string */ @@ -346,24 +359,26 @@ class FormProduct // TODO Use a cache require_once DOL_DOCUMENT_ROOT . '/core/class/cunits.class.php'; $measuringUnits = new CUnits($db); + + $filter = array(); + $filter['t.active'] = 1; + if ($measuring_style) $filter['t.unit_type'] = $measuring_style; + $result = $measuringUnits->fetchAll( '', '', 0, 0, - array( - 't.unit_type' => $measuring_style, - 't.active' => 1, - ) + $filter ); if ($result < 0) { dol_print_error($db); return -1; } else { $return .= ''; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 3ee0cb5de1a..d14eba99fae 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -234,7 +234,7 @@ if ($id > 0 || ! empty($ref)) while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); - + if ($objp->type == Facture::TYPE_CREDIT_NOTE) $objp->qty=-($objp->qty); $total_ht+=$objp->total_ht; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 57dd181bc91..35b433c5a28 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -642,49 +642,23 @@ class Entrepot extends CommonObject /** * Return label of a given status * - * @param int $statut Status + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label of status */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; + $statusType = 'status5'; + if ($status > 0) $statusType = 'status4'; + $langs->load('stocks'); + $label = $langs->trans($this->statuts[$status]); + $labelshort = $langs->trans($this->statuts[$status]); - $picto = 'statut5'; - $label = $langs->trans($this->statuts[$statut]); - - - if ($mode == 0) - { - return $label; - } - elseif ($mode == 1) - { - return $label; - } - elseif ($mode == 2) - { - if ($statut > 0) $picto = 'statut4'; - return img_picto($label, $picto).' '.$label; - } - elseif ($mode == 3) - { - if ($statut > 0) $picto = 'statut4'; - return img_picto($label, $picto).' '.$label; - } - elseif ($mode == 4) - { - if ($statut > 0) $picto = 'statut4'; - return img_picto($label, $picto).' '.$label; - } - elseif ($mode == 5) - { - if ($statut > 0) $picto = 'statut4'; - return $label.' '.img_picto($label, $picto); - } + return dolGetStatus($label, $labelshort, '', $statusType, $mode); } diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 24d8e89e03b..a85b375b085 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -585,7 +585,7 @@ class MouvementStock extends CommonObject $sql .= " t.batch,"; $sql .= " t.eatby,"; $sql .= " t.sellby,"; - $sql .= " t.fk_projet"; + $sql .= " t.fk_projet as fk_project"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql.= ' WHERE 1 = 1'; //if (null !== $ref) { @@ -618,6 +618,7 @@ class MouvementStock extends CommonObject $this->batch = $obj->batch; $this->eatby = $this->db->jdate($obj->eatby); $this->sellby = $this->db->jdate($obj->sellby); + $this->fk_project = $obj->fk_project; } // Retreive all extrafield diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index ef307842017..5303fa78a6c 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -429,7 +429,7 @@ $sql.= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, e.fk_parent, e. $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; $sql.= " m.batch, m.price,"; $sql.= " m.type_mouvement,"; -$sql.= " m.fk_projet,"; +$sql.= " m.fk_projet as fk_project,"; $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql.= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields @@ -859,7 +859,7 @@ if ($resql) } if (! empty($arrayfields['m.fk_projet']['checked'])) { - // fk_projet + // fk_project print ''; print '  '; print ''; - if ($objp->fk_projet != 0) print $movement->get_origin($objp->fk_projet, 'project'); + if ($objp->fk_project != 0) print $movement->get_origin($objp->fk_project, 'project'); print '
'; @@ -635,13 +636,15 @@ elseif ($id > 0 || ! empty($ref)) $arrayfields['t.task_date_start']=array('label'=>$langs->trans("DateStart"), 'checked'=>1); $arrayfields['t.task_date_end']=array('label'=>$langs->trans("DateEnd"), 'checked'=>1); // Extra fields - if (is_array($extrafields_task->attribute_label) && count($extrafields_task->attribute_label)) + if (is_array($extrafields->attributes[$taskstatic->table_element]['label']) && count($extrafields->attributes[$taskstatic->table_element]['label']) > 0) { - foreach($extrafields_task->attribute_label as $key => $val) + foreach($extrafields->attributes[$taskstatic->table_element]['label'] as $key => $val) { - if (! empty($extrafields_task->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields_task->attribute_label[$key], 'checked'=>(($extrafields_task->attribute_list[$key]<0)?0:1), 'position'=>$extrafields_task->attribute_pos[$key], 'enabled'=>(abs($extrafields_task->attribute_list[$key])!=3 && $extrafields_task->attribute_perms[$key])); + if (! empty($extrafields->attributes[$taskstatic->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$taskstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$taskstatic->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$taskstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$taskstatic->table_element]['list'][$key])!=3 && $extrafields->attributes[$taskstatic->table_element]['perms'][$key])); } } + $arrayfields = dol_sort_array($arrayfields, 'position'); print '
'; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 2eb6697be82..3dc54cc2223 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -88,11 +88,9 @@ $hookmanager->initHooks(array('projecttasktime','globalcard')); $object = new Task($db); $projectstatic = new Project($db); -$extrafields_project = new ExtraFields($db); -$extrafields_task = new ExtraFields($db); - -$extrafields_project->fetch_name_optionals_label($projectstatic->table_element); -$extrafields_task->fetch_name_optionals_label($object->table_element); +$extrafields = new ExtraFields($db); +$extrafields->fetch_name_optionals_label($projectstatic->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); /* @@ -761,7 +759,6 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('tasktimelist')); - $extrafields = new ExtraFields($db); // Definition of fields for list $arrayfields=array(); @@ -777,13 +774,15 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $arrayfields['value'] =array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled)?0:1)); $arrayfields['valuebilled'] =array('label'=>$langs->trans("Billed"), 'checked'=>1, 'enabled'=>(((! empty($conf->global->PROJECT_HIDE_TASKS) || empty($conf->global->PROJECT_BILL_TIME_SPENT))?0:1) && $projectstatic->usage_bill_time)); // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } + $arrayfields = dol_sort_array($arrayfields, 'position'); $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); diff --git a/htdocs/public/emailing/mailing-unsubscribe.php b/htdocs/public/emailing/mailing-unsubscribe.php index adb6aa03c8d..48cdd1508e8 100644 --- a/htdocs/public/emailing/mailing-unsubscribe.php +++ b/htdocs/public/emailing/mailing-unsubscribe.php @@ -115,7 +115,7 @@ if (! empty($tag) && ($unsuscrib=='1')) */ // Update status communication of email (new usage) - $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$obj->entity.", '".$obj->email."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$db->escape($obj->entity).", '".$db->escape($obj->email)."')"; $resql=$db->query($sql); //if (! $resql) dol_print_error($db); No test on errors, may fail if already unsubscribed diff --git a/htdocs/public/theme/common/company.png b/htdocs/public/theme/common/company.png new file mode 100644 index 00000000000..b6abd4432af Binary files /dev/null and b/htdocs/public/theme/common/company.png differ diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 2c34cd55ee8..13eb53d86a6 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -102,7 +102,6 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element_line); - // Load object. Make an object->fetch include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once @@ -834,7 +833,7 @@ if ($action == 'create') print '
'; print $langs->trans("Weight"); print ' '; - $text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int')); + $text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'), 0, 2); $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); print '
'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->reception->creer).''; print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->reception->creer); - print ($object->trueWidth && $object->width_units!='')?' '.measuring_units_string($object->width_units, "size"):''; + print ($object->trueWidth && $object->width_units!='')?' '.measuringUnitString(0, "size", $object->width_units):''; print '
'.$form->editfieldkey("Height", 'trueHeight', $object->trueHeight, $object, $user->rights->reception->creer).''; - if($action=='edittrueHeight') + if ($action=='edittrueHeight') { print '
'; print ''; print ''; print ''; print ''; - print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units); + print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units, 0, 2); print ' '; print ' '; print '
'; @@ -1491,7 +1487,7 @@ elseif ($id || $ref) else { print $object->trueHeight; - print ($object->trueHeight && $object->height_units!='')?' '.measuring_units_string($object->height_units, "size"):''; + print ($object->trueHeight && $object->height_units!='')?' '.measuringUnitString(0, "size", $object->height_units):''; } print '
'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->reception->creer).''; print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->reception->creer); - print ($object->trueDepth && $object->depth_units!='')?' '.measuring_units_string($object->depth_units, "size"):''; + print ($object->trueDepth && $object->depth_units!='')?' '.measuringUnitString(0, "size", $object->depth_units):''; print '
'; - - $text=$lines[$i]->product->getNomUrl(1); $text.= ' - '.$label; $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->product->description)); @@ -1959,13 +1951,13 @@ elseif ($id || $ref) // Weight print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->weight*$lines[$i]->qty.' '.measuring_units_string($lines[$i]->product->weight_units, "weight"); + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->weight*$lines[$i]->qty.' '.measuringUnitString(0, "weight", $lines[$i]->product->weight_units); else print ' '; print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->volume*$lines[$i]->qty.' '.measuring_units_string($lines[$i]->product->volume_units, "volume"); + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->volume*$lines[$i]->qty.' '.measuringUnitString(0, "volume", $lines[$i]->product->volume_units); else print ' '; print '
'."\n"; - // Fields title search - print ''; + // Fields title search + // -------------------------------------------------------------------- + print ''; // Ref if (! empty($arrayfields['e.ref']['checked'])) { @@ -694,28 +695,8 @@ if ($resql) print ''; } // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; - } - } - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields from hook $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook @@ -902,23 +883,8 @@ if ($resql) } // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - } - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index ee1ec735086..0f003f05eb6 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -113,19 +113,17 @@ $arrayfields = array( ), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach ($extrafields->attribute_label as $key => $val) { - $typeofextrafield=$extrafields->attribute_type[$key]; - if ($typeofextrafield!='separate') { - $arrayfields["ef." . $key] = array( - 'label' => $extrafields->attribute_label[$key], - 'checked' => $extrafields->attribute_list[$key], - 'position' => $extrafields->attribute_pos[$key], - 'enabled' => $extrafields->attribute_perms[$key] - ); - } +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 92daac0fa9c..e51ceca9c37 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -635,15 +635,16 @@ if (empty($reshook)) { $db->commit(); - if (! empty($backtopage)) + if (! empty($backtopage)) { - if (preg_match('/\?/', $backtopage)) $backtopage.='&socid='.$object->id; + $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation + if (preg_match('/\?/', $backtopage)) $backtopage.='&socid='.$object->id; // Old method header("Location: ".$backtopage); exit; } else { - $url=$_SERVER["PHP_SELF"]."?socid=".$object->id; + $url=$_SERVER["PHP_SELF"]."?socid=".$object->id; // Old method if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/card.php?socid=".$object->id; elseif ($object->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/card.php?socid=".$object->id; @@ -2717,7 +2718,7 @@ else if ($user->rights->societe->creer) { - print ''.$langs->trans("Modify").''."\n"; + print ''.$langs->trans("Modify").''."\n"; } if (! empty($conf->adherent->enabled)) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 15670a2095d..1ed4916e3c9 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -72,10 +72,10 @@ class Thirdparties extends DolibarrApi * * @throws RestException */ - public function get($id) + public function get($id) { - return $this->_fetch($id); - } + return $this->_fetch($id); + } /** * Get properties of a thirdparty object by email. diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 6215b6288b4..36d33c6e221 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2003 Brian Fraval * Copyright (C) 2006 Andre Cianfarani @@ -833,7 +833,7 @@ class Societe extends CommonObject * Update parameters of third party * * @param int $id Id of company (deprecated, use 0 here and call update on an object loaded by a fetch) - * @param User $user Utilisateur qui demande la mise a jour + * @param User $user User who requests the update * @param int $call_trigger 0=no, 1=yes * @param int $allowmodcodeclient Inclut modif code client et code compta * @param int $allowmodcodefournisseur Inclut modif code fournisseur et code compta fournisseur @@ -1640,13 +1640,13 @@ class Societe extends CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Definit la societe comme un client + * Defines the company as a customer * - * @param float $remise Valeur en % de la remise - * @param string $note Note/Motif de modification de la remise - * @param User $user Utilisateur qui definie la remise + * @param float $remise Value in % of the discount + * @param string $note Note/Reason for changing the discount + * @param User $user User who sets the discount * @return int <0 if KO, >0 if OK */ public function set_remise_client($remise, $note, User $user) @@ -1654,7 +1654,7 @@ class Societe extends CommonObject // phpcs:enable global $conf, $langs; - // Nettoyage parametres + // Parameter cleaning $note=trim($note); if (! $note) { @@ -1670,7 +1670,7 @@ class Societe extends CommonObject $now=dol_now(); - // Positionne remise courante + // Position current discount $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; $sql.= " SET remise_client = '".$this->db->escape($remise)."'"; $sql.= " WHERE rowid = " . $this->id; @@ -1682,7 +1682,7 @@ class Societe extends CommonObject return -1; } - // Ecrit trace dans historique des remises + // Writes trace in discount history $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise"; $sql.= " (entity, datec, fk_soc, remise_client, note, fk_user_author)"; $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; @@ -1703,13 +1703,13 @@ class Societe extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Definit la societe comme un client + * Defines the company as a customer * - * @param float $remise Valeur en % de la remise - * @param string $note Note/Motif de modification de la remise - * @param User $user Utilisateur qui definie la remise + * @param float $remise Value in % of the discount + * @param string $note Note/Reason for changing the discount + * @param User $user User who sets the discount * @return int <0 if KO, >0 if OK */ public function set_remise_supplier($remise, $note, User $user) @@ -1717,7 +1717,7 @@ class Societe extends CommonObject // phpcs:enable global $conf, $langs; - // Nettoyage parametres + // Parameter cleaning $note=trim($note); if (! $note) { @@ -1733,7 +1733,7 @@ class Societe extends CommonObject $now=dol_now(); - // Positionne remise courante + // Position current discount $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; $sql.= " SET remise_supplier = '".$this->db->escape($remise)."'"; $sql.= " WHERE rowid = " . $this->id; @@ -1745,7 +1745,7 @@ class Societe extends CommonObject return -1; } - // Ecrit trace dans historique des remises + // Writes trace in discount history $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_supplier"; $sql.= " (entity, datec, fk_soc, remise_supplier, note, fk_user_author)"; $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; @@ -1829,10 +1829,10 @@ class Societe extends CommonObject } /** - * Renvoie montant TTC des reductions/avoirs en cours disponibles de la societe + * Returns amount of included taxes of the current discounts/credits available from the company * - * @param User $user Filtre sur un user auteur des remises - * @param string $filter Filtre autre + * @param User $user Filter on a user author of discounts + * @param string $filter Other filter * @param integer $maxvalue Filter on max value for discount * @param int $discount_type 0 => customer discount, 1 => supplier discount * @return int <0 if KO, Credit note amount otherwise @@ -2266,56 +2266,33 @@ class Societe extends CommonObject return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $statut Id statut + * @param int $status Status id * @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 Libelle du statut + * @return string Status label */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; $langs->load('companies'); - if ($mode == 0) + $statusType = 'status4'; + if ($status == 0) $statusType = 'status5'; + + if (empty($this->labelstatus) || empty($this->labelstatusshort)) { - if ($statut==0) return $langs->trans("ActivityCeased"); - elseif ($statut==1) return $langs->trans("InActivity"); + $this->labelstatus[0] = $langs->trans("ActivityCeased"); + $this->labelstatus[1] = $langs->trans("InActivity"); + $this->labelstatusshort[0] = $langs->trans("ActivityCeased"); + $this->labelstatusshort[1] = $langs->trans("InActivity"); } - elseif ($mode == 1) - { - if ($statut==0) return $langs->trans("ActivityCeased"); - elseif ($statut==1) return $langs->trans("InActivity"); - } - elseif ($mode == 2) - { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - elseif ($statut==1) return img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); - } - elseif ($mode == 3) - { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"'); - elseif ($statut==1) return img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"'); - } - elseif ($mode == 4) - { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - elseif ($statut==1) return img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); - } - elseif ($mode == 5) - { - if ($statut==0) return ''.$langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"'); - elseif ($statut==1) return ''.$langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"'); - } - elseif ($mode == 6) - { - if ($statut==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"'); - elseif ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"'); - } - } + + return dolGetStatus($this->labelstatus[$status], $this->labelstatusshort[$status], '', $statusType, $mode); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** @@ -2431,11 +2408,11 @@ class Societe extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoie la liste des contacts de cette societe + * Returns the contact list of this company * - * @return array tableau des contacts + * @return array array of contacts */ public function contact_array() { @@ -2465,11 +2442,11 @@ class Societe extends CommonObject return $contacts; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoie la liste des contacts de cette societe + * Returns the contact list of this company * - * @return array $contacts tableau des contacts + * @return array $contacts array of contacts */ public function contact_array_objects() { @@ -2610,9 +2587,9 @@ class Societe extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Attribut un code client a partir du module de controle des codes. + * Assigns a customer code from the code control module. * Return value is stored into this->code_client * * @param Societe $objsoc Object thirdparty @@ -2642,9 +2619,9 @@ class Societe extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Attribut un code fournisseur a partir du module de controle des codes. + * Assigns a vendor code from the code control module. * Return value is stored into this->code_fournisseur * * @param Societe $objsoc Object thirdparty @@ -2673,10 +2650,10 @@ class Societe extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Verifie si un code client est modifiable en fonction des parametres - * du module de controle des codes. + * Check if a client code is editable based on the parameters of the + * code control module. * * @return int 0=No, 1=Yes */ @@ -2710,9 +2687,9 @@ class Societe extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Verifie si un code fournisseur est modifiable dans configuration du module de controle des codes + * Check if a vendor code is editable in the code control module configuration * * @return int 0=No, 1=Yes */ @@ -2820,11 +2797,11 @@ class Societe extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoie un code compta, suivant le module de code compta. - * Peut etre identique a celui saisit ou genere automatiquement. - * A ce jour seule la generation automatique est implementee + * Returns an accounting code, following the accounting code module. + * May be identical to the one entered or generated automatically. + * To date only the automatic generation is implemented * * @param string $type Type of thirdparty ('customer' or 'supplier') * @return string Code compta si ok, 0 si aucun, <0 si ko @@ -2849,7 +2826,7 @@ class Societe extends CommonObject $classname = $conf->global->SOCIETE_CODECOMPTA_ADDON; $mod = new $classname; - // Defini code compta dans $mod->code + // Set code count in $mod->code $result = $mod->get_code($this->db, $this, $type); if ($type == 'customer') $this->code_compta = $mod->code; @@ -3001,9 +2978,9 @@ class Societe extends CommonObject else return false; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Verifie la validite d'un identifiant professionnel en fonction du pays de la societe (siren, siret, ...) + * Check the validity of a professional identifier according to the country of the company (siren, siret, ...) * * @param int $idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm) * @param Societe $soc Objet societe @@ -3019,7 +2996,7 @@ class Societe extends CommonObject if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return 1; - // Verifie SIREN si pays FR + // Check SIREN if country FR if ($idprof == 1 && $soc->country_code == 'FR') { $chaine=trim($this->idprof1); @@ -3209,11 +3186,11 @@ class Societe extends CommonObject return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Indique si la societe a des projets + * Indicates if the company has projects * - * @return bool true si la societe a des projets, false sinon + * @return bool true if the company has projects, false otherwise */ public function has_projects() { @@ -3315,9 +3292,9 @@ class Societe extends CommonObject return isInEEC($this); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Charge la liste des categories fournisseurs + * Load the list of provider categories * * @return int 0 if success, <> 0 if error */ @@ -3705,11 +3682,11 @@ class Societe extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set prospect level * - * @param User $user Utilisateur qui definie la remise + * @param User $user User who sets the discount * @return int <0 if KO, >0 if OK * @deprecated Use update function instead */ @@ -3735,12 +3712,12 @@ class Societe extends CommonObject /** * Return label of a given status * - * @param int|string $statut Id or code for prospection status + * @param int|string $status Id or code for prospection status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @param string $label Label to use for status for added status * @return string Libelle du statut */ - public function LibProspCommStatut($statut, $mode = 0, $label = '') + public function LibProspCommStatut($status, $mode = 0, $label = '') { // phpcs:enable global $langs; @@ -3748,38 +3725,38 @@ class Societe extends CommonObject if ($mode == 2) { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); + if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1"); + elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); + elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); + elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); + elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); else { - return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); + return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0).' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label); } } if ($mode == 3) { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3); + if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1); + elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0); + elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1); + elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2); + elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3); else { - return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0); + return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0); } } if ($mode == 4) { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); + if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1"); + elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); + elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); + elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); + elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); else { - return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); + return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0).' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label); } } @@ -3976,19 +3953,19 @@ class Societe extends CommonObject /** * Return the label of the customer/prospect status * - * @param int $statut Id statut + * @param int $status Id statut * @return string Libelle du statut */ - public function LibCustProspStatut($statut) + public function LibCustProspStatut($status) { // phpcs:enable global $langs; $langs->load('companies'); - if ($statut==0) return $langs->trans("NorProspectNorCustomer"); - elseif ($statut==1) return $langs->trans("Customer"); - elseif ($statut==2) return $langs->trans("Prospect"); - elseif ($statut==3) return $langs->trans("ProspectCustomer"); + if ($status==0) return $langs->trans("NorProspectNorCustomer"); + elseif ($status==1) return $langs->trans("Customer"); + elseif ($status==2) return $langs->trans("Prospect"); + elseif ($status==3) return $langs->trans("ProspectCustomer"); } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 7420c417aae..c6373674e4c 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -210,15 +210,16 @@ $arrayfields=array( 's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } - -$object = new Societe($db); +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* @@ -1278,7 +1279,7 @@ while ($i < min($num, $limit)) // Status if (! empty($arrayfields['s.status']['checked'])) { - print ''; + print ''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.import_key']['checked'])) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index bee290878c1..e4e0eb0b11c 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2188,44 +2188,39 @@ class SupplierProposal extends CommonObject /** * Return label of a status (draft, validated, ...) * - * @param int $statut id statut - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @param int $status Id status + * @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 */ - public function LibStatut($statut, $mode = 1) + public function LibStatut($status, $mode = 1) { // phpcs:enable - // Init/load array of translation of status - if (empty($this->labelstatut) || empty($this->labelstatut_short)) - { - global $langs; - $langs->load("supplier_proposal"); - $this->labelstatut[0]=$langs->trans("SupplierProposalStatusDraft"); - $this->labelstatut[1]=$langs->trans("SupplierProposalStatusValidated"); - $this->labelstatut[2]=$langs->trans("SupplierProposalStatusSigned"); - $this->labelstatut[3]=$langs->trans("SupplierProposalStatusNotSigned"); - $this->labelstatut[4]=$langs->trans("SupplierProposalStatusClosed"); - $this->labelstatut_short[0]=$langs->trans("SupplierProposalStatusDraftShort"); - $this->labelstatut_short[1]=$langs->trans("Opened"); - $this->labelstatut_short[2]=$langs->trans("SupplierProposalStatusSignedShort"); - $this->labelstatut_short[3]=$langs->trans("SupplierProposalStatusNotSignedShort"); - $this->labelstatut_short[4]=$langs->trans("SupplierProposalStatusClosedShort"); - } - $statuttrans=''; - if ($statut==0) $statuttrans='statut0'; - elseif ($statut==1) $statuttrans='statut1'; - elseif ($statut==2) $statuttrans='statut3'; - elseif ($statut==3) $statuttrans='statut5'; - elseif ($statut==4) $statuttrans='statut6'; + // Init/load array of translation of status + if (empty($this->labelstatut) || empty($this->labelstatut_short)) + { + global $langs; + $langs->load("supplier_proposal"); + $this->labelstatut[self::STATUS_DRAFT]=$langs->trans("SupplierProposalStatusDraft"); + $this->labelstatut[self::STATUS_VALIDATED]=$langs->trans("SupplierProposalStatusValidated"); + $this->labelstatut[self::STATUS_SIGNED]=$langs->trans("SupplierProposalStatusSigned"); + $this->labelstatut[self::STATUS_NOTSIGNED]=$langs->trans("SupplierProposalStatusNotSigned"); + $this->labelstatut[self::STATUS_CLOSE]=$langs->trans("SupplierProposalStatusClosed"); + $this->labelstatut_short[self::STATUS_DRAFT]=$langs->trans("SupplierProposalStatusDraftShort"); + $this->labelstatut_short[self::STATUS_VALIDATED]=$langs->trans("Opened"); + $this->labelstatut_short[self::STATUS_SIGNED]=$langs->trans("SupplierProposalStatusSignedShort"); + $this->labelstatut_short[self::STATUS_NOTSIGNED]=$langs->trans("SupplierProposalStatusNotSignedShort"); + $this->labelstatut_short[self::STATUS_CLOSE]=$langs->trans("SupplierProposalStatusClosedShort"); + } - if ($mode == 0) return $this->labelstatut[$statut]; - elseif ($mode == 1) return $this->labelstatut_short[$statut]; - elseif ($mode == 2) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut_short[$statut]; - elseif ($mode == 3) return img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 4) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut[$statut]; - elseif ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); + $statusnew=''; + if ($status==self::STATUS_DRAFT) $statusnew='status0'; + elseif ($status==self::STATUS_VALIDATED) $statusnew='status1'; + elseif ($status==self::STATUS_SIGNED) $statusnew='status3'; + elseif ($status==self::STATUS_NOTSIGNED) $statusnew='status5'; + elseif ($status==self::STATUS_CLOSE) $statusnew='status6'; + + return dolGetStatus($this->labelstatut[$status], $this->labelstatut_short[$status], '', $statusnew, $mode); } diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index 92333394edc..ffa4bd6d13b 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -41,12 +41,12 @@ $langs->loadLangs(array("admin", "cashdesk", "commercial")); if (GETPOST('action', 'alpha') == 'set') { $db->begin(); - + $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_RECEIPT_NAME", GETPOST('TAKEPOS_RECEIPT_NAME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_SHOW_CUSTOMER", GETPOST('TAKEPOS_SHOW_CUSTOMER', 'alpha'), 'chaine', 0, '', $conf->entity); - + dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); if (! $res > 0) $error++; diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 69228b5efb5..2a27094bb90 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -45,9 +45,18 @@ $term = GETPOST('term', 'alpha'); if ($action=="getProducts") { $object = new Categorie($db); $result=$object->fetch($category); - if ($result) + if ($result > 0) { $prods = $object->getObjectsInCateg("product"); + // Removed properties we don't need + if (is_array($prods) && count($prods) > 0) + { + foreach($prods as $prod) + { + unset($prod->fields); + unset($prod->db); + } + } echo json_encode($prods); } else diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 6a67d9d03f9..2fcb9e0a6d8 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -165,8 +165,12 @@ if ($action == 'valid' && $user->rights->facture->creer) $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; if ($invoice->statut != Facture::STATUS_DRAFT) { - dol_syslog("Sale already validated"); - dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); + //If invoice is validated but it is not fully paid is not error and make the payment + if ($invoice->getRemainToPay()>0) $res=1; + else{ + dol_syslog("Sale already validated"); + dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); + } } elseif (count($invoice->lines)==0) { @@ -199,7 +203,7 @@ if ($action == 'valid' && $user->rights->facture->creer) $payment->amounts[$invoice->id] = $amountofpayment; // If user has not used change control, add total invoice payment - if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $invoice->total_ttc; + if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $remaintopay; $payment->paiementid=$paiementid; $payment->num_payment=$invoice->ref; @@ -427,7 +431,6 @@ $sectionwithinvoicelink=''; if ($action=="valid" || $action=="history") { $sectionwithinvoicelink.=''."\n"; - $sectionwithinvoicelink.=''; $sectionwithinvoicelink.=''; $sectionwithinvoicelink.=$invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - "; $remaintopay = $invoice->getRemainToPay(); @@ -582,7 +585,7 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) if ($mobilepage=="invoice" || $mobilepage=="") { print $langs->trans('TotalTTC'); print ' : ' . price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency) . ''; - print '
' . $sectionwithinvoicelink; + print '
' . $sectionwithinvoicelink; print ''; } if ($_SESSION["basiclayout"]!=1) diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 63bf151f40a..349c03540b2 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -172,9 +172,8 @@ else print "var received=0;"; } console.log("We click on the payment mode to pay amount = "+amountpayed); parent.$("#poslines").load("invoice.php?place=&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid, function() { - //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight); - parent.$.colorbox.close(); - //parent.setFocusOnSearchField(); // This does not have effect + if (amountpayed > || amountpayed == || amountpayed==0 ) parent.$.colorbox.close(); + else location.reload(); }); } diff --git a/htdocs/theme/eldy/badges.inc.php b/htdocs/theme/eldy/badges.inc.php index 0f635941a8e..975f2eb311f 100644 --- a/htdocs/theme/eldy/badges.inc.php +++ b/htdocs/theme/eldy/badges.inc.php @@ -22,6 +22,11 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> box-sizing: border-box; } +.badge-status { + font-size: 1em; + padding: .19em .35em; /* more than 0.19 generate a change into heigth of lines */ +} + .badge-pill, .tabs .badge { padding-right: .5em; padding-left: .5em; @@ -31,7 +36,7 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> .badge-dot { padding: 0; border-radius: 50%; - padding: 0.25rem; + padding: 0.45em; vertical-align: middle; } @@ -168,10 +173,12 @@ a.badge-dark:focus, a.badge-dark:hover { background-color: ; } + /* -* STATUS BADGES -*/ -span.fa-plus-circle, .tableforfieldcreate a.butActionNew>span.fa-plus-circle:hover, +.tableforfieldedit a.butActionNew>span.fa-plus-circle, .tableforfieldedit a.butActionNew>span.fa-plus-circle:hover, span.butActionNew>span.fa-plus-circle, span.butActionNew>span.fa-plus-circle:hover, a.butActionNewRefused>span.fa-plus-circle, a.butActionNewRefused>span.fa-plus-circle:hover, span.butActionNewRefused>span.fa-plus-circle, span.butActionNewRefused>span.fa-plus-circle:hover, diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index d93118b0b46..09e89c98b71 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -273,15 +273,14 @@ input:-webkit-autofill { } ::-webkit-input-placeholder { color:#ccc; } input:-moz-placeholder { color:#ccc; } -input[name=price], input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], select[name=incoterm_id] { margin-right: 6px; } -input[name=surface] { margin-right: 4px; } +input[name=price], input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], input[name=net_measure], select[name=incoterm_id] { margin-right: 6px; } fieldset { border: 1px solid #AAAAAA !important; } .legendforfieldsetstep { padding-bottom: 10px; } input#onlinepaymenturl, input#directdownloadlink { opacity: 0.7; } -div#moretabsListaction { +div#moretabsList, div#moretabsListaction { z-index: 5; } @@ -511,10 +510,10 @@ body[class*="colorblind-"] .text-success{ color : } -.editfielda span.fa-pencil-alt { +.editfielda span.fa-pencil-alt, .editfielda span.fa-trash { color: #ccc !important; } -.editfielda span.fa-pencil-alt:hover { +.editfielda span.fa-pencil-alt:hover, .editfielda span.fa-trash:hover { color: rgb() !important; } @@ -5789,7 +5788,7 @@ div.tabsElem a.tab { } .dropdown dd ul { - max-width: 300px; + max-width: 350px; } } /* rule to reduce top menu - 2nd reduction: Reduce width of top menu icons again */ @@ -5818,6 +5817,10 @@ div.tabsElem a.tab { margin-top: 2px; left: 4px; } + + .dropdown dd ul { + max-width: 300px; + } } /* rule to reduce top menu - 3rd reduction: The menu for user is on left */ @media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3) ? round($nbtopmenuentries * 47, 0) + 130 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3; ?>px) /* reduction 3 */ diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index a483b3d758d..2ceaa70911a 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -149,46 +149,56 @@ a.info-box-text{ text-decoration: none;} /* ICONS INFO BOX */ -.info-box-icon { - color: #fff !important; -} - global->THEME_AGRESSIVITY_RATIO='.$conf->global->THEME_AGRESSIVITY_RATIO.' */'."\n"; -if (! isset($conf->global->THEME_AGRESSIVITY_RATIO)) $conf->global->THEME_AGRESSIVITY_RATIO=-40; -if (GETPOSTISSET('THEME_AGRESSIVITY_RATIO')) $conf->global->THEME_AGRESSIVITY_RATIO=GETPOST('THEME_AGRESSIVITY_RATIO', 'int'); + +$prefix=''; +$prefix = 'background-'; +if (! empty($conf->global->THEME_INFOBOX_COLOR_ON_BACKGROUND)) $prefix = 'background-'; + +if (! isset($conf->global->THEME_AGRESSIVENESS_RATIO) && $prefix) $conf->global->THEME_AGRESSIVENESS_RATIO=-50; +if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) $conf->global->THEME_AGRESSIVENESS_RATIO=GETPOST('THEME_AGRESSIVENESS_RATIO', 'int'); +//var_dump($conf->global->THEME_AGRESSIVENESS_RATIO); ?> +.info-box-icon { + + color: #fff !important; + + background-color: #eee !important; + + opacity: 0.95; +} + .bg-infoxbox-project{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-action{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-propal, .bg-infoxbox-facture, .bg-infoxbox-commande{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-supplier_proposal, .bg-infoxbox-invoice_supplier, .bg-infoxbox-order_supplier{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-contrat{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-bank_account{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-adherent{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-expensereport{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-holiday{ - background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 086b7f942e6..ed1ca8a9279 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -236,7 +236,7 @@ print 'fontsizesmaller='.$fontsizesmaller."\n"; print 'topMenuFontSize='.$topMenuFontSize."\n"; print 'toolTipBgColor='.$toolTipBgColor."\n"; print 'toolTipFontColor='.$toolTipFontColor."\n"; -print 'conf->global->THEME_AGRESSIVITY_RATIO='.$conf->global->THEME_AGRESSIVITY_RATIO." (must be between -100 and +100)\n"; +print 'conf->global->THEME_AGRESSIVENESS_RATIO='.$conf->global->THEME_AGRESSIVENESS_RATIO." (must be between -100 and +100)\n"; print '*/'."\n"; diff --git a/htdocs/theme/md/badges.inc.php b/htdocs/theme/md/badges.inc.php index ac6eb9de53c..2a1b9ffd24b 100644 --- a/htdocs/theme/md/badges.inc.php +++ b/htdocs/theme/md/badges.inc.php @@ -21,7 +21,11 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> border-color: rgba(255,255,255,0); box-sizing: border-box; } -/* Themes for badges */ + +.badge-status { + font-size: 1em; + padding: .19em .35em; /* more than 0.19 generate a change into heigth of lines */ +} .badge-pill, .tabs .badge { padding-right: .5em; @@ -158,46 +162,74 @@ a.badge-dark:focus, a.badge-dark:hover { background-color: ; } + /* -* STATUS BADGES -*/ - -/* Default Status */ - + * STATUS BADGES + */ span.fa-plus-circle { padding-left: 6px; font-size: 1.5em; } a.butActionNewRefused>span.fa-plus-circle { padding-left: 6px; font-size: 1.5em; } .tableforfieldcreate a.butActionNew>span.fa-plus-circle, .tableforfieldcreate a.butActionNew>span.fa-plus-circle:hover, +.tableforfieldedit a.butActionNew>span.fa-plus-circle, .tableforfieldedit a.butActionNew>span.fa-plus-circle:hover, span.butActionNew>span.fa-plus-circle, span.butActionNew>span.fa-plus-circle:hover, a.butActionNewRefused>span.fa-plus-circle, a.butActionNewRefused>span.fa-plus-circle:hover, span.butActionNewRefused>span.fa-plus-circle, span.butActionNewRefused>span.fa-plus-circle:hover, diff --git a/htdocs/theme/md/info-box.inc.php b/htdocs/theme/md/info-box.inc.php index 95e057e68f1..8effe7d62d6 100644 --- a/htdocs/theme/md/info-box.inc.php +++ b/htdocs/theme/md/info-box.inc.php @@ -104,39 +104,39 @@ a.info-box-text{ text-decoration: none;} } global->THEME_AGRESSIVITY_RATIO)) $conf->global->THEME_AGRESSIVITY_RATIO=-100; -if (GETPOSTISSET('THEME_AGRESSIVITY_RATIO')) $conf->global->THEME_AGRESSIVITY_RATIO=GETPOST('THEME_AGRESSIVITY_RATIO', 'int'); +if (! isset($conf->global->THEME_AGRESSIVENESS_RATIO)) $conf->global->THEME_AGRESSIVENESS_RATIO=-100; +if (GETPOSTISSET('THEME_AGRESSIVENESS_RATIO')) $conf->global->THEME_AGRESSIVENESS_RATIO=GETPOST('THEME_AGRESSIVENESS_RATIO', 'int'); ?> .bg-infoxbox-project i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-action i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-propal i.fa, .bg-infoxbox-facture i.fa, .bg-infoxbox-commande i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-supplier_proposal i.fa, .bg-infoxbox-invoice_supplier i.fa, .bg-infoxbox-order_supplier i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-contrat i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-bank_account i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-adherent i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-expensereport i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } .bg-infoxbox-holiday i.fa{ - color: global->THEME_AGRESSIVITY_RATIO); ?> !important; + color: global->THEME_AGRESSIVENESS_RATIO); ?> !important; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 097f6e1e5c6..46e1993c1b6 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -500,15 +500,14 @@ input:-webkit-autofill { ::-moz-placeholder { color:#bbb; } /* firefox 19+ */ :-ms-input-placeholder { color:#ccc; } /* ie */ input:-moz-placeholder { color:#ccc; } -input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], select[name=incoterm_id] { margin-right: 6px; } -input[name=surface] { margin-right: 4px; } +input[name=price], input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], input[name=net_measure], select[name=incoterm_id] { margin-right: 6px; } fieldset { border: 1px solid #AAAAAA !important; } .legendforfieldsetstep { padding-bottom: 10px; } input#onlinepaymenturl, input#directdownloadlink { opacity: 0.7; } -div#moretabsListaction { +div#moretabsList, div#moretabsListaction { z-index: 5; } @@ -1507,7 +1506,8 @@ table.noborder tr.liste_titre td { padding-: 3px; } .pictowarning { - vertical-align: text-bottom; + /* vertical-align: text-bottom; */ + color: #9f4705; } .pictomodule { width: 14px; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index d5a3afda413..1e0a15bac06 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1041,7 +1041,7 @@ if ($action == 'create' || $action == 'adduserldap') } // Tel - print ''; + print ''; print ''; // Tel portable - print ''; + print ''; print ''; // Fax - print ''; + print ''; print ''; + // EMail + print 'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.img_picto('', 'object_email').' '.$langs->trans("EMail").''; + print ''; + if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { @@ -1172,20 +1186,6 @@ if ($action == 'create' || $action == 'adduserldap') // print ''; // } - // EMail - print 'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; - print ''; - // Accountancy code if ($conf->accounting->enabled) { @@ -2409,7 +2409,7 @@ else } // Tel pro - print "".''; + print "".''; print ''; // Tel mobile - print "".''; + print "".''; print ''; // Fax - print "".''; + print "".''; print ''; + // EMail + print "".'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.img_picto('', 'object_email').' '.$langs->trans("EMail").''; + print ''; + if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { @@ -2537,20 +2551,6 @@ else // print ''; // } - // EMail - print "".'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; - print ''; - // OpenID url if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) { diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 5520465a75d..95b9529017c 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -108,13 +108,16 @@ $arrayfields=array( 'u.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); // Init search fields $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 080242d3137..e5f1d17b8aa 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -350,7 +350,7 @@ if (! empty($id) || ! empty($ref)) print ' - isProduct()) print ''; ?> + isProduct()) print ''; ?>
 '; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/', '', $key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } - print ''; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ''.$companystatic->getLibStatut(3).''.$companystatic->getLibStatut(5).'
'.$langs->trans("PhonePro").'
'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").''; if (! empty($ldap_phone)) { @@ -1055,7 +1055,7 @@ if ($action == 'create' || $action == 'adduserldap') print '
'.$langs->trans("PhoneMobile").'
'.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").''; if (! empty($ldap_mobile)) { @@ -1069,7 +1069,7 @@ if ($action == 'create' || $action == 'adduserldap') print '
'.$langs->trans("Fax").'
'.img_picto('', 'object_phoning_fax').' '.$langs->trans("Fax").''; if (! empty($ldap_fax)) { @@ -1082,6 +1082,20 @@ if ($action == 'create' || $action == 'adduserldap') } print '
'; + if (! empty($ldap_mail)) + { + print ''; + print $ldap_mail; + } + else + { + print ''; + } + print '
'; - if (! empty($ldap_mail)) - { - print ''; - print $ldap_mail; - } - else - { - print ''; - } - print '
'.$langs->trans("PhonePro").'
'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").''; if ($caneditfield && empty($object->ldap_sid)) { @@ -2423,7 +2423,7 @@ else print '
'.$langs->trans("PhoneMobile").'
'.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").''; if ($caneditfield && empty($object->ldap_sid)) { @@ -2437,7 +2437,7 @@ else print '
'.$langs->trans("Fax").'
'.img_picto('', 'object_phoning_fax').' '.$langs->trans("Fax").''; if ($caneditfield && empty($object->ldap_sid)) { @@ -2450,6 +2450,20 @@ else } print '
'; + if ($caneditfield && empty($object->ldap_sid)) + { + print ''; + } + else + { + print ''; + print $object->email; + } + print '
'; - if ($caneditfield && empty($object->ldap_sid)) - { - print ''; - } - else - { - print ''; - print $object->email; - } - print '
'.$langs->trans("Weight").''; if ($object->weight != '') { - print $object->weight." ".measuring_units_string($object->weight_units, "weight"); + print $object->weight." ".measuringUnitString(0, "weight", $object->weight_units); } else { @@ -776,7 +776,7 @@ if (! empty($id) || ! empty($ref)) } ?> variation_price >= 0 ? '+' : '').price($currcomb->variation_price).($currcomb->variation_price_percentage ? ' %' : '') ?>'.($currcomb->variation_weight >= 0 ? '+' : '').price($currcomb->variation_weight).' '.measuring_units_string($prodstatic->weight_units, 'weight').''.($currcomb->variation_weight >= 0 ? '+' : '').price($currcomb->variation_weight).' '.measuringUnitString(0, 'weight', $prodstatic->weight_units).'getLibStatut(2, 0) ?> getLibStatut(2, 1) ?> diff --git a/htdocs/variants/generator.php b/htdocs/variants/generator.php index 57b9963d9b4..6012ddd511c 100644 --- a/htdocs/variants/generator.php +++ b/htdocs/variants/generator.php @@ -179,7 +179,7 @@ if (! empty($id) || ! empty($ref)) {