diff --git a/ChangeLog b/ChangeLog index b641ec2029e..e0f4159c49e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -128,6 +128,7 @@ NEW: Upgrade jquery lib to 3.3.1 NEW: Add hook 'addHtmlHeader()' NEW: Add hook 'createRecurringInvoices()' NEW: Add hook 'afterSelectContactOptions' +NEW: Add hook 'getAccessForbiddenMessage' NEW: Add hook support in accountancy index NEW: Add hook support in list of template invoices NEW: Add parameter 'replaceambiguouschars' on getRandomPassword function diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 073d180cd16..7de500ba690 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -447,11 +447,11 @@ $listofformat=AccountancyExport::getType(); if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList"); else $buttonLabel = $langs->trans("ExportList"); -$newcardbutton = dolGetButtonTitle($buttonLabel, '', 'fa fa-file-export', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'')); +$newcardbutton = dolGetButtonTitle($buttonLabel, '', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'')); -$newcardbutton.= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-object-group', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param); +$newcardbutton.= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param); -$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle', './card.php?action=create'); +$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create'); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index a2cf4864df8..0b9bebcea78 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -256,8 +256,8 @@ if ($action == 'delbookkeepingyear') { print '
'; -$newcardbutton.= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); -$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle', './card.php?action=create'); +$newcardbutton.= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); +$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create'); if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index aa8161b9c52..039b7076c3e 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -143,9 +143,9 @@ $textnextyear = ' trans("DescVentilCustomer") . '
'; +print ''.$langs->trans("DescVentilCustomer") . '
'; print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; -print '
'; +print '

'; $y = $year_current; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index f7a53c9e210..83bceb04026 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -294,7 +294,7 @@ if ($result) { print ''; print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print $langs->trans("DescVentilDoneCustomer") . '
'; + print ''.$langs->trans("DescVentilDoneCustomer") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 4b3906d60da..61c22eb2912 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -356,7 +356,7 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print $langs->trans("DescVentilTodoCustomer") . '

'; + print ''.$langs->trans("DescVentilTodoCustomer") . '

'; /*$topicmail="Information"; $modelmail="project"; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index e350a3011a0..696f947b63f 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -139,9 +139,9 @@ $textnextyear = ' 
trans("DescVentilExpenseReport") . '
'; +print ''.$langs->trans("DescVentilExpenseReport") . '
'; print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; -print '
'; +print '

'; $y = $year_current; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 3a322c07ef3..734bbfb65d2 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -248,7 +248,7 @@ if ($result) { print_barre_liste($langs->trans("ExpenseReportLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print $langs->trans("DescVentilDoneExpenseReport") . '
'; + print ''.$langs->trans("DescVentilDoneExpenseReport") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 4f037f3c72b..4c739a218b9 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -289,7 +289,7 @@ if ($result) { print_barre_liste($langs->trans("ExpenseReportLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print $langs->trans("DescVentilTodoExpenseReport") . '

'; + print ''.$langs->trans("DescVentilTodoExpenseReport") . '

'; /*$topicmail="Information"; $modelmail="project"; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 6bbc4ad9c62..12e76882adc 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -743,6 +743,7 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { + print '
'; print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 25c53863162..08df2e71b32 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -680,6 +680,7 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { + print '
'; print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); } diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index ab85507a7b4..6f178c755d3 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -140,9 +140,9 @@ $textnextyear = ' 
trans("DescVentilSupplier") . '
'; +print ''.$langs->trans("DescVentilSupplier") . '
'; print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; -print '
'; +print '

'; $y = $year_current; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 4af51060b4b..9b704e21eb3 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -297,7 +297,7 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print $langs->trans("DescVentilDoneSupplier") . '
'; + print ''.$langs->trans("DescVentilDoneSupplier") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 27cccdb7eb2..47e3570bcbe 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -355,7 +355,7 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print $langs->trans("DescVentilTodoCustomer") . '

'; + print ''.$langs->trans("DescVentilTodoCustomer") . '

