diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index d84f546fb01..faf55427786 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -147,6 +147,7 @@ if (empty($reshook)) { // and pass CCCNNNNN + (num of company * 100 000 000) as offset to the run_sql as a new parameter to say to update sql on the fly to add offset to rowid and account_parent value. // This is to be sure there is no conflict for each chart of account, whatever is country, whatever is company when multicompany is used. $tmp = file_get_contents($sqlfile); + $reg = array(); if (preg_match('/-- ADD (\d+) to rowid/ims', $tmp, $reg)) { $offsetforchartofaccount += $reg[1]; } @@ -342,7 +343,7 @@ if ($resql) { // Box to select active chart of account print $langs->trans("Selectchartofaccounts")." : "; - print ''; $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country = c.rowid AND c.active = 1"; @@ -353,6 +354,7 @@ if ($resql) { if ($resqlchart) { $numbis = $db->num_rows($resqlchart); $i = 0; + print ''; while ($i < $numbis) { $obj = $db->fetch_object($resqlchart); diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 7efe910a814..53852955094 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -340,7 +340,7 @@ class FormAccounting extends Form * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. * @return string String with HTML select */ - public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '') + public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss = 'minwidth100 maxwidth300 maxwidthonsmartphone', $usecache = '') { // phpcs:enable global $conf, $langs; @@ -378,36 +378,44 @@ class FormAccounting extends Form return -1; } - $selected = $selectid; // selectid can be -1, 0, 123 - while ($obj = $this->db->fetch_object($resql)) { - if (empty($obj->labelshort)) { - $labeltoshow = $obj->label; - } else { - $labeltoshow = $obj->labelshort; - } + $num_rows = $this->db->num_rows($resql); - $label = length_accountg($obj->account_number).' - '.$labeltoshow; - $label = dol_trunc($label, $trunclength); + if ($num_rows == 0) { + $langs->load("errors"); + $showempty = $langs->trans("ErrorYouMustFirstSetupYourChartOfAccount"); + } else { + $selected = $selectid; // selectid can be -1, 0, 123 + while ($obj = $this->db->fetch_object($resql)) { + if (empty($obj->labelshort)) { + $labeltoshow = $obj->label; + } else { + $labeltoshow = $obj->labelshort; + } - $select_value_in = $obj->rowid; - $select_value_out = $obj->rowid; + $label = length_accountg($obj->account_number).' - '.$labeltoshow; + $label = dol_trunc($label, $trunclength); - // Try to guess if we have found default value - if ($select_in == 1) { - $select_value_in = $obj->account_number; - } - if ($select_out == 1) { - $select_value_out = $obj->account_number; - } - // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number - // Because same account_number can be share between different accounting_system and do have the same meaning - if ($selectid != '' && $selectid == $select_value_in) { - //var_dump("Found ".$selectid." ".$select_value_in); - $selected = $select_value_out; - } + $select_value_in = $obj->rowid; + $select_value_out = $obj->rowid; - $options[$select_value_out] = $label; + // Try to guess if we have found default value + if ($select_in == 1) { + $select_value_in = $obj->account_number; + } + if ($select_out == 1) { + $select_value_out = $obj->account_number; + } + // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number + // Because same account_number can be share between different accounting_system and do have the same meaning + if ($selectid != '' && $selectid == $select_value_in) { + //var_dump("Found ".$selectid." ".$select_value_in); + $selected = $select_value_out; + } + + $options[$select_value_out] = $label; + } } + $this->db->free($resql); if ($usecache) { @@ -416,7 +424,7 @@ class FormAccounting extends Form } } - $out .= Form::selectarray($htmlname, $options, $selected, ($showempty > 0 ? 1 : 0), 0, 0, '', 0, 0, 0, '', $morecss, 1); + $out .= Form::selectarray($htmlname, $options, $selected, ($showempty ? (is_numeric($showempty) ? 1 : $showempty): 0), 0, 0, '', 0, 0, 0, '', $morecss, 1); return $out; } diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index e256ad8f4aa..8f7ed11ba16 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -1550,13 +1550,18 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->cols['subprice'] = array( 'rank' => $rank, 'width' => 19, // in mm - 'status' => true, + 'status' => false, 'title' => array( 'textkey' => 'PriceUHT' ), 'border-left' => true, // add left line separator ); + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE)) + { + $this->cols['subprice']['status'] = true; + } + $rank = $rank + 10; $this->cols['qty'] = array( 'rank' => $rank, @@ -1607,6 +1612,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders 'border-left' => true, // add left line separator ); + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN)) + { + $this->cols['totalexcltax']['status'] = true; + } + // Add extrafields cols if (!empty($object->lines)) { $line = reset($object->lines); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 879cbba7578..9ca3031f037 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -339,10 +339,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); - $pdf->SetSubject($outputlangs->transnoentities("Order")); + $pdf->SetSubject($outputlangs->transnoentities("PurchaseOrder")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); + + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PurchaseOrder")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { $pdf->SetCompression(false); } @@ -526,16 +527,18 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut // VAT Rate - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R'); } // Unit price before discount - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxup, $curY); - $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0); + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE)) { + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->posxup, $curY); + $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0); + } // Quantity $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); @@ -557,9 +560,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } // Total HT line - $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs); - $pdf->SetXY($this->postotalht, $curY); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0); + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN)) { + $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs); + $pdf->SetXY($this->postotalht, $curY); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0); + } // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) { diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 6217b804787..72b57de5a61 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -162,9 +162,12 @@ if (empty($reshook)) { $description = trim(GETPOST('description', 'restricthtml')); // Check that leave is for a user inside the hierarchy or advanced permission for all is set - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->holiday->write)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->holiday->writeall_advance))) { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->holiday->write)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->id == $fuserid && empty($user->rights->holiday->write)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->id != $fuserid && empty($user->rights->holiday->writeall_advance)) + ) { $error++; - setEventMessages($langs->trans("NotEnoughPermission"), null, 'errors'); + setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors'); } else { if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance)) { if (!in_array($fuserid, $childids)) { diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 0fd3ab0b2a6..bb5e7c5e287 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -260,6 +260,7 @@ ErrorAParameterIsRequiredForThisOperation=A parameter is mandatory for this oper ErrorDateIsInFuture=Error, the date can't be in the future ErrorAnAmountWithoutTaxIsRequired=Error, amount is mandatory ErrorAPercentIsRequired=Error, please fill in the percentage correctly +ErrorYouMustFirstSetupYourChartOfAccount=You must first setup your chart of account # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. diff --git a/htdocs/product/card.php b/htdocs/product/card.php index d7080e39417..1a3967f2de7 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1333,7 +1333,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } else { $accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell') ? GETPOST('accountancy_code_sell', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT); } - print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, null, 1, 1, ''); + print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, null, 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1); print ''; // Accountancy_code_sell_intra @@ -1345,7 +1345,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } else { $accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra') ? GETPOST('accountancy_code_sell_intra', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT); } - print $formaccounting->select_account($accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, null, 1, 1, ''); + print $formaccounting->select_account($accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, null, 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1); print ''; } @@ -1357,18 +1357,18 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } else { $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ? GETPOST('accountancy_code_sell_export', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT); } - print $formaccounting->select_account($accountancy_code_sell_export, 'accountancy_code_sell_export', 1, null, 1, 1, ''); + print $formaccounting->select_account($accountancy_code_sell_export, 'accountancy_code_sell_export', 1, null, 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1); print ''; // Accountancy_code_buy print ''.$langs->trans("ProductAccountancyBuyCode").''; print ''; - if ($type == 0) { - $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT); - } else { - $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT); - } - print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, ''); + if ($type == 0) { + $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT); + } else { + $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT); + } + print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1); print ''; // Accountancy_code_buy_intra @@ -1380,7 +1380,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } else { $accountancy_code_buy_intra = (GETPOSTISSET('accountancy_code_buy_intra') ? GETPOST('accountancy_code_buy_intra', 'alpha') : $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT); } - print $formaccounting->select_account($accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, null, 1, 1, ''); + print $formaccounting->select_account($accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, null, 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1); print ''; } @@ -1392,7 +1392,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } else { $accountancy_code_buy_export = (GETPOST('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export', 'alpha') : $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT); } - print $formaccounting->select_account($accountancy_code_buy_export, 'accountancy_code_buy_export', 1, null, 1, 1, ''); + print $formaccounting->select_account($accountancy_code_buy_export, 'accountancy_code_buy_export', 1, null, 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1); print ''; } else // For external software { @@ -1509,7 +1509,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; // Ref - print ''; + print ''; // Label print ''; @@ -1746,21 +1746,21 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (!empty($conf->accounting->enabled)) { // Accountancy_code_sell - print ''; + print ''; print ''; // Accountancy_code_sell_intra if ($mysoc->isInEEC()) { - print ''; + print ''; print ''; } // Accountancy_code_sell_export - print ''; + print ''; print ''; @@ -1773,33 +1773,33 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Accountancy_code_buy_intra if ($mysoc->isInEEC()) { - print ''; + print ''; print ''; } // Accountancy_code_buy_export - print ''; + print ''; print ''; } else { // For external software // Accountancy_code_sell - print ''; + print ''; print ''; // Accountancy_code_sell_intra if ($mysoc->isInEEC()) { - print ''; + print ''; print ''; } // Accountancy_code_sell_export - print ''; + print ''; print ''; @@ -1810,13 +1810,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Accountancy_code_buy_intra if ($mysoc->isInEEC()) { - print ''; + print ''; print ''; } // Accountancy_code_buy_export - print ''; + print ''; print ''; }
'.$langs->trans("Ref").'
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("ProductAccountancySellCode").'
'.$langs->trans("ProductAccountancySellCode").''; print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1); print '
'.$langs->trans("ProductAccountancySellIntraCode").'
'.$langs->trans("ProductAccountancySellIntraCode").''; print $formaccounting->select_account($object->accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, '', 1, 1); print '
'.$langs->trans("ProductAccountancySellExportCode").'
'.$langs->trans("ProductAccountancySellExportCode").''; print $formaccounting->select_account($object->accountancy_code_sell_export, 'accountancy_code_sell_export', 1, '', 1, 1); print '
'.$langs->trans("ProductAccountancyBuyIntraCode").'
'.$langs->trans("ProductAccountancyBuyIntraCode").''; print $formaccounting->select_account($object->accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, '', 1, 1); print '
'.$langs->trans("ProductAccountancyBuyExportCode").'
'.$langs->trans("ProductAccountancyBuyExportCode").''; print $formaccounting->select_account($object->accountancy_code_buy_export, 'accountancy_code_buy_export', 1, '', 1, 1); print '
'.$langs->trans("ProductAccountancySellCode").'
'.$langs->trans("ProductAccountancySellCode").''; print '
'.$langs->trans("ProductAccountancySellIntraCode").'
'.$langs->trans("ProductAccountancySellIntraCode").''; print '
'.$langs->trans("ProductAccountancySellExportCode").'
'.$langs->trans("ProductAccountancySellExportCode").''; print '
'.$langs->trans("ProductAccountancyBuyIntraCode").'
'.$langs->trans("ProductAccountancyBuyIntraCode").''; print '
'.$langs->trans("ProductAccountancyBuyExportCode").'
'.$langs->trans("ProductAccountancyBuyExportCode").''; print '