diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c5128942830..1b516e1c94e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2063,9 +2063,10 @@ class Adherent extends CommonObject * @param string $mode ''=Show firstname+lastname as label (using default order), 'firstname'=Show only firstname, 'login'=Show login, 'ref'=Show ref * @param string $morecss Add more css on link * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option = 'card', $mode = '', $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option = 'card', $mode = '', $morecss = '', $save_lastsearch_value = -1, $notooltip = 0) { global $conf, $langs; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 455175220a8..40514cd1890 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -438,7 +438,6 @@ foreach ($dirmodels as $reldir) if ($modulequalified) { - $var = !$var; print ''; print (empty($module->name)?$name:$module->name); print "\n"; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index f1fbbd4b286..2dbc601c264 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin", "other", "orders")); +$langs->loadLangs(array("admin", "other", "orders", "stocks")); if (!$user->admin) accessforbidden(); @@ -561,25 +561,31 @@ print '' print "\n"; // Option to add a quality/validation step, on products, after reception. -$langs->load("stocks"); print ''; print ''.$langs->trans("UseDispatchStatus").''; print ''; print ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('SUPPLIER_ORDER_USE_DISPATCH_STATUS'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("SUPPLIER_ORDER_USE_DISPATCH_STATUS", $arrval, $conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS); +if ($conf->reception->enabled) +{ + print ''.$langs->trans("FeatureNotAvailableWithReceptionModule").''; } -print "\n\n"; +else +{ + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('SUPPLIER_ORDER_USE_DISPATCH_STATUS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("SUPPLIER_ORDER_USE_DISPATCH_STATUS", $arrval, $conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS); + } +} +print "\n"; +print "\n"; print '
'; print ''; - /* * Notifications */ diff --git a/htdocs/asset/info.php b/htdocs/asset/info.php index 462abf17342..45157e9b7a5 100644 --- a/htdocs/asset/info.php +++ b/htdocs/asset/info.php @@ -44,15 +44,18 @@ $object->fetch($id); * Actions */ + + /* * View */ + +$form = new Form($db); + $title = $langs->trans('Asset') . " - " . $langs->trans('Info'); $helpurl = ""; llxHeader('', $title, $helpurl); -$form = new Form($db); - $object->info($id); $head = asset_prepare_head($object); diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 54f289a5b23..89f3e337099 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -101,7 +101,7 @@ class Boms extends DolibarrApi $obj_ret = array(); $tmpobject = new BOM($db); - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $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/comm/action/card.php b/htdocs/comm/action/card.php index af54186e255..a9dd837fc8c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -147,7 +147,7 @@ if ($action == 'classin' && ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) { $object->fetch($id); - $object->setProject(GETPOST('projectid')); + $object->setProject(GETPOST('projectid', 'int')); } // Action clone object @@ -165,7 +165,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') reset($object->socpeopleassigned); $object->contactid = key($object->socpeopleassigned); } - $result = $object->createFromClone($user, GETPOST('fk_userowner'), GETPOST('socid')); + $result = $object->createFromClone($user, GETPOST('socid', 'int')); if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 9cc8bd32d26..15badcd75a3 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -103,7 +103,7 @@ class Proposals extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 440ea9e6984..56147545f36 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -107,7 +107,7 @@ class Orders extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 74a2243d633..c2fed2895a8 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -81,8 +81,8 @@ if (count($linkedObjectBlock) > 1) trans("Total"); ?> - - + + diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index d6b33acbda6..d558bf5ac7f 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -112,7 +112,7 @@ class Invoices extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 301f2f532b1..1276194b6c3 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -239,6 +239,23 @@ if ($id > 0 || $ref) dol_fiche_end(); + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Delete'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); + } + + // Call Hook formConfirm + /*$parameters = array(); + $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; + if (empty($object->date_trans) && $user->rights->prelevement->bons->send && $action=='settransmitted') { @@ -298,7 +315,7 @@ if ($id > 0 || $ref) print "id."\">".$langs->trans("ClassCredited").""; } - print "id."\">".$langs->trans("Delete").""; + print "id."\">".$langs->trans("Delete").""; print ""; } @@ -356,8 +373,6 @@ if ($id > 0 || $ref) print_liste_field_titre(''); print "\n"; - $var=false; - $total = 0; while ($i < min($num, $conf->liste_limit)) @@ -406,7 +421,10 @@ if ($id > 0 || $ref) print ''.$langs->trans("Total").''; print ' '; print ''; - if ($total != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); + if (empty($offset) && $num <= $limit) // If we have all record on same page, then the following test/warning can be done + { + if ($total != $object->amount) print img_warning("TotalAmountOfdirectDebitOrderDiffersFromSumOfLines"); + } print price($total); print "\n"; print ' '; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index a60330270d4..92ba7f621cb 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -739,14 +739,13 @@ class BonPrelevement extends CommonObject $sql = "SELECT count(f.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql.= " WHERE f.fk_statut = 1"; + $sql.= " WHERE f.fk_statut = ".Facture::STATUS_VALIDATED; $sql.= " AND f.entity IN (".getEntity('invoice').")"; $sql.= " AND f.rowid = pfd.fk_facture"; - $sql.= " AND f.paye = 0"; $sql.= " AND pfd.traite = 0"; $sql.= " AND f.total_ttc > 0"; - dol_syslog(get_class($this)."::SommeAPrelever"); + dol_syslog(get_class($this)."::NbFactureAPrelever"); $resql = $this->db->query($sql); if ( $resql ) @@ -759,7 +758,7 @@ class BonPrelevement extends CommonObject } else { - $this->error=get_class($this)."::SommeAPrelever Erreur -1 sql=".$this->db->error(); + $this->error=get_class($this)."::NbFactureAPrelever Erreur -1 sql=".$this->db->error(); return -1; } } @@ -798,8 +797,6 @@ class BonPrelevement extends CommonObject $month = strftime("%m", $datetimeprev); $year = strftime("%Y", $datetimeprev); - $puser = new User($this->db, $conf->global->PRELEVEMENT_USER); - $this->invoice_in_error = array(); $this->thirdparty_in_error = array(); @@ -1631,8 +1628,8 @@ class BonPrelevement extends CommonObject public static function buildRumNumber($row_code_client, $row_datec, $row_drum) { global $langs; - $pre = $langs->trans('RUM').'-'; - return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); + $pre = substr(dol_string_nospecial(dol_string_unaccent($langs->transnoentitiesnoconv('RUM'))), 0, 3); // Must always be on 3 char ('RUM' or 'UMR'. This is a protection against bad translation) + return $pre.'-'.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index eaef92a1abc..dce08c5c66b 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array('banks', 'categories', 'widthdrawals', 'companies', 'bills')); +$langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies', 'bills')); // Security check if ($user->societe_id) $socid=$user->societe_id; @@ -105,6 +105,7 @@ if (empty($reshook)) /* * View */ + $form = new Form($db); $thirdpartystatic=new Societe($db); @@ -207,9 +208,11 @@ $sql.= " ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql.= " WHERE s.rowid = f.fk_soc"; $sql.= " AND f.entity IN (".getEntity('invoice').")"; +$sql.= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; +$sql.= " AND f.total_ttc > 0"; $sql.= " AND pfd.traite = 0"; $sql.= " AND pfd.fk_facture = f.rowid"; -if ($socid) $sql.= " AND f.fk_soc = ".$socid; +if ($socid > 0) $sql.= " AND f.fk_soc = ".$socid; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -293,7 +296,7 @@ if ($resql) $i++; } } - else print ''.$langs->trans("None").''; + else print ''.$langs->trans("None").''; print ""; print ""; print "
\n"; diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 8f9df284291..a34fde042e5 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -35,31 +35,43 @@ $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); // Security check $socid = GETPOST('socid', 'int'); +$status = GETPOST('status', 'int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'prelevement', '', '', 'bons'); -// Get supervariables -$page = GETPOST('page', 'int'); -$sortorder = GETPOST('sortorder', 'alpha'); -$sortfield = GETPOST('sortfield', 'alpha'); +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +// Load variable for pagination $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="f.ref"; +$massactionbutton = ''; + /* * View */ -llxHeader(); +if (!$status) +{ + $title = $langs->trans("RequestStandingOrderToTreat"); +} +else +{ + $title = $langs->trans("RequestStandingOrderTreated"); +} + +llxHeader('', $title); $thirdpartystatic=new Societe($db); $invoicestatic=new Facture($db); @@ -78,95 +90,126 @@ $sql.= " WHERE s.rowid = f.fk_soc"; $sql.= " AND f.entity IN (".getEntity('invoice').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND f.fk_soc = ".$socid; -if (!$statut) $sql.= " AND pfd.traite = 0"; -if ($statut) $sql.= " AND pfd.traite = ".$statut; +if (!$status) $sql.= " AND pfd.traite = 0"; +if ($status) $sql.= " AND pfd.traite = ".$status; +$sql.= " AND f.total_ttc > 0"; +$sql.= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; $sql.= " AND pfd.fk_facture = f.rowid"; if (dol_strlen(trim(GETPOST('search_societe', 'alpha')))) { $sql.= natural_search("s.nom", 'search_societe'); } -$sql.= " ORDER BY $sortfield $sortorder "; -$sql.= $db->plimit($limit+1, $offset); +$sql.=$db->order($sortfield, $sortorder); -$resql=$db->query($sql); -if ($resql) + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $num = $db->num_rows($resql); - $i = 0; - - if (!$statut) + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 { - print_barre_liste($langs->trans("RequestStandingOrderToTreat"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num); + $page = 0; + $offset = 0; } - else - { - print_barre_liste($langs->trans("RequestStandingOrderTreated"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num); - } - - print '
'; - - print ''; - - print ''; - print_liste_field_titre("Bill", $_SERVER["PHP_SELF"]); - print_liste_field_titre("Company", $_SERVER["PHP_SELF"]); - print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "", "", $param, 'class="right"'); - print_liste_field_titre("DateRequest", $_SERVER["PHP_SELF"], "", "", $param, 'class="center"'); - print_liste_field_titre(''); - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - // Action column - print ''; - print ''; - - $users = array(); - - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($resql); - - print ''; - - // Ref facture - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - $i++; - } - - print "
'; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); - print $searchpicto; - print '
'; - $invoicestatic->id=$obj->rowid; - $invoicestatic->ref=$obj->ref; - print $invoicestatic->getNomUrl(1, 'withdraw'); - print ''; - $thirdpartystatic->id=$obj->socid; - $thirdpartystatic->name=$obj->name; - print $thirdpartystatic->getNomUrl(1, 'customer'); - print ''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->date_demande), 'day').'

"; - - print '
'; +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +{ + $num = $nbtotalofrecords; } else { - dol_print_error($db); + $sql.= $db->plimit($limit+1, $offset); + + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); } + + +$newcardbutton = ''.$langs->trans("Back").''; + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic', 0, $newcardbutton, '', $limit); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + + +print ''; + +print ''; +print_liste_field_titre("Bill", $_SERVER["PHP_SELF"]); +print_liste_field_titre("Company", $_SERVER["PHP_SELF"]); +print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "", "", $param, 'class="right"'); +print_liste_field_titre("DateRequest", $_SERVER["PHP_SELF"], "", "", $param, 'class="center"'); +print_liste_field_titre(''); +print ''; + +print ''; +print ''; +print ''; +print ''; +print ''; +// Action column +print ''; +print ''; + +$users = array(); + +$i = 0; +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + print ''; + + // Ref facture + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + $i++; +} + +print "
'; +$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); +print $searchpicto; +print '
'; + $invoicestatic->id=$obj->rowid; + $invoicestatic->ref=$obj->ref; + print $invoicestatic->getNomUrl(1, 'withdraw'); + print ''; + $thirdpartystatic->id=$obj->socid; + $thirdpartystatic->name=$obj->name; + print $thirdpartystatic->getNomUrl(1, 'customer'); + print ''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->date_demande), 'day').'

"; + +print '
'; + + // End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 1be716f8f61..44db7dd2625 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -71,6 +71,7 @@ $thirdpartystatic=new Societe($db); $invoicestatic=new Facture($db); $bprev = new BonPrelevement($db); + print ''; print ''; @@ -100,6 +101,8 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX $sql.= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql.= " WHERE s.rowid = f.fk_soc"; $sql.= " AND f.entity IN (".getEntity('invoice').")"; +$sql.= " AND f.total_ttc > 0"; +$sql.= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; $sql.= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND f.fk_soc = ".$socid; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 86dda559061..c17724e2de5 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -184,7 +184,7 @@ class PaymentSocialContribution extends CommonObject $remaintopay=price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); if ($remaintopay == 0) { - $result=$contrib->set_paid($user, '', ''); + $result=$contrib->set_paid($user); } else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing."); } diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 4d26fef7965..84fc87d35f8 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -152,7 +152,9 @@ $dolibarr_main_db_collation='utf8_unicode_ci'; // dolibarr_main_instance_unique_id -// An ID that is unique for each installation. +// An secret ID that is unique for each installation. +// This value is also visible and never propagated outside of Dolibarr, so it can be used as a salt / key for some encryption. +// To propagate a unique key, you propagate the value concatenated with a string with a hash function. Example: md5('dolibarr'+dolibarr_main_instance_unique_id) // Default value: randomly defined during installation // Examples: // $dolibarr_main_instance_unique_id='84b5bc91f83b56e458db71e0adac2b62'; diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 4735f840582..194e145210f 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -108,7 +108,7 @@ class Contracts extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index eabe0440dca..43ad52b5f47 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -428,7 +428,7 @@ class CMailFile foreach ($this->images_encoded as $img) { //$img['fullpath'],$img['image_encoded'],$img['name'],$img['content_type'],$img['cid'] - $attachment = Swift_Image::fromPath($img['fullpath'], $img['content_type']); + $attachment = Swift_Image::fromPath($img['fullpath']); // embed image $imgcid = $this->message->embed($attachment); // replace cid by the one created by swiftmail in html message diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1a1b5c597ce..f71e0c93739 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4587,10 +4587,15 @@ abstract class CommonObject */ protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams = null) { - global $conf, $langs, $user; + global $conf, $langs, $user, $hookmanager; $srctemplatepath=''; + $parameters = array('modelspath'=>$modelspath,'modele'=>$modele,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'hidedesc'=>$hidedesc,'hideref'=>$hideref, 'moreparams'=>$moreparams); + $reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + if(empty($reshook)) + { dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null')); // Increase limit for PDF build @@ -4835,6 +4840,8 @@ abstract class CommonObject dol_print_error('', $this->error); return -1; } + } + else return $reshook; } /** @@ -6608,9 +6615,12 @@ abstract class CommonObject } else { - $csstyle=''; $class=(!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : ''); + $csstyle=''; if (is_array($params) && count($params)>0) { + if (array_key_exists('class', $params)) { + $class.=$params['class'].' '; + } if (array_key_exists('style', $params)) { $csstyle=$params['style']; } @@ -6647,16 +6657,19 @@ abstract class CommonObject $labeltoshow = $langs->trans($label); - $out .= ''; $html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : ''; + $out .=''; + /*for($ii = 0; $ii < ($colspan - 1); $ii++) + { + $out .=''; + }*/ + if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= ''; else $out .= ''; $e++; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 3c03f9ea14c..b85056fe5e8 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -552,9 +552,6 @@ class Conf if (! isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES=1; // use dash between lines if (! isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT=1; // allow html content into free footer text - // Set default value to MAIN_SHOW_LOGO - if (! isset($this->global->MAIN_SHOW_LOGO)) $this->global->MAIN_SHOW_LOGO=1; - // Default max file size for upload $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index c92ae311141..0a9f98b4afd 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -274,9 +274,10 @@ class ExtraFields * @param string $perms Permission * @param string $list Into list view by default * @param string $computed Computed value + * @param string $help Help on tooltip * @return int <=0 if KO, >0 if OK */ - private function create($attrname, $type = 'varchar', $length = 255, $elementtype = 'member', $unique = 0, $required = 0, $default_value = '', $param = '', $perms = '', $list = '0', $computed = '') + private function create($attrname, $type = 'varchar', $length = 255, $elementtype = 'member', $unique = 0, $required = 0, $default_value = '', $param = '', $perms = '', $list = '0', $computed = '', $help = '') { if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'contact') $elementtype='socpeople'; diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 5593b4a90a4..90d824b7263 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -63,28 +63,28 @@ class Fiscalyear extends CommonObject * @var string fiscal year label */ public $label; - + /** * Date start (date_start) * * @var integer */ public $date_start; - + /** * Date end (date_end) * * @var integer */ public $date_end; - + /** * Date creation record (datec) * * @var integer */ public $datec; - + public $statut; // 0=open, 1=closed /** diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index f6a9208cadf..396991b6612 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -3058,7 +3058,7 @@ class lessc_parser { $content[] = $m[1]; if ($m[2] == "@{") { $this->count -= strlen($m[2]); - if ($this->interpolation($inter, false)) { + if ($this->interpolation($inter)) { $content[] = $inter; } else { $this->count += strlen($m[2]); @@ -3310,7 +3310,7 @@ class lessc_parser { continue; } - if ($this->interpolation($inter, false)) { + if ($this->interpolation($inter)) { $attrParts[] = $inter; $hasInterpolation = true; continue; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 0c72fe35fab..3bbedb91076 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1023,22 +1023,16 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable { case UPLOAD_ERR_INI_SIZE: // 1 return 'ErrorFileSizeTooLarge'; - break; case UPLOAD_ERR_FORM_SIZE: // 2 return 'ErrorFileSizeTooLarge'; - break; case UPLOAD_ERR_PARTIAL: // 3 return 'ErrorPartialFile'; - break; case UPLOAD_ERR_NO_TMP_DIR: // return 'ErrorNoTmpDir'; - break; case UPLOAD_ERR_CANT_WRITE: return 'ErrorFailedToWriteInDir'; - break; case UPLOAD_ERR_EXTENSION: return 'ErrorUploadBlockedByAddon'; - break; default: break; } diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index b321c0da621..438ff8246ea 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -53,8 +53,8 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout if (empty($noout)) print_start_menu_array_auguria(); - $usemenuhider = 1; global $usemenuhider; + $usemenuhider = 1; // Show/Hide vertical menu if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) @@ -265,8 +265,8 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t $mainmenu=($forcemainmenu?$forcemainmenu:$_SESSION["mainmenu"]); $leftmenu=($forceleftmenu?'':(empty($_SESSION["leftmenu"])?'none':$_SESSION["leftmenu"])); - $usemenuhider = 0; global $usemenuhider; + $usemenuhider = 0; // Show logo company if (empty($noout) && ! empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e2e977b1321..9efb4dd1e27 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -915,16 +915,16 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers", $langs->trans("List"), 1, $user->rights->fournisseur->commande->lire); if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders_suppliers") { - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->fournisseur->commande->lire); - if (empty($conf->global->SUPPLIER_ORDER_HIDE_VALIDATED)) $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->fournisseur->commande->lire); - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=2", $langs->trans("StatusOrderApprovedShort"), 2, $user->rights->fournisseur->commande->lire); - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=3", $langs->trans("StatusOrderOnProcessShort"), 2, $user->rights->fournisseur->commande->lire); - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=4", $langs->trans("StatusOrderReceivedPartiallyShort"), 2, $user->rights->fournisseur->commande->lire); - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=5", $langs->trans("StatusOrderReceivedAll"), 2, $user->rights->fournisseur->commande->lire); - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusOrderCanceled"), 2, $user->rights->fournisseur->commande->lire); - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=9", $langs->trans("StatusOrderRefused"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=0", $langs->trans("StatusSupplierOrderDraftShort"), 2, $user->rights->fournisseur->commande->lire); + if (empty($conf->global->SUPPLIER_ORDER_HIDE_VALIDATED)) $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=1", $langs->trans("StatusSupplierOrderValidated"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=2", $langs->trans("StatusSupplierOrderApprovedShort"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=3", $langs->trans("StatusSupplierOrderOnProcessShort"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=4", $langs->trans("StatusSupplierOrderReceivedPartiallyShort"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=5", $langs->trans("StatusSupplierOrderReceivedAll"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusSupplierOrderCanceled"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=9", $langs->trans("StatusSupplierOrderRefused"), 2, $user->rights->fournisseur->commande->lire); } - // Billed is another field. We should add instead a dedicated filter on list. if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&billed=1", $langs->trans("StatusOrderBilled"), 2, $user->rights->fournisseur->commande->lire); + // Billed is another field. We should add instead a dedicated filter on list. if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&billed=1", $langs->trans("Billed"), 2, $user->rights->fournisseur->commande->lire); $newmenu->add("/commande/stats/index.php?leftmenu=orders_suppliers&mode=supplier", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire); @@ -1580,8 +1580,17 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $langs->load("mrp"); $newmenu->add("", $langs->trans("MenuBOM"), 0, $user->rights->bom->read, '', $mainmenu, 'bom'); - $newmenu->add("/bom/bom_card.php?leftmenu=bom&action=create", $langs->trans("NewBOM"), 1, $user->rights->bom->write); - $newmenu->add("/bom/bom_list.php?leftmenu=bom", $langs->trans("List"), 1, $user->rights->bom->read); + $newmenu->add("/bom/bom_card.php?leftmenu=bom&action=create", $langs->trans("NewBOM"), 1, $user->rights->bom->write, '', $mainmenu, 'bom'); + $newmenu->add("/bom/bom_list.php?leftmenu=bom", $langs->trans("List"), 1, $user->rights->bom->read, '', $mainmenu, 'bom'); + } + + if (! empty($conf->mrp->enabled)) + { + $langs->load("mrp"); + + $newmenu->add("", $langs->trans("MenuMRP"), 0, $user->rights->mrp->read, '', $mainmenu, 'mo'); + $newmenu->add("/mrp/mo_card.php?leftmenu=mo&action=create", $langs->trans("NewMO"), 1, $user->rights->mrp->write, '', $mainmenu, 'mo'); + $newmenu->add("/mrp/mo_list.php?leftmenu=mo", $langs->trans("List"), 1, $user->rights->mrp->read, '', $mainmenu, 'mo'); } } diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 1898d67ad39..964681a962b 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -51,12 +51,15 @@ class MenuManager /** - * Load this->tabMenu - * - * @return void + * Load this->tabMenu + * + * @param string $forcemainmenu To force mainmenu to load + * @param string $forceleftmenu To force leftmenu to load + * @return void */ - public function loadMenu() + public function loadMenu($forcemainmenu = '', $forceleftmenu = '') { + // Do nothing } diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 606b23e2767..0888e5b84bf 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -761,7 +761,7 @@ class ImportCsv extends ModeleImports $lastinsertid = $res->rowid; $last_insert_id_array[$tablename] = $lastinsertid; } elseif($resql->num_rows > 1) { - $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode($filters, ', ')); + $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); $this->errors[$error]['type']='SQL'; $error++; } else { diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 66670247a4c..253622d115f 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -782,7 +782,7 @@ class ImportXlsx extends ModeleImports $lastinsertid = $res->rowid; $last_insert_id_array[$tablename] = $lastinsertid; } elseif($resql->num_rows > 1) { - $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode($filters, ', ')); + $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); $this->errors[$error]['type']='SQL'; $error++; } else { diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index d9833e2978e..b582d5e2165 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -93,7 +93,7 @@ class modBlockedLog extends DolibarrModules $this->always_enabled = (!empty($conf->blockedlog->enabled) && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) - && $this->alreadyUsed(1)); + && $this->alreadyUsed()); // Constants //----------- diff --git a/htdocs/core/modules/modDataPolicy.class.php b/htdocs/core/modules/modDataPolicy.class.php index a08ce2f7873..13095010a55 100644 --- a/htdocs/core/modules/modDataPolicy.class.php +++ b/htdocs/core/modules/modDataPolicy.class.php @@ -187,8 +187,7 @@ class modDataPolicy extends DolibarrModules { // Cronjobs (List of cron jobs entries to add when module is enabled) // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week $this->cronjobs = array( - 0 => array('label' => 'DATAPOLICY Cron', 'jobtype' => 'method', 'class' => '/datapolicy/class/datapolicyCron.class.php', 'objectname' => 'DataPolicyCron', 'method' => 'exec', 'parameters' => '', 'comment' => 'Clean data', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => '$conf->datapolicy->enabled'), - //1 => array('label' => 'DATAPOLICY Mailing', 'jobtype' => 'method', 'class' => '/datapolicy/class/datapolicyCron.class.php', 'objectname' => 'RgpdCron', 'method' => 'sendMailing', 'parameters' => '', 'comment' => 'Comment', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 0, 'test' => true) + 0 => array('label' => 'DATAPOLICYJob', 'jobtype' => 'method', 'class' => 'datapolicy/class/datapolicycron.class.php', 'objectname' => 'DataPolicyCron', 'method' => 'cleanDataForDataPolicy', 'parameters' => '', 'comment' => 'Clean data', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => '$conf->datapolicy->enabled'), ); // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true), // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true) diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index 6594d7bb04a..f85f5656afe 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -58,7 +58,7 @@ class modReception extends DolibarrModules // Data directories to create when module is enabled $this->dirs = array("/reception/receipt", "/reception/receipt/temp", - "/doctemplates/reception" + "/doctemplates/receptions" ); // Config pages diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 23d000308ef..4a16724d614 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -121,15 +121,7 @@ class pdf_squille extends ModelePdfReception // 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'; - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("products"); - $outputlangs->load("propal"); - $outputlangs->load("deliveries"); - $outputlangs->load("receptions"); - $outputlangs->load("productbatch"); + $outputlangs->loadLangs(array("main","dict","companies","bills","products","propal","deliveries","receptions","productbatch","sendings")); $nblines = count($object->lines); diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 1f7d403b575..0f9b733d010 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -208,7 +208,7 @@ if ($permission) { if ($tab[$i]['source']=='external') { $contactstatic->fetch($tab[$i]['id']); - echo $contactstatic->getNomUrl(1, '', 0, '', 0, 0, '', 'valignmiddle'); + echo $contactstatic->getNomUrl(1, '', 0, '', 0, 0); } ?> diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f427bb34f92..1f0897f7e98 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -375,7 +375,7 @@ if ($nolinesbefore) { { $coldisplay++; ?> - + + showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var],'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); + print $line->showOptionals($extrafieldsline, 'edit', array('class'=>'tredited', 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } ?> diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index d048b6f7c9d..988df55b61c 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -163,6 +163,23 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; print (! empty($line->description) && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; } } + + if ($user->rights->fournisseur->lire && $line->fk_fournprice > 0) + { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productfourn = new ProductFournisseur($this->db); + $productfourn->fetch_product_fournisseur_price($line->fk_fournprice); + echo '
' . $langs->trans('Supplier') . ' : ' . $productfourn->getSocNomUrl(1, 'supplier') . ' - ' . $langs->trans('Ref') . ' : '; + // Supplier ref + if ($user->rights->produit->creer || $user->rights->service->creer) // change required right here + { + echo $productfourn->getNomUrl(); + } + else + { + echo $productfourn->ref_supplier; + } + } if (! empty($conf->accounting->enabled) && $line->fk_accounting_account > 0) { diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 7934a628880..0e12da80cfc 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -894,14 +894,15 @@ class Cronjob extends CommonObject /** * Load object information * - * @return int + * @param int $id ID + * @return int <0 if KO, >0 if OK */ - public function info() + public function info($id) { $sql = "SELECT"; $sql.= " f.rowid, f.datec, f.tms, f.fk_user_mod, f.fk_user_author"; $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as f"; - $sql.= " WHERE f.rowid = ".$this->id; + $sql.= " WHERE f.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index bf1033084d5..c4b3cd2458d 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -30,6 +30,16 @@ include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; */ class DataPolicy { + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + /** * getAllContactNotInformed * @@ -200,7 +210,6 @@ class DataPolicy } else { $result4 = $mailfile->sendfile(); if (!$error) { - $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; $contact->array_options['options_datapolicy_send'] = date('Y-m-d', time()); $contact->update($contact->id); @@ -301,6 +310,10 @@ class DataPolicy $sendto = $adherent->email; + // TODO Use a dolibarr email template + $s = 'TXTLINKDATAPOLICIESSUBJECT_' . $l; + $ma = 'TXTLINKDATAPOLICIESMESSAGE_' . $l; + $code= md5($adherent->email); if (!empty($adherent->default_lang)) { $l = $adherent->default_lang; diff --git a/htdocs/datapolicy/class/datapolicycron.class.php b/htdocs/datapolicy/class/datapolicycron.class.php index 656831eed2f..6c1a740bd98 100644 --- a/htdocs/datapolicy/class/datapolicycron.class.php +++ b/htdocs/datapolicy/class/datapolicycron.class.php @@ -19,7 +19,7 @@ /** * \file htdocs/datapolicy/class/datapolicycron.class.php * \ingroup datapolicy - * \brief Example hook overload. + * \brief File for cron task of module DataPolicy */ /** @@ -27,17 +27,33 @@ */ class DataPolicyCron { + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + + /** * Function exec + * CAN BE A CRON TASK * - * @return boolean + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ - public function exec() + public function cleanDataForDataPolicy() { - global $conf, $db, $langs, $user; + global $conf, $langs, $user; $langs->load('datapolicy@datapolicy'); + $error = 0; + $errormsg = ''; + $nbupdated = $nbdeleted = 0; + // FIXME Removed hardcoded values of id $arrayofparameters=array( 'DATAPOLICIES_TIERS_CLIENT' => array( @@ -446,14 +462,18 @@ class DataPolicyCron ), ); - foreach ($arrayofparameters as $key => $params) { - if ($conf->global->$key != '' && is_numeric($conf->global->$key) && (int) $conf->global->$key > 0) { + $this->db->begin(); + foreach ($arrayofparameters as $key => $params) + { + if ($conf->global->$key != '' && is_numeric($conf->global->$key) && (int) $conf->global->$key > 0) + { $sql = sprintf($params['sql'], (int) $conf->entity, (int) $conf->global->$key, (int) $conf->global->$key); $resql = $db->query($sql); - if ($resql && $db->num_rows($resql) > 0) { + if ($resql && $db->num_rows($resql) > 0) + { $num = $db->num_rows($resql); $i = 0; @@ -461,33 +481,51 @@ class DataPolicyCron require_once $params['file']; $object = new $params['class']($db); - while ($i < $num) + while ($i < $num && ! $error) { $obj = $db->fetch_object($resql); $object->fetch($obj->rowid); $object->id = $obj->rowid; - if ($object->isObjectUsed($obj->rowid) > 0) { + if ($object->isObjectUsed($obj->rowid) > 0) // If object to clean is used + { foreach ($params['fields_anonym'] as $fields => $val) { $object->$fields = $val; } - $object->update($obj->rowid, $user); - if ($params['class'] == 'Societe') { - // On supprime les contacts associé - $sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = " . $obj->rowid; - $db->query($sql); + $result = $object->update($obj->rowid, $user); + if ($result > 0) + { + if ($params['class'] == 'Societe') { + // We delete contacts of thirdparty + $sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = " . $obj->rowid; + $result = $this->db->query($sql); + if ($result < 0) + { + $errormsg = $this->db->lasterror(); + $error++; + } + } } - } else { - if (DOL_VERSION < 8) { - $ret = $object->delete($obj->rowid, $user); + else + { + $errormsg = $object->error; + $error++; + } + $nbupdated++; + } else { // If object to clean is not used + if ($object->element == 'adherent') { + $result = $object->delete($obj->rowid, $user); } else { - if ($object->element == 'adherent') { - $ret = $object->delete($obj->rowid); - } else { - $ret = $object->delete(); - } + $result = $object->delete($user); } + if ($result < 0) + { + $errormsg = $object->error; + $error++; + } + + $nbdeleted++; } $i++; @@ -495,27 +533,18 @@ class DataPolicyCron } } } - return true; - } + $this->db->commit(); - /** - * sendMailing - * - * @return boolean - */ - public function sendMailing() - { - global $conf, $db, $langs, $user; + if (! $error) + { + $this->output = $nbupdated.' record updated, '.$nbdeleted.' record deleted'; + } + else + { + $this->error = $errormsg; + } - $langs->load('datapolicy@datapolicy'); - - require_once DOL_DOCUMENT_ROOT . '/datapolicy/class/datapolicy.class.php'; - - $contacts = new DataPolicy($db); - $contacts->getAllContactNotInformed(); - $contacts->getAllCompaniesNotInformed(); - $contacts->getAllAdherentsNotInformed(); - return true; + return 0; } } diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index f9e2c5ab64b..ef59743e03f 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -106,7 +106,7 @@ class Donations extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) ) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 9f1e42a7aaa..5e4d0d5e00c 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -106,7 +106,7 @@ class Shipments extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index cb5a438bc21..f2177aafc63 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -101,7 +101,7 @@ class ExpenseReports extends DolibarrApi $obj_ret = array(); // case of external user, $societe param is ignored and replaced by user's socid - //$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; + //$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe; $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as t"; diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index b183623edb3..12f6824ad4d 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -113,7 +113,7 @@ class Interventions extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 897d210b1f1..323ddf29521 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -103,7 +103,7 @@ class SupplierOrders extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index c38107b14b4..64c7ca73b7b 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -639,28 +639,27 @@ class CommandeFournisseur extends CommonOrder { $langs->load('orders'); - $this->statuts[0] = 'StatusOrderDraft'; - $this->statuts[1] = 'StatusOrderValidated'; - $this->statuts[2] = 'StatusOrderApproved'; - if (empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $this->statuts[3] = 'StatusOrderOnProcess'; - else $this->statuts[3] = 'StatusOrderOnProcessWithValidation'; - $this->statuts[4] = 'StatusOrderReceivedPartially'; - $this->statuts[5] = 'StatusOrderReceivedAll'; - $this->statuts[6] = 'StatusOrderCanceled'; // Approved->Canceled - $this->statuts[7] = 'StatusOrderCanceled'; // Process running->canceled - //$this->statuts[8] = 'StatusOrderBilled'; // Everything is finished, order received totally and bill received - $this->statuts[9] = 'StatusOrderRefused'; + $this->statuts[0] = 'StatusSupplierOrderDraft'; + $this->statuts[1] = 'StatusSupplierOrderValidated'; + $this->statuts[2] = 'StatusSupplierOrderApproved'; + if (empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $this->statuts[3] = 'StatusSupplierOrderOnProcess'; + else $this->statuts[3] = 'StatusSupplierOrderOnProcessWithValidation'; + $this->statuts[4] = 'StatusSupplierOrderReceivedPartially'; + $this->statuts[5] = 'StatusSupplierOrderReceivedAll'; + $this->statuts[6] = 'StatusSupplierOrderCanceled'; // Approved->Canceled + $this->statuts[7] = 'StatusSupplierOrderCanceled'; // Process running->canceled + $this->statuts[9] = 'StatusSupplierOrderRefused'; // List of language codes for status - $this->statutshort[0] = 'StatusOrderDraftShort'; - $this->statutshort[1] = 'StatusOrderValidatedShort'; - $this->statutshort[2] = 'StatusOrderApprovedShort'; - $this->statutshort[3] = 'StatusOrderOnProcessShort'; - $this->statutshort[4] = 'StatusOrderReceivedPartiallyShort'; - $this->statutshort[5] = 'StatusOrderReceivedAllShort'; - $this->statutshort[6] = 'StatusOrderCanceledShort'; - $this->statutshort[7] = 'StatusOrderCanceledShort'; - $this->statutshort[9] = 'StatusOrderRefusedShort'; + $this->statutshort[0] = 'StatusSupplierOrderDraftShort'; + $this->statutshort[1] = 'StatusSupplierOrderValidatedShort'; + $this->statutshort[2] = 'StatusSupplierOrderApprovedShort'; + $this->statutshort[3] = 'StatusSupplierOrderOnProcessShort'; + $this->statutshort[4] = 'StatusSupplierOrderReceivedPartiallyShort'; + $this->statutshort[5] = 'StatusSupplierOrderReceivedAllShort'; + $this->statutshort[6] = 'StatusSupplierOrderCanceledShort'; + $this->statutshort[7] = 'StatusSupplierOrderCanceledShort'; + $this->statutshort[9] = 'StatusSupplierOrderRefusedShort'; } $billedtext=''; diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index df29d329e0d..9be757cf87e 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -939,8 +939,16 @@ if ($id > 0 || ! empty($ref)) { print ''; print ''; print ''; - if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) || !empty($conf->reception->enabled)) + + // Status + if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && empty($reception->rowid)) { print ''; + } + elseif(!empty($conf->reception->enabled)) { + print ''; + } + + print ''; print "\n"; @@ -1025,17 +1033,15 @@ if ($id > 0 || ! empty($ref)) { } } print ''; - }elseif(!empty($conf->reception->enabled)){ + } elseif(!empty($conf->reception->enabled)) { print ''; } - print ''; - print ''; - + print ''; print "\n"; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 2207148e4ea..204d832a94c 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -55,13 +55,6 @@ $langs->load("holiday"); $childids = $user->getAllChildIds(1); -$cancreate = 0; -if (! empty($user->rights->holiday->write_all)) $cancreate=1; -if (! empty($user->rights->holiday->write) && in_array($fuserid, $childids)) $cancreate=1; - -$candelete = 0; -if (! empty($user->rights->holiday->delete)) $candelete=1; - $morefilter = 'AND employee = 1'; if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; @@ -82,6 +75,13 @@ if ($id > 0) } } +$cancreate = 0; +if (! empty($user->rights->holiday->write_all)) $cancreate=1; +if (! empty($user->rights->holiday->write) && in_array($fuserid, $childids)) $cancreate=1; + +$candelete = 0; +if (! empty($user->rights->holiday->delete)) $candelete=1; +if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && in_array($object->fk_user, $childids)) $candelete=1; /* * Actions @@ -1435,7 +1435,7 @@ else { print ''.$langs->trans("SetToDraft").''; } - if ($user->rights->holiday->delete && ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED)) // If draft or canceled or refused + if ($candelete && ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED)) // If draft or canceled or refused { print ''.$langs->trans("DeleteCP").''; } diff --git a/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql b/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql index 5b6f4bf3f0c..312c30210c8 100644 --- a/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql +++ b/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql @@ -41,3 +41,4 @@ INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, year, month, day INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, year, month, day, active) VALUES('FRASSOMPTION', 0, 1, 0, 8, 15, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, year, month, day, active) VALUES('FRTOUSSAINT', 0, 1, 0, 11, 1, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, year, month, day, active) VALUES('FRARMISTICE', 0, 1, 0, 11, 11, 1); +--INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('EASTER', 0, 1, 'easter', 0, 0, 0, 1); 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 7ef80e9b5b6..4bf4cef6bba 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 @@ -106,6 +106,7 @@ ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_c_type_co ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); +ALTER TABLE llx_accounting_account MODIFY COLUMN rowid bigint AUTO_INCREMENT; create table llx_c_hrm_public_holiday ( @@ -121,4 +122,6 @@ create table llx_c_hrm_public_holiday import_key varchar(14) )ENGINE=innodb; +ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_start datetime DEFAULT NULL; +ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_end datetime DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_accounting_account.sql b/htdocs/install/mysql/tables/llx_accounting_account.sql index 727965f6a9d..fd1962b6c09 100644 --- a/htdocs/install/mysql/tables/llx_accounting_account.sql +++ b/htdocs/install/mysql/tables/llx_accounting_account.sql @@ -21,7 +21,7 @@ create table llx_accounting_account ( - rowid integer AUTO_INCREMENT PRIMARY KEY, + rowid bigint AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, datec datetime, tms timestamp, diff --git a/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql b/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql index 211502686ee..b735046a340 100644 --- a/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql +++ b/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql @@ -40,6 +40,8 @@ CREATE TABLE llx_supplier_proposaldet ( total_localtax2 double(24,8) DEFAULT 0, total_ttc double(24,8) DEFAULT 0, product_type integer DEFAULT 0, + date_start datetime DEFAULT NULL, -- date debut si service + date_end datetime DEFAULT NULL, -- date fin si service info_bits integer DEFAULT 0, buy_price_ht double(24,8) DEFAULT 0, fk_product_fournisseur_price integer DEFAULT NULL, diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 494e7d4a8a3..a8f7f9643ce 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -218,7 +218,7 @@ DoliStoreDesc=DoliStore, the official market place for Dolibarr ERP/CRM external DoliPartnersDesc=List of companies providing custom-developed modules or features.
Note: since Dolibarr is an open source application, anyone experienced in PHP programming may develop a module. WebSiteDesc=External websites for more add-on (non-core) modules... DevelopYourModuleDesc=Some solutions to develop your own module... -URL=Link +URL=URL BoxesAvailable=Widgets available BoxesActivated=Widgets activated ActivateOn=Activate on @@ -1940,4 +1940,5 @@ RESTRICT_API_ON_IP=Allow available APIs to some host IP only (wildcard not allow RESTRICT_ON_IP=Allow access to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can access. BaseOnSabeDavVersion=Based on the library SabreDAV version NotAPublicIp=Not a public IP -MakeAnonymousPing=Make an anonymous Ping '+1' to the Dolibarr foundation server (done 1 time only after installation) to allow the foundation to count the number of Dolibarr installation. \ No newline at end of file +MakeAnonymousPing=Make an anonymous Ping '+1' to the Dolibarr foundation server (done 1 time only after installation) to allow the foundation to count the number of Dolibarr installation. +FeatureNotAvailableWithReceptionModule=Feature not available when module Reception is enabled diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index aee4d7bb988..1de1251831a 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -81,3 +81,4 @@ JobDisabled=Job disabled MakeLocalDatabaseDumpShort=Local database backup MakeLocalDatabaseDump=Create a local database dump. Parameters are: compression ('gz' or 'bz' or 'none'), backup type ('mysql', 'pgsql', 'auto'), 1, 'auto' or filename to build, number of backup files to keep WarningCronDelayed=Attention, for performance purpose, whatever is next date of execution of enabled jobs, your jobs may be delayed to a maximum of %s hours, before being run. +DATAPOLICYJob=Data cleaner and anonymizer diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 64ebfc40b32..c4611836a51 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -825,6 +825,7 @@ Mandatory=Mandatory Hello=Hello GoodBye=GoodBye Sincerely=Sincerely +ConfirmDeleteObject=Are you sure you want to delete this object? DeleteLine=Delete line ConfirmDeleteLine=Are you sure you want to delete this line? NoPDFAvailableForDocGenAmongChecked=No PDF were available for the document generation among checked record diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 360f4303f07..96efb3be55f 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -15,3 +15,5 @@ ManufacturingEfficiency=Manufacturing efficiency ValueOfMeansLoss=Value of 0.95 means an average of 5%% of loss during the production DeleteBillOfMaterials=Delete Bill Of Materials ConfirmDeleteBillOfMaterials=Are you sure you want to delete this Bill Of Material? +MenuMRP=Manufacturing Orders +NewMO=New Manufacturing Order \ No newline at end of file diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 256bd2a7d4d..3197cc12bca 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -37,7 +37,6 @@ StatusOrderDeliveredShort=Delivered StatusOrderToBillShort=Delivered StatusOrderApprovedShort=Approved StatusOrderRefusedShort=Refused -StatusOrderBilledShort=Billed StatusOrderToProcessShort=To process StatusOrderReceivedPartiallyShort=Partially received StatusOrderReceivedAllShort=Products received @@ -50,7 +49,6 @@ StatusOrderProcessed=Processed StatusOrderToBill=Delivered StatusOrderApproved=Approved StatusOrderRefused=Refused -StatusOrderBilled=Billed StatusOrderReceivedPartially=Partially received StatusOrderReceivedAll=All products received ShippingExist=A shipment exists @@ -156,3 +154,31 @@ OptionToSetOrderBilledNotEnabled=Option (from module Workflow) to set order to ' IfValidateInvoiceIsNoOrderStayUnbilled=If invoice validation is 'No', the order will remain to status 'Unbilled' until the invoice is validated. CloseReceivedSupplierOrdersAutomatically=Close order to status "%s" automatically if all products are received. SetShippingMode=Set shipping mode + +#### supplier orders status +StatusSupplierOrderCanceledShort=Canceled +StatusSupplierOrderDraftShort=Draft +StatusSupplierOrderValidatedShort=Validated +StatusSupplierOrderSentShort=In process +StatusSupplierOrderSent=Shipment in process +StatusSupplierOrderOnProcessShort=Ordered +StatusSupplierOrderProcessedShort=Processed +StatusSupplierOrderDelivered=Delivered +StatusSupplierOrderDeliveredShort=Delivered +StatusSupplierOrderToBillShort=Delivered +StatusSupplierOrderApprovedShort=Approved +StatusSupplierOrderRefusedShort=Refused +StatusSupplierOrderToProcessShort=To process +StatusSupplierOrderReceivedPartiallyShort=Partially received +StatusSupplierOrderReceivedAllShort=Products received +StatusSupplierOrderCanceled=Canceled +StatusSupplierOrderDraft=Draft (needs to be validated) +StatusSupplierOrderValidated=Validated +StatusSupplierOrderOnProcess=Ordered - Standby reception +StatusSupplierOrderOnProcessWithValidation=Ordered - Standby reception or validation +StatusSupplierOrderProcessed=Processed +StatusSupplierOrderToBill=Delivered +StatusSupplierOrderApproved=Approved +StatusSupplierOrderRefused=Refused +StatusSupplierOrderReceivedPartially=Partially received +StatusSupplierOrderReceivedAll=All products received \ No newline at end of file diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 88e5eaf128c..b1d6e30e329 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -76,7 +76,7 @@ WithdrawalFile=Withdrawal file SetToStatusSent=Set to status "File Sent" ThisWillAlsoAddPaymentOnInvoice=This will also record payments to invoices and will classify them as "Paid" if remain to pay is null StatisticsByLineStatus=Statistics by status of lines -RUM=Unique Mandate Reference (UMR) +RUM=UMR DateRUM=Mandate signature date RUMLong=Unique Mandate Reference RUMWillBeGenerated=If empty, a UMR (Unique Mandate Reference) will be generated once the bank account information is saved. diff --git a/htdocs/langs/fr_FR/orders.lang b/htdocs/langs/fr_FR/orders.lang index bbbeb2638e8..a2c6fa1ea82 100644 --- a/htdocs/langs/fr_FR/orders.lang +++ b/htdocs/langs/fr_FR/orders.lang @@ -156,3 +156,33 @@ OptionToSetOrderBilledNotEnabled=L'option (issue du module Workflow) pour défin IfValidateInvoiceIsNoOrderStayUnbilled=Si la validation de facture est à "Non", la commande restera au statut "Non facturé" jusqu'à ce que la facture soit validée. CloseReceivedSupplierOrdersAutomatically=Fermer la commande au statut "%s" automatiquement si tous les produits ont été reçus. SetShippingMode=Définir la méthode d'expédition + +###### statuts commandes fournisseurs +StatusSupplierOrderCanceledShort=Annulée +StatusSupplierOrderDraftShort=Brouillon +StatusSupplierOrderValidatedShort=Validée +StatusSupplierOrderSentShort=En cours +StatusSupplierOrderSent=Envoi en cours +StatusSupplierOrderOnProcessShort=Commandé +StatusSupplierOrderProcessedShort=Traitée +StatusSupplierOrderDelivered=Livrée +StatusSupplierOrderDeliveredShort=Livrée +StatusSupplierOrderToBillShort=Livré +StatusSupplierOrderApprovedShort=Approuvée +StatusSupplierOrderRefusedShort=Refusée +StatusSupplierOrderBilledShort=Facturée +StatusSupplierOrderToProcessShort=À traiter +StatusSupplierOrderReceivedPartiallyShort=Reçue partiellement +StatusSupplierOrderReceivedAllShort=Produits reçus +StatusSupplierOrderCanceled=Annulée +StatusSupplierOrderDraft=Brouillon (à valider) +StatusSupplierOrderValidated=Validée +StatusSupplierOrderOnProcess=Commandé - en attente de réception +StatusSupplierOrderOnProcessWithValidation=Commandé - en attente de réception ou validation +StatusSupplierOrderProcessed=Traitée +StatusSupplierOrderToBill=Livrée +StatusSupplierOrderApproved=Approuvée +StatusSupplierOrderRefused=Refusée +StatusSupplierOrderBilled=Facturée +StatusSupplierOrderReceivedPartially=Reçue partiellement +StatusSupplierOrderReceivedAll=Tous les produits reçus diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 1c3c899b19c..4b7efffdfed 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2195,7 +2195,7 @@ elseif (! empty($module)) print ''; - print '
'.$langs->trans("Statistics").'
attributes[$this->table_element]['required'][$key])) $out .= ' fieldrequired'; $out .= '">'; - if (! empty($extrafields->attributes[$object->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$object->table_element]['help'][$key]); + if (! empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]); else $out .= $labeltoshow; $out .= ''; + //$out .=''; switch($mode) { case "view": @@ -6669,6 +6682,11 @@ abstract class CommonObject $out .= '
">"> global->MAIN_EDIT_PREDEF_PRICEHT)) + { + ?> + // get the HT price for the product and display it + $.post('/product/ajax/products.php?action=fetch', { 'id': $(this).val(), 'socid' : socid; ?> }, function(data) { + jQuery("#price_ht").val(data.price_ht); + }, + 'json'); rights->margins->creer) { $langs->load('stocks'); @@ -839,7 +850,10 @@ function setforpredef() { console.log("Call setforpredef. We hide some fields and show dates"); jQuery("#select_type").val(-1); jQuery("#prod_entry_mode_free").prop('checked',false).change(); - jQuery("#prod_entry_mode_predef").prop('checked',true).change(); + jQuery("#prod_entry_mode_predef").prop('checked',true).change( + global->MAIN_EDIT_PREDEF_PRICEHT)) { ?> + jQuery("#price_ht").val('').hide(); + jQuery("#price_ht").val('') jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide(); jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index bac9ff997bc..82eb44c3b9b 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -140,7 +140,7 @@ $coldisplay=0; { $coldisplay++; ?> - ' . $langs->trans("Warehouse") . '' . $langs->trans("Comment") . '' . $langs->trans("Status") . '
'; if(!empty($reception->id)){ print $reception->getLibStatut(5); } + print ''; - print '
'; print $proptype; print ''; + print ''; if ($proparrayofkeyval) { print json_encode($proparrayofkeyval); } @@ -2344,7 +2344,7 @@ elseif (! empty($module)) { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; - //$menus = $moduleobj->; + $menus = $moduleobj->menu; if ($action != 'editfile' || empty($file)) { @@ -2361,9 +2361,6 @@ elseif (! empty($module)) print '
'; print load_fiche_titre($langs->trans("ListOfMenusEntries"), '', ''); - // @TODO - print $langs->trans("FeatureNotYetAvailable"); - print '
'; print ''; print ''; @@ -2371,77 +2368,90 @@ elseif (! empty($module)) print ''; print ''; - /* - print '
'; - print ''; + print '
'; + print '
'; - print ''; - print_liste_field_titre("Menu",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder); - print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print "\n"; + print ''; + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("fk_menu", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Title", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("mainmenu", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("leftmenu", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("URL", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + 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("Target", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("UserType", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print "\n"; - if (count($menus)) - { - foreach ($cronjobs as $cron) - { - print ''; + if (count($menus)) + { + foreach ($menus as $menu) + { + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; - } + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + } } else { - print ''; + print ''; } print '
'; - print $cron['label']; - print ''; + print $menu['type']; + print ''; - if ($cron['jobtype']=='method') - { - $text=$langs->trans("CronClass"); - $texttoshow=$langs->trans('CronModule').': '.$module.'
'; - $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'
'; - $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'
'; - $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; - $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - elseif ($cron['jobtype']=='command') - { - $text=$langs->trans('CronCommand'); - $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); - $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - print $form->textwithpicto($text, $texttoshow, 1); - print '
'; + print $menu['fk_menu']; + print ''; - if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); - if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); - if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); - if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); - print ''; + print $menu['titre']; + print ''; - print $cron['status']; - print ''; + print $menu['mainmenu']; + print ''; - if (!empty($cron['comment'])) {print $cron['comment'];} - print ''; + print $menu['left']; + print '
'; + print $menu['url']; + print ''; + print $menu['langs']; + print ''; + print $menu['position']; + print ''; + print $menu['enabled']; + print ''; + print $menu['perms']; + print ''; + print $menu['target']; + print ''; + print $menu['user']; + print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; print '
'; print '
'; - */ } else { @@ -2474,7 +2484,7 @@ elseif (! empty($module)) { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; - //$perms = $moduleobj->; + $perms = $moduleobj->rights; if ($action != 'editfile' || empty($file)) { @@ -2492,10 +2502,6 @@ elseif (! empty($module)) print '
'; print load_fiche_titre($langs->trans("ListOfPermissionsDefined"), '', ''); - - // @TODO - print $langs->trans("FeatureNotYetAvailable"); - print '
'; print ''; print ''; @@ -2503,77 +2509,50 @@ elseif (! empty($module)) print ''; print ''; - /* - print '
'; - print ''; + print '
'; + print '
'; - print ''; - print_liste_field_titre("CronLabel",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder); - print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print "\n"; + print ''; + print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Permission", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print "\n"; - if (count($cronjobs)) - { - foreach ($cronjobs as $cron) - { - print ''; + if (count($perms)) + { + foreach ($perms as $perm) + { + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; + } + } + else + { + print ''; + } - print ''; - } - } - else - { - print ''; - } + print '
'; - print $cron['label']; - print ''; + print $perm[0]; + print ''; - if ($cron['jobtype']=='method') - { - $text=$langs->trans("CronClass"); - $texttoshow=$langs->trans('CronModule').': '.$module.'
'; - $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'
'; - $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'
'; - $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; - $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - elseif ($cron['jobtype']=='command') - { - $text=$langs->trans('CronCommand'); - $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); - $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - print $form->textwithpicto($text, $texttoshow, 1); - print '
'; + print $perm[1]; + print ''; - if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); - if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); - if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); - if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); - print ''; + print $perm[4]; + print ''; - print $cron['status']; - print ''; + print $perm[5]; + print ''; - if (!empty($cron['comment'])) {print $cron['comment'];} - print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; + print '
'; - print '
'; - print ''; - - print ''; - */ + print ''; } else { diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 0fcd9a8afd4..594f979bb22 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -111,7 +111,7 @@ class MyModuleApi extends DolibarrApi throw new RestException(401); } - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $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/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 28c817658f6..72bc424c53c 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -256,7 +256,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); } // Confirmation to delete line if ($action == 'deleteline') diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 2543ff4a2e6..446b4fa3cfe 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -116,7 +116,7 @@ class Products extends DolibarrApi $obj_ret = array(); - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; $sql = "SELECT t.rowid, t.ref, t.ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX."product as t"; diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 38ea9796f65..0744017161e 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -105,7 +105,7 @@ class Projects extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index b5e589e4ef9..2415950e37b 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -113,7 +113,7 @@ class Tasks extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index 9601c661c70..2b66b76e9dd 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -1,6 +1,7 @@ - * Copyright (C) 2014 Marcos García +/* Copyright (C) 2012 Regis Houssin + * Copyright (C) 2014 Marcos García + * Copyright (C) 2019 Laurent Destailleur * * 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 @@ -15,6 +16,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> @@ -22,41 +31,47 @@ load("receptions"); +$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); + $total=0; $ilink=0; -$var=true; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass=($var?'pair':'impair'); + $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> - trans("Reception"); ?> - getNomUrl(1); ?> - - date_delivery, 'day'); ?> - trans("Reception"); ?> + global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print ' + + getNomUrl(1); ?> + + date_delivery, 'day'); ?> + rights->reception->lire) { $total = $total + $objectlink->total_ht; echo price($objectlink->total_ht); } ?> - getLibStatut(3); ?> - + getLibStatut(3); ?> + element != 'order_supplier') { ?> - ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> + societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index efb480370cd..bf6ec8d0c59 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -357,7 +357,7 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - $result = $object->addline( + $result = $object->addline( $desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, @@ -646,6 +646,9 @@ if (empty($reshook)) $pu_ht = $productsupplier->fourn_pu; if (empty($pu_ht)) $pu_ht = 0; // If pu is '' or null, we force to have a numeric value + $fournprice = 0; + $buyingprice = 0; + $result=$object->addline( $desc, $pu_ht, @@ -670,9 +673,17 @@ if (empty($reshook)) $productsupplier->fk_unit, '', 0, - $productsupplier->fourn_multicurrency_unitprice + $productsupplier->fourn_multicurrency_unitprice, + $date_start, + $date_end ); + //var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit; + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } } if ($idprod == -99 || $idprod == 0) { @@ -1756,7 +1767,7 @@ if ($action == 'create') if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier=1; if (! empty($object->lines)) - $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); + $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector); // Form to add new line if ($object->statut == SupplierProposal::STATUS_DRAFT && $user->rights->supplier_proposal->creer) @@ -1764,7 +1775,7 @@ if ($action == 'create') if ($action != 'editline') { // Add products/services form - $object->formAddObjectLine(1, $soc, $mysoc); + $object->formAddObjectLine($dateSelector, $soc, $mysoc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index 014951d980e..cb606e8a083 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -101,7 +101,7 @@ class Supplierproposals extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 3748aede1c7..f6866569f13 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -324,9 +324,6 @@ class SupplierProposal extends CommonObject $supplier_proposalligne->rang=-1; $supplier_proposalligne->info_bits=2; - // TODO deprecated - $supplier_proposalligne->price=-$remise->amount_ht; - $supplier_proposalligne->total_ht = -$remise->amount_ht; $supplier_proposalligne->total_tva = -$remise->amount_tva; $supplier_proposalligne->total_ttc = -$remise->amount_ttc; @@ -391,11 +388,13 @@ class SupplierProposal extends CommonObject * @param string $origin 'order', 'supplier_proposal', ... * @param int $origin_id Id of origin line * @param double $pu_ht_devise Amount in currency + * @param int $date_start Date start + * @param int $date_end Date end * @return int >0 if OK, <0 if KO * * @see add_product() */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0, $date_start = 0, $date_end = 0) { global $mysoc, $conf; @@ -570,6 +569,8 @@ class SupplierProposal extends CommonObject $this->line->origin=$origin; $this->line->origin_id=$origin_id; $this->line->ref_fourn = $this->db->escape($ref_supplier); + $this->line->date_start = $date_start; + $this->line->date_end = $date_end; // infos marge if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { @@ -594,10 +595,6 @@ class SupplierProposal extends CommonObject // Mise en option de la ligne if (empty($qty) && empty($special_code)) $this->line->special_code=3; - // TODO deprecated - $this->line->price=$price; - $this->line->remise=$remise; - if (is_array($array_option) && count($array_option)>0) { $this->line->array_options=$array_option; } @@ -613,7 +610,7 @@ class SupplierProposal extends CommonObject if ($result > 0) { $this->db->commit(); - return $this->line->rowid; + return $this->line->id; } else { @@ -629,6 +626,11 @@ class SupplierProposal extends CommonObject return -2; } } + else + { + $this->error = 'BadStatusOfObjectToAddLine'; + return -5; + } } @@ -688,6 +690,7 @@ class SupplierProposal extends CommonObject $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); // Clean vat code + $reg = array(); $vat_src_code=''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { @@ -707,14 +710,6 @@ class SupplierProposal extends CommonObject $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - // Anciens indicateurs: $price, $remise (a ne plus utiliser) - $price = $pu; - if ($remise_percent > 0) - { - $remise = round(($pu * $remise_percent / 100), 2); - $price = $pu - $remise; - } - // Update line $this->line=new SupplierProposalLine($this->db); @@ -730,7 +725,7 @@ class SupplierProposal extends CommonObject $this->line->rang = $rangmax + 1; } - $this->line->rowid = $rowid; + $this->line->id = $rowid; $this->line->label = $label; $this->line->desc = $desc; $this->line->qty = $qty; @@ -768,10 +763,6 @@ class SupplierProposal extends CommonObject } $this->line->pa_ht = $pa_ht; - // TODO deprecated - $this->line->price=$price; - $this->line->remise=$remise; - if (is_array($array_option) && count($array_option)>0) { $this->line->array_options=$array_option; } @@ -791,7 +782,6 @@ class SupplierProposal extends CommonObject $this->update_price(1); $this->fk_supplier_proposal = $this->id; - $this->rowid = $rowid; $this->db->commit(); return $result; @@ -1357,7 +1347,6 @@ class SupplierProposal extends CommonObject $line->subprice = $objp->subprice; $line->fk_remise_except = $objp->fk_remise_except; $line->remise_percent = $objp->remise_percent; - $line->price = $objp->price; // TODO deprecated $line->info_bits = $objp->info_bits; $line->total_ht = $objp->total_ht; @@ -2371,7 +2360,6 @@ class SupplierProposal extends CommonObject $line->desc=$langs->trans("Description")." ".$xnbp; $line->qty=1; $line->subprice=100; - $line->price=100; $line->tva_tx=19.6; $line->localtax1_tx=0; $line->localtax2_tx=0; @@ -2745,9 +2733,6 @@ class SupplierProposalLine extends CommonObjectLine public $oldline; - // From llx_supplier_proposaldet - public $rowid; // deprecated - /** * @var int ID */ @@ -2813,20 +2798,11 @@ class SupplierProposalLine extends CommonObjectLine // Bit 1: 0 ligne normale - 1 si ligne de remise fixe public $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne - public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne + public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne - /** - * @deprecated - * @see remise_percent, fk_remise_except - */ - public $remise; - - /** - * @deprecated - * @see subprice - */ - public $price; + public $date_start; + public $date_end; // From llx_product /** @@ -2902,6 +2878,7 @@ class SupplierProposalLine extends CommonObjectLine public function fetch($rowid) { $sql = 'SELECT pd.rowid, pd.fk_supplier_proposal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; + $sql.= ' pd.date_start, pd.date_end,'; $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; @@ -2917,21 +2894,20 @@ class SupplierProposalLine extends CommonObjectLine { $objp = $this->db->fetch_object($result); - $this->rowid = $objp->rowid; // deprecated $this->id = $objp->rowid; $this->fk_supplier_proposal = $objp->fk_supplier_proposal; $this->fk_parent_line = $objp->fk_parent_line; $this->label = $objp->custom_label; $this->desc = $objp->description; $this->qty = $objp->qty; - $this->price = $objp->price; // deprecated $this->subprice = $objp->subprice; $this->tva_tx = $objp->tva_tx; - $this->remise = $objp->remise; $this->remise_percent = $objp->remise_percent; $this->fk_remise_except = $objp->fk_remise_except; $this->fk_product = $objp->fk_product; $this->info_bits = $objp->info_bits; + $this->date_start = $this->db->jdate($objp->date_start); + $this->date_end = $this->db->jdate($objp->date_end); $this->total_ht = $objp->total_ht; $this->total_tva = $objp->total_tva; @@ -3028,6 +3004,7 @@ class SupplierProposalLine extends CommonObjectLine // Insert line into database $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'supplier_proposaldet'; $sql.= ' (fk_supplier_proposal, fk_parent_line, label, description, fk_product, product_type,'; + $sql.= ' date_start, date_end,'; $sql.= ' fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; $sql.= ' subprice, remise_percent, '; $sql.= ' info_bits, '; @@ -3040,6 +3017,8 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " '".$this->db->escape($this->desc)."',"; $sql.= " ".($this->fk_product?"'".$this->db->escape($this->fk_product)."'":"null").","; $sql.= " '".$this->db->escape($this->product_type)."',"; + $sql.= " ".($this->date_start ? "'".$this->db->idate($this->date_start)."'" : "null").","; + $sql.= " ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null").","; $sql.= " ".($this->fk_remise_except?"'".$this->db->escape($this->fk_remise_except)."'":"null").","; $sql.= " ".price2num($this->qty).","; $sql.= " ".price2num($this->tva_tx).","; @@ -3073,8 +3052,7 @@ class SupplierProposalLine extends CommonObjectLine $resql=$this->db->query($sql); if ($resql) { - $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'supplier_proposaldet'); - $this->id=$this->rowid; + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'supplier_proposaldet'); if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { @@ -3120,7 +3098,7 @@ class SupplierProposalLine extends CommonObjectLine $error=0; $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."supplier_proposaldet WHERE rowid = ".$this->rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."supplier_proposaldet WHERE rowid = ".$this->id; dol_syslog("SupplierProposalLine::delete", LOG_DEBUG); if ($this->db->query($sql) ) { @@ -3128,7 +3106,6 @@ class SupplierProposalLine extends CommonObjectLine // Remove extrafields if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { - $this->id=$this->rowid; $result=$this->deleteExtraFields(); if ($result < 0) { @@ -3180,8 +3157,6 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->localtax2_type)) $this->localtax2_type=0; if (empty($this->marque_tx)) $this->marque_tx=0; if (empty($this->marge_tx)) $this->marge_tx=0; - if (empty($this->price)) $this->price=0; // TODO A virer - if (empty($this->remise)) $this->remise=0; // TODO A virer if (empty($this->remise_percent)) $this->remise_percent=0; if (empty($this->info_bits)) $this->info_bits=0; if (empty($this->special_code)) $this->special_code=0; @@ -3212,6 +3187,8 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " description='".$this->db->escape($this->desc)."'"; $sql.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); $sql.= " , product_type=".$this->product_type; + $sql.= " , date_start=".($this->date_start ? "'".$this->db->idate($this->date_start)."'" : "null"); + $sql.= " , date_end=".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null"); $sql.= " , tva_tx='".price2num($this->tva_tx)."'"; $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); @@ -3220,8 +3197,6 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " , qty='".price2num($this->qty)."'"; $sql.= " , subprice=".price2num($this->subprice).""; $sql.= " , remise_percent=".price2num($this->remise_percent).""; - $sql.= " , price=".price2num($this->price).""; // TODO A virer - $sql.= " , remise=".price2num($this->remise).""; // TODO A virer $sql.= " , info_bits='".$this->db->escape($this->info_bits)."'"; if (empty($this->skip_update_total)) { @@ -3245,7 +3220,7 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - $sql.= " WHERE rowid = ".$this->rowid; + $sql.= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql=$this->db->query($sql); @@ -3253,7 +3228,6 @@ class SupplierProposalLine extends CommonObjectLine { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $this->id=$this->rowid; $result=$this->insertExtraFields(); if ($result < 0) { @@ -3298,10 +3272,10 @@ class SupplierProposalLine extends CommonObjectLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposaldet SET"; - $sql.= " total_ht=".price2num($this->total_ht, 'MT').""; - $sql.= ",total_tva=".price2num($this->total_tva, 'MT').""; - $sql.= ",total_ttc=".price2num($this->total_ttc, 'MT').""; - $sql.= " WHERE rowid = ".$this->rowid; + $sql.= " total_ht=".price2num($this->total_ht, 'MT'); + $sql.= ",total_tva=".price2num($this->total_tva, 'MT'); + $sql.= ",total_ttc=".price2num($this->total_ttc, 'MT'); + $sql.= " WHERE rowid = ".$this->id; dol_syslog("SupplierProposalLine::update_total", LOG_DEBUG); diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 400b8452938..aac1bf88f60 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -234,8 +234,8 @@ class Tickets extends DolibarrApi $obj_ret = array(); - if (!$socid && DolibarrApiAccess::$user->societe_id) { - $socid = DolibarrApiAccess::$user->societe_id; + if (!$socid && DolibarrApiAccess::$user->socid) { + $socid = DolibarrApiAccess::$user->socid; } // If the internal user must only see his customers, force searching by him diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index f570dd21285..1344cdd9815 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -76,7 +76,7 @@ class Users extends DolibarrApi } // case of external user, $societe param is ignored and replaced by user's socid - //$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; + //$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe; $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."user as t"; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 38af5be87e4..47e3188f5ff 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -705,7 +705,7 @@ if ($action == 'addcontainer') getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl['content'], $action, 1, $grabimages, $grabimagesinto); include_once DOL_DOCUMENT_ROOT.'/core/class/lessc.class.php'; - $lesscobj = new lessc(); + $lesscobj = new Lessc(); try { $contentforlessc = ".bodywebsite {\n".$tmpgeturl['content']."\n}\n"; //print '
'.$contentforlessc.'
'; diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 37abbc9a2bd..f5068dc59ee 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -87,6 +87,8 @@ class AllTests $suite->addTestSuite('DateLibTest'); require_once dirname(__FILE__).'/UtilsTest.php'; $suite->addTestSuite('UtilsTest'); + require_once dirname(__FILE__).'/LesscTest.php'; + $suite->addTestSuite('LesscTest'); //require_once dirname(__FILE__).'/DateLibTzFranceTest.php'; //$suite->addTestSuite('DateLibTzFranceTest'); require_once dirname(__FILE__).'/MarginsLibTest.php'; diff --git a/test/phpunit/LesscTest.php b/test/phpunit/LesscTest.php new file mode 100644 index 00000000000..70ed161c260 --- /dev/null +++ b/test/phpunit/LesscTest.php @@ -0,0 +1,181 @@ + + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file test/phpunit/LessTest.php + * \ingroup test + * \brief PHPUnit test + * \remarks To run this script as CLI: phpunit filename.php + */ + +global $conf,$user,$langs,$db; +//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver +//require_once 'PHPUnit/Autoload.php'; +require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; +require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; + +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +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 there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) + +if (empty($user->id)) +{ + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); +} +$conf->global->MAIN_DISABLE_ALL_MAILS=1; + + +/** + * Class for PHPUnit tests + * + * @backupGlobals disabled + * @backupStaticAttributes enabled + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + */ +class LesscTest extends PHPUnit\Framework\TestCase +{ + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; + + /** + * Constructor + * We save global variables into local variables + * + * @return SecurityTest + */ + public function __construct() + { + parent::__construct(); + + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; + } + + // tear down after class + public static function tearDownAfterClass() + { + global $conf,$user,$langs,$db; + $db->rollback(); + + print __METHOD__."\n"; + } + + /** + * Init phpunit tests + * + * @return void + */ + protected function setUp() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + print __METHOD__."\n"; + } + + /** + * End phpunit tests + * + * @return void + */ + protected function tearDown() + { + print __METHOD__."\n"; + } + + /** + * testLess + * + * @return string + */ + public function testLessc() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + include_once DOL_DOCUMENT_ROOT.'/core/class/lessc.class.php'; + + $lesscobj = new Lessc(); + + $cssfile = " + a { font-size: 10px; } + b .test { + font-size: 10px; + } + "; + + try { + $contentforlessc = ".bodywebsite {\n".$cssfile."\n}\n"; + //print '
'.$contentforlessc.'
'; + $result = $lesscobj->compile($contentforlessc); + //var_dump($contentforlessc); exit; + } catch (exception $e) { + //echo "failed to compile lessc"; + dol_syslog("Failed to compile the CSS with lessc: ".$e->getMessage(), LOG_WARNING); + } + + $cssexpected = " +.bodywebsite a { + font-size: 10px; +} +.bodywebsite b .test { + font-size: 10px; +} +"; + + print __METHOD__." SeparatorDecimal=".$result."\n"; + $this->assertEquals(trim($result), trim($cssexpected)); + + return; + } +}