'; /*$topicmail="Information"; $modelmail="project"; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 32398f05ada..a6be1d181c5 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2018 Laurent Destailleur +/* Copyright (C) 2001-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2011-2017 Philippe Grand @@ -588,9 +588,8 @@ if ($action == 'edit' || $action == 'updateedit') print ''.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").''; print "\n"; - print ''; - print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START, 'SOCIETE_FISCAL_MONTH_START', 0, 1) . ''; + print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START, 'SOCIETE_FISCAL_MONTH_START', 0, 1, 'maxwidth100') . ''; print ""; diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index dd14bb2eb67..569409fe91a 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -48,6 +48,17 @@ if (! empty($conf->syslog->enabled)) */ if ($action=='purge' && ! preg_match('/^confirm/i', $choice) && ($choice != 'allfiles' || $confirm == 'yes') ) { + // Increase limit of time. Works only if we are not in safe mode + $ExecTimeLimit=600; + if (!empty($ExecTimeLimit)) + { + $err=error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); + } + require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php'; $utils = new Utils($db); $result = $utils->purgeFiles($choice); diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index 61be1ad51d6..1de1030dec9 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -145,7 +145,7 @@ if ($object->id) } else { - accessforbidden('', 0, 0); + accessforbidden('', 0, 1); } // End of page diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index 012094fbb05..3cc042941b2 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -143,7 +143,7 @@ if ($object->id) } else { - accessforbidden('', 0, 0); + accessforbidden('', 0, 1); } // End of page diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 8442a640fc0..e7083e767a2 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -41,6 +41,12 @@ class BOM extends CommonObject */ public $table_element = 'bom_bom'; + /** + * @var string Name of subtable if this object has sub lines + */ + public $table_element_line = 'bom_bomline'; + public $fk_element = 'fk_bom'; + /** * @var int Does bom support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ @@ -57,9 +63,6 @@ class BOM extends CommonObject public $picto = 'bom'; - public $table_element_line = 'bom_bomline'; - - const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; const STATUS_CANCELED = 9; @@ -222,7 +225,13 @@ class BOM extends CommonObject $this->db->begin(); // Load source object - $object->fetchCommon($fromid); + $result = $object->fetchCommon($fromid); + if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines(); + + // Get lines so they will be clone + //foreach($object->lines as $line) + // $line->fetch_optionals(); + // Reset some properties unset($object->id); unset($object->fk_user_creat); @@ -231,7 +240,7 @@ class BOM extends CommonObject // Clear fields $object->ref = "copy_of_".$object->ref; $object->title = $langs->trans("CopyOf")." ".$object->title; - // ... + // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { @@ -256,6 +265,29 @@ class BOM extends CommonObject $this->errors = $object->errors; } + if (! $error) + { + // copy internal contacts + if ($this->copy_linked_contact($object, 'internal') < 0) + { + $error++; + } + } + + if (! $error) + { + // copy external contacts if same company + if (property_exists($this, 'socid') && $this->socid == $object->socid) + { + if ($this->copy_linked_contact($object, 'external') < 0) + $error++; + } + } + + // If there is lines, create lines too + + + unset($object->context['createfromclone']); // End @@ -854,7 +886,7 @@ class BOM extends CommonObject $this->lines=array(); $objectline = new BOMLine($this->db); - $result = $objectline->fetchAll('', '', 0, 0, array('customsql'=>'fk_bom = '.$this->id)); + $result = $objectline->fetchAll('ASC', 'rank', 0, 0, array('customsql'=>'fk_bom = '.$this->id)); if (is_numeric($result)) { @@ -1071,71 +1103,6 @@ class BOMLine extends CommonObject return $this->createCommon($user, $notrigger); } - /** - * Clone an object into another one - * - * @param User $user User that creates - * @param int $fromid Id of object to clone - * @return mixed New object created, <0 if KO - */ - public function createFromClone(User $user, $fromid) - { - global $langs, $hookmanager, $extrafields; - $error = 0; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $object = new self($this->db); - - $this->db->begin(); - - // Load source object - $object->fetchCommon($fromid); - // Reset some properties - unset($object->id); - unset($object->fk_user_creat); - unset($object->import_key); - - // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - // ... - // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) - { - $extrafields->fetch_name_optionals_label($this->element); - foreach($object->array_options as $key => $option) - { - $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) - { - //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; - unset($object->array_options[$key]); - } - } - } - - // Create clone - $object->context['createfromclone'] = 'createfromclone'; - $result = $object->createCommon($user); - if ($result < 0) { - $error++; - $this->error = $object->error; - $this->errors = $object->errors; - } - - unset($object->context['createfromclone']); - - // End - if (!$error) { - $this->db->commit(); - return $object; - } else { - $this->db->rollback(); - return -1; - } - } - /** * Load object in memory from the database * diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index d3fb1f7607b..6df0362d1c4 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -57,7 +57,7 @@ $domData .= ' data-qty="'.$line->qty.'"'; $domData .= ' data-product_type="'.$line->product_type.'"'; // Lines for extrafield -$objectline = new BOMLine($this->db); +$objectline = new BOMLine($object->db); ?> @@ -68,12 +68,9 @@ $objectline = new BOMLine($this->db);
textwithtooltip($text, $description, 3, '', '', $i, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) - { - print (! empty($line->description) && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; - } + $tmpproduct = new Product($object->db); + $tmpproduct->fetch($line->fk_product); + print $tmpproduct->getNomUrl(1); ?> diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index d804cced41c..16cba59ca4a 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -65,7 +65,11 @@ $arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css') llxHeader('', $title, '', '', 0, 0, $arrayofjs, $arrayofcss); -$newcardbutton.= dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/categories/card.php?action=create&type='.$type.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type)); + +$newcardbutton=''; +if (! empty($user->rights->categorie->creer)) { + $newcardbutton.= dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/categories/card.php?action=create&type='.$type.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type)); +} print load_fiche_titre($title, $newcardbutton); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index c8cba5c3dda..7331d7a86e9 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -321,7 +321,7 @@ if (empty($reshook)) $datep = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $date_delivery = dol_mktime(12, 0, 0, GETPOST('date_livraisonmonth'), GETPOST('date_livraisonday'), GETPOST('date_livraisonyear')); - $duration = GETPOST('duree_validite'); + $duration = GETPOST('duree_validite', 'int'); if (empty($datep)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); @@ -1622,7 +1622,7 @@ if ($action == 'create') print ''; // Validaty duration - print '' . $langs->trans("ValidityDuration") . ' ' . $langs->trans("days") . ''; + print '' . $langs->trans("ValidityDuration") . ' ' . $langs->trans("days") . ''; // Terms of payment print '' . $langs->trans('PaymentConditionsShort') . ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6217caa4710..0f2669014a8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1408,8 +1408,9 @@ if (empty($reshook)) { // Don't add lines with qty 0 when coming from a shipment including all order lines if($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; - // Don't add closed lines when coming from a contract - if($srcobject->element == 'contrat' && $lines[$i]->statut == 5) continue; + // Don't add closed lines when coming from a contract (Set constant to '0,5' to exclude also inactive lines) + if (! isset($conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '5'; + if ($srcobject->element == 'contrat' && in_array($lines[$i]->statut, explode(',', $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE))) continue; $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); @@ -3382,7 +3383,9 @@ elseif ($id > 0 || ! empty($ref)) $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); if ($user->societe_id > 0 && $user->societe_id != $object->socid) - accessforbidden('', 0); + { + accessforbidden('', 0, 1); + } $result = $object->fetch_thirdparty(); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index ab141f028bd..920acd1c22f 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -848,7 +848,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie */ if (! GETPOST('action', 'aZ09')) { - if ($page == -1) $page = 0 ; + if (empty($page) || $page == -1) $page = 0; $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $offset = $limit * $page ; diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 1025f7b11ed..086c5795955 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -55,7 +55,7 @@ $result = restrictedArea($user, 'tax', $id, 'chargesociales', 'charges'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); -if ($page == -1) { +if (empty($page) || $page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index fe31f68380a..cd17fbba233 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -318,7 +318,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) $case = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage), "%Y-%m"); $caseprev = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage-1), "%Y-%m"); - if ($annee >= $year_start) + if ($annee >= $year_start) // We ignore $annee < $year_start, we loop on it to be able to make delta, nothing is output. { if ($modecompta == 'CREANCES-DETTES') { // Valeur CA du mois w/o VAT @@ -386,11 +386,12 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) else { print ' '; } print ''; } - if ($annee_decalage != $year_end) print ' '; + + if ($annee_decalage < $year_end || ($annee_decalage == $year_end && $mois > 12 && $annee < $year_end)) print ' '; } - $total_ht[$annee]+=!empty($cum_ht[$case]) ? $cum_ht[$case] : 0; - $total[$annee]+=$cum[$case]; + $total_ht[$annee] += ((! empty($cum_ht[$case])) ? $cum_ht[$case] : 0); + $total[$annee] += $cum[$case]; } print ''; diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 78a1029b2f4..1a3dc9d7dcc 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -56,9 +56,10 @@ $result = restrictedArea($user, 'tax', $id, 'vat', 'charges'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); -if ($page == -1) { +if (empty($page) || $page == -1) { $page = 0; } + $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 40529413bbe..20e4d6a03ca 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -244,7 +244,6 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd) $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); // ... - $result=$objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); if (is_object($result) || $result > 0) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 65e2b22d0e7..d4f26a377b5 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -563,14 +563,16 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $objecttmp->socid = $cmd->socid; $objecttmp->type = Facture::TYPE_STANDARD; - $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; - $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; - $objecttmp->fk_project = $cmd->fk_project; + $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; + $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; + $objecttmp->fk_project = $cmd->fk_project; + $objecttmp->multicurrency_code = $cmd->multicurrency_code; + if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; - $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (empty($datefacture)) { - $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y")); + $datefacture = dol_now(); } $objecttmp->date = $datefacture; diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 7270409a47a..2e2c8891b62 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -20,6 +20,11 @@ * \file htdocs/core/ajax/row.php * \brief File to return Ajax response on Row move. * This ajax page is called when doing an up or down drag and drop. + * Parameters: + * roworder (Example: '1,3,2,4'), + * table_element_line (Example: 'commandedet') + * fk_element (Example: 'fk_order') + * element_id (Example: 1) */ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disable token renewal diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9852e2f2fb0..a709d502d93 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2443,8 +2443,9 @@ abstract class CommonObject */ public function updateRangOfLine($rowid, $rang) { - $fieldposition = 'rang'; + $fieldposition = 'rang'; // @TODO Rename 'rang' and 'position' into 'rank' if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; + if (in_array($this->table_element_line, array('bom_bomline'))) $fieldposition = 'rank'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; $sql.= ' WHERE rowid = '.$rowid; @@ -3886,6 +3887,7 @@ abstract class CommonObject { $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_create.tpl.php'; } + if (empty($conf->file->strict_mode)) { $res=@include $tpl; } else { @@ -4086,6 +4088,7 @@ abstract class CommonObject { $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_view.tpl.php'; } + if (empty($conf->file->strict_mode)) { $res=@include $tpl; } else { @@ -4116,6 +4119,7 @@ abstract class CommonObject { $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_edit.tpl.php'; } + if (empty($conf->file->strict_mode)) { $res=@include $tpl; } else { @@ -4191,9 +4195,10 @@ abstract class CommonObject * @param CommonObjectLine $line Line * @param string $var Var * @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not) + * @param string $defaulttpldir Directory where to find the template * @return void */ - public function printOriginLine($line, $var, $restrictlist = '') + public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir = '/core/tpl') { global $langs, $conf; @@ -4314,7 +4319,7 @@ abstract class CommonObject // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer - $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + $dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); foreach($dirtpls as $module => $reldir) { if (!empty($module)) @@ -4325,6 +4330,7 @@ abstract class CommonObject { $tpl = DOL_DOCUMENT_ROOT.$reldir.'/originproductline.tpl.php'; } + if (empty($conf->file->strict_mode)) { $res=@include $tpl; } else { @@ -7245,6 +7251,31 @@ abstract class CommonObject if ($result < 0) $error++; } + // Create lines + if (! empty($this->table_element_line) && ! empty($this->fk_element)) + { + $num=(is_array($this->lines) ? count($this->lines) : 0); + for ($i = 0; $i < $num; $i++) + { + $line = $this->lines[$i]; + + $keyforparent = $this->fk_element; + $line->$keyforparent = $this->id; + + // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array + //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. + if (! is_object($line)) $line = (object) $line; + + $result = $line->create($user, 1); + if ($result < 0) + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + } + // Triggers if (! $error && ! $notrigger) { diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index f23aa1da5a3..f1abc148291 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -165,11 +165,12 @@ class HookManager 'formattachOptions', 'formBuilddocLineOptions', 'formatNotificationMessage', - 'getFormMail', - 'getIdProfUrl', + 'getAccessForbiddenMessage', 'getDirList', - 'getFormatedCustomerRef', + 'getFormMail', + 'getFormatedCustomerRef', 'getFormatedSupplierRef', + 'getIdProfUrl', 'moveUploadedFile', 'moreHtmlStatus', 'pdf_build_address', diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 19b39fd776d..a25fd098f9a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5274,10 +5274,10 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart) /** * Creation of a directory (this can create recursive subdir) * - * @param string $dir Directory to create (Separator must be '/'. Example: '/mydir/mysubdir') - * @param string $dataroot Data root directory (To avoid having the data root in the loop. Using this will also lost the warning on first dir PHP has no permission when open_basedir is used) - * @param int $newmask Mask for new file (Defaults to $conf->global->MAIN_UMASK or 0755 if unavailable). Example: '0444' - * @return int < 0 if KO, 0 = already exists, > 0 if OK + * @param string $dir Directory to create (Separator must be '/'. Example: '/mydir/mysubdir') + * @param string $dataroot Data root directory (To avoid having the data root in the loop. Using this will also lost the warning on first dir PHP has no permission when open_basedir is used) + * @param string|null $newmask Mask for new file (Defaults to $conf->global->MAIN_UMASK or 0755 if unavailable). Example: '0444' + * @return int < 0 if KO, 0 = already exists, > 0 if OK */ function dol_mkdir($dir, $dataroot = '', $newmask = null) { diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 0dbbb7f0829..dcdc70c3fe6 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -659,7 +659,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand */ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0) { - global $conf, $db, $user, $langs; + global $conf, $db, $user, $langs, $hookmanager; if (! is_object($langs)) { include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; @@ -681,14 +681,27 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho print '
'; if (empty($showonlymessage)) { - if ($user->login) + global $action, $object; + if (empty($hookmanager)) { - print $langs->trans("CurrentLogin").': '.$user->login.'
'; - print $langs->trans("ErrorForbidden2", $langs->trans("Home"), $langs->trans("Users")); + $hookmanager = new HookManager($db); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + $hookmanager->initHooks(array('main')); } - else + $parameters = array('message'=>$message); + $reshook=$hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + print $hookmanager->resPrint; + if (empty($reshook)) { - print $langs->trans("ErrorForbidden3"); + if ($user->login) + { + print $langs->trans("CurrentLogin").': '.$user->login.'
'; + print $langs->trans("ErrorForbidden2", $langs->transnoentitiesnoconv("Home"), $langs->transnoentitiesnoconv("Users")); + } + else + { + print $langs->trans("ErrorForbidden3"); + } } } if ($printfooter && function_exists("llxFooter")) llxFooter(); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 3710cc2cf91..3073ffe6032 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1153,35 +1153,67 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $permtoshowmenu=(! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire); //$newmenu->add("/accountancy/index.php?leftmenu=accountancy", $langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy'); + // Configuration + $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"), 0, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/', $leftmenu)) { + $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_general', 10); + + // Fiscal year - Not really yet used. In a future will lock some periods. + if ($conf->global->MAIN_FEATURES_LEVEL > 1) { + $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 1, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear', 20); + } + + $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 30); + $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 40); + $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 41); + $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 50); + $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 60); + if (! empty($conf->banque->enabled)) { + $newmenu->add("/compta/bank/list.php?mainmenu=accountancy&leftmenu=accountancy_admin&search_status=-1", $langs->trans("MenuBankAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_bank', 70); + } + if (! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)) { + $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 80); + } + if (! empty($conf->tax->enabled)) { + $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 90); + } + if (! empty($conf->expensereport->enabled)) { + $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 100); + } + $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 110); + $newmenu->add("/accountancy/admin/closure.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuClosureAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_closure', 120); + $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 130); + } + // Transfer in accounting $newmenu->add("/accountancy/index.php?leftmenu=accountancy_transfer", $langs->trans("TransferInAccounting"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'transfer', 1); - // Binding - // $newmenu->add("", $langs->trans("Binding"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch'); - if (! empty($conf->facture->enabled)) - { - $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy", $langs->trans("CustomersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer'); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/', $leftmenu)) { - $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); - $newmenu->add("/accountancy/customer/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); - } - } - if (! empty($conf->supplier_invoice->enabled)) - { - $newmenu->add("/accountancy/supplier/index.php?leftmenu=accountancy_dispatch_supplier&mainmenu=accountancy", $langs->trans("SuppliersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_supplier'); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_supplier/', $leftmenu)) { - $newmenu->add("/accountancy/supplier/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); - $newmenu->add("/accountancy/supplier/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); - } - } - if (! empty($conf->expensereport->enabled)) - { - $newmenu->add("/accountancy/expensereport/index.php?leftmenu=accountancy_dispatch_expensereport&mainmenu=accountancy", $langs->trans("ExpenseReportsVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_expensereport'); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_expensereport/', $leftmenu)) { - $newmenu->add("/accountancy/expensereport/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); - $newmenu->add("/accountancy/expensereport/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); - } - } + // Binding + // $newmenu->add("", $langs->trans("Binding"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch'); + if (! empty($conf->facture->enabled)) + { + $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy", $langs->trans("CustomersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer'); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/', $leftmenu)) { + $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); + $newmenu->add("/accountancy/customer/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); + } + } + if (! empty($conf->supplier_invoice->enabled)) + { + $newmenu->add("/accountancy/supplier/index.php?leftmenu=accountancy_dispatch_supplier&mainmenu=accountancy", $langs->trans("SuppliersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_supplier'); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_supplier/', $leftmenu)) { + $newmenu->add("/accountancy/supplier/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); + $newmenu->add("/accountancy/supplier/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); + } + } + if (! empty($conf->expensereport->enabled)) + { + $newmenu->add("/accountancy/expensereport/index.php?leftmenu=accountancy_dispatch_expensereport&mainmenu=accountancy", $langs->trans("ExpenseReportsVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_expensereport'); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_expensereport/', $leftmenu)) { + $newmenu->add("/accountancy/expensereport/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); + $newmenu->add("/accountancy/expensereport/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); + } + } // Journals if(! empty($conf->accounting->enabled) && ! empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') @@ -1292,38 +1324,6 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM //$newmenu->add("/compta/stats/byratecountry.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByVatRate"),3,$user->rights->accounting->comptarapport->lire); } } - - // Configuration - $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"), 0, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/', $leftmenu)) { - $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_general', 10); - - // Fiscal year - Not really yet used. In a future will lock some periods. - if ($conf->global->MAIN_FEATURES_LEVEL > 1) { - $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 1, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear', 20); - } - - $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 30); - $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 40); - $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 41); - $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 50); - $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 60); - if (! empty($conf->banque->enabled)) { - $newmenu->add("/compta/bank/list.php?mainmenu=accountancy&leftmenu=accountancy_admin&search_status=-1", $langs->trans("MenuBankAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_bank', 70); - } - if (! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)) { - $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 80); - } - if (! empty($conf->tax->enabled)) { - $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 90); - } - if (! empty($conf->expensereport->enabled)) { - $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 100); - } - $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 110); - $newmenu->add("/accountancy/admin/closure.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuClosureAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_closure', 120); - $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 130); - } } // Accountancy (simple) diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index 2694b852b7a..405ad3161a8 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -136,8 +136,8 @@ class modReceiptPrinter extends DolibarrModules // Clean before activation $this->remove($options); $sql = array( - "CREATE TABLE IF NOT EXISTS llx_printer_receipt (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), fk_type integer, fk_profile integer, parameter varchar(128), entity integer) ENGINE=innodb;", - "CREATE TABLE IF NOT EXISTS llx_printer_receipt_template (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), template text, entity integer) ENGINE=innodb;", + "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), fk_type integer, fk_profile integer, parameter varchar(128), entity integer) ENGINE=innodb;", + "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt_template (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), template text, entity integer) ENGINE=innodb;", ); return $this->_init($sql, $options); } diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 230d9dd5fbe..f3864525d8d 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -345,7 +345,7 @@ class modStock extends DolibarrModules 'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10" ); $this->import_run_sql_after_array[$r]=array( // Because we may change data that are denormalized, we must update dernormalized data after. - 'UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid);' + 'UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);' ); } diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index f45d4009d05..640267e25da 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -799,7 +799,7 @@ if (empty($action) || $action == 'list') $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page=GETPOST("page", 'int'); - if ($page == -1 || $page == null) { $page = 0 ; } + if (empty($page) || $page == -1) { $page = 0; } $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index 5e6413abb45..2918a8d95ab 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -54,7 +54,7 @@ $sortfield = GETPOST("sortfield"); if (!$sortorder) $sortorder="DESC"; if (!$sortfield) $sortfield="e.rowid"; -if ($page == -1) { +if (empty($page) || $page == -1) { $page = 0 ; } diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 81a1e315751..96b1f68fa9a 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -227,6 +227,7 @@ CREATE TABLE llx_bom_bom( ) ENGINE=innodb; ALTER TABLE llx_bom_bom ADD COLUMN efficiency double(8,4) DEFAULT 1; +ALTER TABLE llx_bom_bom ADD COLUMN entity integer DEFAULT 1 NOT NULL; create table llx_bom_bom_extrafields ( @@ -272,6 +273,10 @@ ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_rowid (rowid); ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_product (fk_product); ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_bom (fk_bom); +ALTER TABLE llx_bom_bom ADD UNIQUE INDEX uk_bom_bom_ref(ref, entity); +ALTER TABLE llx_bom_bomline ADD CONSTRAINT llx_bom_bomline_fk_bom FOREIGN KEY (fk_bom) REFERENCES llx_bom_bom(rowid); + + ALTER TABLE llx_product_fournisseur_price ADD COLUMN barcode varchar(180) DEFAULT NULL; ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_barcode_type integer DEFAULT NULL; ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_barcode (barcode); diff --git a/htdocs/install/mysql/tables/llx_bom_bom.key.sql b/htdocs/install/mysql/tables/llx_bom_bom.key.sql index 72631851e1b..aed37c7ce47 100644 --- a/htdocs/install/mysql/tables/llx_bom_bom.key.sql +++ b/htdocs/install/mysql/tables/llx_bom_bom.key.sql @@ -22,7 +22,7 @@ ALTER TABLE llx_bom_bom ADD INDEX idx_bom_bom_status (status); ALTER TABLE llx_bom_bom ADD INDEX idx_bom_bom_fk_product (fk_product); -- END MODULEBUILDER INDEXES ---ALTER TABLE llx_bom_bom ADD UNIQUE INDEX uk_bom_bom_fieldxy(fieldx, fieldy); +ALTER TABLE llx_bom_bom ADD UNIQUE INDEX uk_bom_bom_ref(ref, entity); --ALTER TABLE llx_bom_bom ADD CONSTRAINT llx_bom_bom_fk_field FOREIGN KEY (fk_field) REFERENCES llx_bom_myotherobject(rowid); diff --git a/htdocs/install/mysql/tables/llx_bom_bomline.key.sql b/htdocs/install/mysql/tables/llx_bom_bomline.key.sql index 89c65f78644..ee8eaaeeb6c 100644 --- a/htdocs/install/mysql/tables/llx_bom_bomline.key.sql +++ b/htdocs/install/mysql/tables/llx_bom_bomline.key.sql @@ -22,5 +22,5 @@ ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_bom (fk_bom); --ALTER TABLE llx_bom_bomline ADD UNIQUE INDEX uk_bom_bomline_fieldxy(fieldx, fieldy); ---ALTER TABLE llx_bom_bomline ADD CONSTRAINT llx_bom_bomline_fk_field FOREIGN KEY (fk_field) REFERENCES llx_bom_myotherobject(rowid); +ALTER TABLE llx_bom_bomline ADD CONSTRAINT llx_bom_bomline_fk_bom FOREIGN KEY (fk_bom) REFERENCES llx_bom_bom(rowid); diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index d55cdd7d01f..b241c8729a7 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -847,7 +847,7 @@ if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) if ($resql2) { // We update product_stock, so we must field stock into product too. - $sql3='UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid)'; + $sql3='UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid)'; $resql3=$db->query($sql3); if (! $resql3) { diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index b5d05a4dd4a..c932b2631e8 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -699,8 +699,8 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; $sql.= " bu2.url_id as socid"; $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; - $sql.= " LEFT JOIN llx_paiement_facture as pf ON pf.fk_paiement = p.rowid"; - $sql.= " LEFT JOIN llx_bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')"; $sql.= " WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid"; $sql.= " AND b.rappro = 1"; $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; @@ -826,8 +826,8 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; $sql.= " bu2.url_id as socid"; $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; - $sql.= " LEFT JOIN llx_paiement_facture as pf ON pf.fk_paiement = p.rowid"; - $sql.= " LEFT JOIN llx_bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')"; $sql.= " WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid"; $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; @@ -1143,7 +1143,7 @@ function migrate_contracts_date1($db, $langs, $conf) print '
'; print ''.$langs->trans('MigrationContractsEmptyDatesUpdate')."
\n"; - $sql="update llx_contrat set date_contrat=tms where date_contrat is null"; + $sql="update ".MAIN_DB_PREFIX."contrat set date_contrat=tms where date_contrat is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); if (! $resql) dol_print_error($db); @@ -1152,7 +1152,7 @@ function migrate_contracts_date1($db, $langs, $conf) else print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')."
\n"; - $sql="update llx_contrat set datec=tms where datec is null"; + $sql="update ".MAIN_DB_PREFIX."contrat set datec=tms where datec is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); if (! $resql) dol_print_error($db); @@ -1243,7 +1243,7 @@ function migrate_contracts_date3($db, $langs, $conf) print '
'; print ''.$langs->trans('MigrationContractsIncoherentCreationDateUpdate')."
\n"; - $sql="update llx_contrat set datec=date_contrat where datec is null or datec > date_contrat"; + $sql="update ".MAIN_DB_PREFIX."contrat set datec=date_contrat where datec is null or datec > date_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_date3"); $resql = $db->query($sql); if (! $resql) dol_print_error($db); @@ -1270,7 +1270,7 @@ function migrate_contracts_open($db, $langs, $conf) print '
'; print ''.$langs->trans('MigrationReopeningContracts')."
\n"; - $sql = "SELECT c.rowid as cref FROM llx_contrat as c, llx_contratdet as cd"; + $sql = "SELECT c.rowid as cref FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."contratdet as cd"; $sql.= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_open"); $resql = $db->query($sql); @@ -2003,7 +2003,7 @@ function migrate_modeles($db, $langs, $conf) if (count($modellist)==0) { // Aucun model par defaut. - $sql=" insert into llx_document_model(nom,type) values('crabe','invoice')"; + $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')"; $resql = $db->query($sql); if (! $resql) dol_print_error($db); } @@ -2016,7 +2016,7 @@ function migrate_modeles($db, $langs, $conf) if (count($modellist)==0) { // Aucun model par defaut. - $sql=" insert into llx_document_model(nom,type) values('einstein','order')"; + $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')"; $resql = $db->query($sql); if (! $resql) dol_print_error($db); } @@ -2029,7 +2029,7 @@ function migrate_modeles($db, $langs, $conf) if (count($modellist)==0) { // Aucun model par defaut. - $sql=" insert into llx_document_model(nom,type) values('rouget','shipping')"; + $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')"; $resql = $db->query($sql); if (! $resql) dol_print_error($db); } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 20b9862e187..a7f6cfd87de 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -107,7 +107,7 @@ ExpenseReportsVentilation=Expense report binding CreateMvts=Create new transaction UpdateMvts=Modification of a transaction ValidTransaction=Validate transaction -WriteBookKeeping=Journalize transactions in Ledger +WriteBookKeeping=Register transactions in Ledger Bookkeeping=Ledger AccountBalance=Account balance ObjectsRef=Source object ref diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index 0b7e23bbd3f..7544e1913e8 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -47,7 +47,7 @@ $result = restrictedArea($user, 'loan', $id, '', ''); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); -if ($page == -1) { +if (empty($page) || $page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index b0d34db43eb..319ee2dc363 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -401,13 +401,19 @@ if ((! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && ! empty($conf-> if (GETPOSTISSET('disablemodules')) $_SESSION["disablemodules"]=GETPOST('disablemodules', 'alpha'); if (! empty($_SESSION["disablemodules"])) { + $modulepartkeys = array('css', 'js', 'tabs', 'triggers', 'login', 'substitutions', 'menus', 'theme', 'sms', 'tpl', 'barcode', 'models', 'societe', 'hooks', 'dir', 'syslog', 'tpllinkable', 'contactelement', 'moduleforexternal'); + $disabled_modules=explode(',', $_SESSION["disablemodules"]); foreach($disabled_modules as $module) { if ($module) { - if (empty($conf->$module)) $conf->$module=new stdClass(); + if (empty($conf->$module)) $conf->$module=new stdClass(); // To avoid warnings $conf->$module->enabled=false; + foreach($modulepartkeys as $modulepartkey) + { + unset($conf->modules_parts[$modulepartkey][$module]); + } if ($module == 'fournisseur') // Special case { $conf->supplier_order->enabled=0; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index a3e1f43b619..266b8d1925f 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -46,6 +46,7 @@ class MyObject extends CommonObject * @var string Name of subtable if this object has sub lines */ //public $table_element_line = 'mymodule_myobjectline'; + //public $fk_element = 'fk_myobject'; /** * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -267,12 +268,19 @@ class MyObject extends CommonObject $this->db->begin(); // Load source object - $object->fetchCommon($fromid); + $result = $object->fetchCommon($fromid); + if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines(); + + // get lines so they will be clone + //foreach($this->lines as $line) + // $line->fetch_optionals(); + // Reset some properties unset($object->id); unset($object->fk_user_creat); unset($object->import_key); + // Clear fields $object->ref = "copy_of_".$object->ref; $object->title = $langs->trans("CopyOf")." ".$object->title; @@ -301,6 +309,25 @@ class MyObject extends CommonObject $this->errors = $object->errors; } + if (! $error) + { + // copy internal contacts + if ($this->copy_linked_contact($object, 'internal') < 0) + { + $error++; + } + } + + if (! $error) + { + // copy external contacts if same company + if (property_exists($this, 'socid') && $this->socid == $object->socid) + { + if ($this->copy_linked_contact($object, 'external') < 0) + $error++; + } + } + unset($object->context['createfromclone']); // End @@ -671,7 +698,7 @@ class MyObject extends CommonObject $this->lines=array(); $objectline = new MyObjectLine($this->db); - $result = $objectline->fetchAll('', '', 0, 0, array('customsql'=>'fk_myobject = '.$this->id)); + $result = $objectline->fetchAll('ASC', 'rank', 0, 0, array('customsql'=>'fk_myobject = '.$this->id)); if (is_numeric($result)) { @@ -756,4 +783,5 @@ class MyObject extends CommonObject class MyObjectLine { // To complete with content of an object MyObjectLine + // We should have a field rowid, fk_myobject and rank } diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 6c956826e4c..0f4df0012f4 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -158,7 +158,7 @@ if ($object->id) } else { - accessforbidden('', 0, 0); + accessforbidden('', 0, 1); } // End of page diff --git a/htdocs/public/ifttt/index.php b/htdocs/public/ifttt/index.php deleted file mode 100644 index 27a1b169c7c..00000000000 --- a/htdocs/public/ifttt/index.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/public/ifttt/index.php - * \ingroup ifttt - * \brief Page to IFTTT endpoint agenda - * http://127.0.0.1/dolibarr/public/ifttt/index.php?securekey=... - */ - -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); // This means this output page does not require to be logged. -if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - -// This is a wrapper, so header is empty - -/** - * Header function - * - * @return void - */ -function llxHeaderIFTTT() -{ - print 'IFTTT API'; -} -/** - * Footer function - * - * @return void - */ -function llxFooterIFTTT() -{ - print ''; -} - - -require '../../main.inc.php'; - -// Security check -if (empty($conf->ifttt->enabled)) accessforbidden('', 0, 0, 1); - -// Check config -if (empty($conf->global->IFTTT_DOLIBARR_ENDPOINT_SECUREKEY)) -{ - $user->getrights(); - - llxHeaderIFTTT(); - print '
Module Agenda was not configured properly.
'; - llxFooterIFTTT(); - exit; -} - -// Check exportkey -if (empty($_GET["securekey"]) || $conf->global->IFTTT_DOLIBARR_ENDPOINT_SECUREKEY != $_GET["securekey"]) -{ - $user->getrights(); - - llxHeaderIFTTT(); - print '
Bad value for securekey.
'; - llxFooterIFTTT(); - exit; -} - - -// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks -$hookmanager->initHooks(array('iftttapi')); - - -llxHeaderIFTTT(); -print '
TODO
'; -llxFooterIFTTT(); diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index d242b2df3c1..56c43556c6e 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -62,7 +62,7 @@ $listofvoters=explode(',', $_SESSION["savevoter"]); // Add comment if (GETPOST('ajoutcomment', 'alpha')) { - if (!$canbemodified) accessforbidden(); + if (!$canbemodified) accessforbidden('', 0, 0, 1); $error=0; @@ -97,7 +97,7 @@ if (GETPOST('ajoutcomment', 'alpha')) // Add vote if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // boutonp for chrome, boutonp_x for firefox { - if (!$canbemodified) accessforbidden(); + if (!$canbemodified) accessforbidden('', 0, 0, 1); //Si le nom est bien entré if (GETPOST('nom', 'nohtml')) @@ -220,7 +220,7 @@ if ($testmodifier) } } - if (!$canbemodified) accessforbidden(); + if (!$canbemodified) accessforbidden('', 0, 0, 1); $idtomodify=$_POST["idtomodify".$modifier]; $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs"; @@ -235,7 +235,7 @@ if ($testmodifier) $idcomment=GETPOST('deletecomment', 'int'); if ($idcomment) { - if (!$canbemodified) accessforbidden(); + if (!$canbemodified) accessforbidden('', 0, 0, 1); $resql = $object->deleteComment($idcomment); } diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 880c4feb7f5..44a727f6e4c 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -237,8 +237,7 @@ if ($action == 'create' || $object->fetch($id) > 0) if ($action == 'create' || $action == 'edit') { - if ( ! $user->rights->resource->write ) - accessforbidden('', 0); + if (! $user->rights->resource->write) accessforbidden('', 0, 1); // Create/Edit object diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 7adec8e6009..2f45be04542 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -547,13 +547,13 @@ class Dolresource extends CommonObject if ($limit) $sql.= $this->db->plimit($limit, $offset); dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); + $this->lines=array(); $resql=$this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); if ($num) { - $this->lines=array(); while ($obj = $this->db->fetch_object($resql)) { $line = new Dolresource($this->db); @@ -853,6 +853,8 @@ class Dolresource extends CommonObject $sql .= ' ORDER BY resource_type'; dol_syslog(get_class($this)."::getElementResources", LOG_DEBUG); + + $resources = array(); $resql = $this->db->query($sql); if ($resql) { @@ -904,7 +906,7 @@ class Dolresource extends CommonObject // phpcs:enable global $langs; - if (count($this->cache_code_type_resource)) return 0; // Cache deja charge + if (is_array($this->cache_code_type_resource) && count($this->cache_code_type_resource)) return 0; // Cache deja charge $sql = "SELECT rowid, code, label, active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_resource"; diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index f9fd60c3566..975b463da05 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -93,8 +93,6 @@ class FormResource $out = ''; $out.= ''; } - //$out.= ''; - //$out.= ''; if ($resourcestat) { diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 6765d2d7147..d9547ad441b 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -94,8 +94,7 @@ if (empty($arch)) $arch = 0; $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $page = GETPOST("page"); -$page = is_numeric($page) ? $page : 0; -$page = $page == -1 ? 0 : $page; +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/societe/notify/index.php b/htdocs/societe/notify/index.php index 197f3a84d3d..f4e5bd8554b 100644 --- a/htdocs/societe/notify/index.php +++ b/htdocs/societe/notify/index.php @@ -41,7 +41,7 @@ if ($sortfield == "") $sortfield="s.nom"; } -if ($page == -1 || $page == null) { $page = 0 ; } +if (empty($page) || $page == -1) { $page = 0 ; } $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php index bad8e58497b..ed689b4e966 100644 --- a/htdocs/ticket/agenda.php +++ b/htdocs/ticket/agenda.php @@ -86,11 +86,11 @@ if (!$user->rights->ticket->read) { // restrict access for externals users if ($user->societe_id > 0 && ($object->fk_soc != $user->societe_id)) { - accessforbidden('', 0); + accessforbidden(); } // or for unauthorized internals users if (!$user->societe_id && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { - accessforbidden('', 0); + accessforbidden(); } diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 475c9f5beae..94c0aec8d90 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -647,7 +647,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd { // or for unauthorized internals users if (!$user->societe_id && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { - accessforbidden('', 0); + accessforbidden('', 0, 1); } // Confirmation close diff --git a/htdocs/ticket/document.php b/htdocs/ticket/document.php index 16fabc6943c..779b97657e1 100644 --- a/htdocs/ticket/document.php +++ b/htdocs/ticket/document.php @@ -196,7 +196,7 @@ if ($object->id) } else { - accessforbidden('', 0, 0); + accessforbidden('', 0, 1); } // End of page diff --git a/htdocs/user/document.php b/htdocs/user/document.php index 63d527dc33c..91d0e7219ce 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -174,7 +174,7 @@ if ($object->id) } else { - accessforbidden('', 0, 0); + accessforbidden('', 0, 1); } // End of page diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index b25cc076836..4d13b182fd4 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -170,7 +170,7 @@ if (GETPOST('type', 'alpha')) $type=GETPOST('type', 'alpha'); else $type=dol_mimetype($original_file); // Security: This wrapper is for images. We do not allow type/html -if (preg_match('/html/', $type)) accessforbidden('Error: Using the image wrapper to output a file with a mime type HTML is not possible.', 1, 1, 1); +if (preg_match('/html/', $type)) accessforbidden('Error: Using the image wrapper to output a file with a mime type HTML is not possible.', 0, 0, 1); // Security: Delete string ../ into $original_file $original_file = str_replace("../", "/", $original_file); @@ -179,7 +179,7 @@ $original_file = str_replace("../", "/", $original_file); $refname=basename(dirname($original_file)."/"); // Security check -if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart', 1, 1, 1); +if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart', 0, 0, 1); $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); $accessallowed = $check_access['accessallowed']; diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 5405f723a0c..64e23642b60 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -892,6 +892,7 @@ class Website extends CommonObject // Warning: We must keep llx_ here. It is a generic SQL. $line = 'INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, image, keywords, status, date_creation, tms, lang, import_key, grabbed_from, type_container, htmlheader, content)'; + $line.= " VALUES("; $line.= $objectpageold->newid."__+MAX_llx_website_page__, "; $line.= ($objectpageold->newfk_page ? $this->db->escape($objectpageold->newfk_page)."__+MAX_llx_website_page__" : "null").", "; @@ -939,7 +940,8 @@ class Website extends CommonObject //var_dump($this->fk_default_home.' - '.$objectpageold->id.' - '.$objectpageold->newid);exit; if ($this->fk_default_home > 0 && ($objectpageold->id == $this->fk_default_home) && ($objectpageold->newid > 0)) // This is the record with home page { - $line = "UPDATE llx_website SET fk_default_home = ".($objectpageold->newid > 0 ? $this->db->escape($objectpageold->newid)."__+MAX_llx_website_page__" : "null")." WHERE rowid = __WEBSITE_ID__;"; + // Warning: We must keep llx_ here. It is a generic SQL. + $line = "UPDATE llx_website SET fk_default_home = ".($objectpageold->newid > 0 ? $this->db->escape($objectpageold->newid)."__+MAX_llx_website_page__" : "null")." WHERE rowid = __WEBSITE_ID__;"; $line.= "\n"; fputs($fp, $line); }