diff --git a/.travis.yml b/.travis.yml index c1bed319447..733e997bdf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,8 +38,8 @@ env: jobs: fast_finish: true - allow_failures: - - php: nightly + #allow_failures: + #- php: nightly include: - if: type = push php: '5.6' @@ -73,13 +73,6 @@ before_install: phpenv config-rm xdebug.ini echo -- | - if [ "$DB" = 'postgresql' ]; then - echo "Check pgloader version" - pgloader --version - echo - fi - install: - | echo "Updating Composer" @@ -178,6 +171,10 @@ before_script: mysql --version | head - mysql -e "SELECT VERSION();" | head - psql --version + if [ "$DB" = 'postgresql' ]; then + echo "Check pgloader version" + pgloader --version + fi echo - | diff --git a/ChangeLog b/ChangeLog index c5cc42fd2f3..14f59405eb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,8 @@ English Dolibarr ChangeLog For users: ---------- -NEW: Add module "Credit transfer SEPA" to manage payment of vendors using bank credit transfer SEPA files. +NEW: Module "Credit transfer SEPA" to manage payment of vendors using bank credit transfer SEPA files. +NEW: Module Intracomm report NEW: Module Reception (for a more accurate management of your receptions) moved from experimental to stable. NEW: Module Recruitment to manage Job position and applications. NEW: Several security issues after a private bug bounty campaign. @@ -22,7 +23,6 @@ NEW: Solve blocking feature. Can increase stock of a Kit without changing subpro NEW: add a widget to show the customers with outstanding limits reached NEW: add 2 rules for emailcollector: Message send/not sent from Dolibarr NEW: add a counter of number of words for pages in website module -NEW: add alert before changing thirdparty in TakePOS NEW: add a page to list Stock at a given date in the past NEW: add a start date to begin binding in accountancy NEW: add a statistics page to list popularity of products on invoices @@ -34,7 +34,7 @@ NEW: add column vat rate in page to define accounting account on product/service NEW: add costprice in fields of products list NEW: add an import profile for CUSTOMER ORDER, PO, PROPOSAL MODULE, SUPPLIER INVOICE NEW: add employee link in expense report binding page -NEW: add EORI No. as ProfID5 +NEW: add EORI No. as ProfID5 #15382 NEW: add export for various payments NEW: add Extrafields labels and values in mail on create ticket NEW: add Extrafields support on ECM module @@ -121,9 +121,7 @@ NEW: link on balance to the ledger NEW: MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const in email collector NEW: manage errors on update extra fields in ticket card NEW: mass-actions for the event list view -NEW: Module Intracomm report NEW: more filter for "View change logs" -NEW: multicurrency total in TakePOS NEW: multiselect type and date to date filter NEW: Nature of product is now a dictionay NEW: new line template: hidden conf to fill service dates from the last service line @@ -136,14 +134,12 @@ NEW: Purchase price table: added filterable table columns NEW: rate editor for multicurrency NEW: ref_ext field for Commande lines, order lines, Attributes and Combinations, Invoice lines, payments, order lines NEW: remove new lines in mail on add ticket message -NEW: restrict thirdparty to customer in TakePOS NEW: Rule "email to" accept wildcard * NEW: Save filter of the project homepage NEW: select-able columns on customer and supplier invoice paymnet list NEW: select-able columns on miscellaneous payments + more data columns NEW: select-able columns on social taxes list NEW: send context and remove new lines on create ticket -NEW: show available stock in TakePOS NEW: show category filter on lists only when user have rights to read categories NEW: show header number and make it clickable in warehouse area, payment area, shipment area NEW: show image of user in the combo select of users @@ -156,12 +152,16 @@ NEW: show tags and status in search list of website pages NEW: show user on external calender events (when found) NEW: subject title with company name instead of application title in ticket message NEW: Support for Samba4 AD +NEW: TakePOS add alert before changing thirdparty NEW: TakePOS add third order printer NEW: TakePOS can change thirdparty with barcode scan NEW: TakePOS can create a thirdparty customer from TakePOS frontend NEW: TakePOS connector compatibility with RECEIPT PRINTERS module NEW: TakePOS Gift Receipt -NEW: TakePOS Multicurrency compatibility +NEW: TakePOS multicurrency compatibility +NEW: TakePOS multicurrency total +NEW: TakePOS restrict thirdparty to customer +NEW: TakePOS show available stock in TakePOS NEW: TakePOS Weighing Scale compatibility with TakePOS connector #14725 NEW: Third-Party Import new fields: mother company,outstanding debt limit,bank account,incoterms NEW: Thirdparty module : box on customer/supplier tab for invoice outsantding amount late diff --git a/build/README b/build/README index 14f2b92ae39..626953f9376 100644 --- a/build/README +++ b/build/README @@ -7,6 +7,9 @@ Building packages ################################################## All sub-directories of "build" directory contains files (setup or binary tools) required to build automatically Dolibarr packages. +The build directory and all its contents is absolutely not required to make Dolibarr working. +It is here only to build Dolibarr packages, and those generated packages will not contains this "build" directory. + There are several tools: @@ -17,8 +20,7 @@ There are several tools: -------------------------------------------------------------------------------------------------- -Prerequisites to build tgz, debian, rpm package: - +Prerequisites to build tgz, debian and rpm packages: > apt-get install tar dpkg dpatch p7zip-full rpm zip @@ -58,10 +60,6 @@ Prerequisites to build autoexe DoliWamp package: -------------------------------------------------------------------------------------------------- -Note: -The build directory and all its contents is absolutely not required to make Dolibarr working. -It is here only to build Dolibarr packages, and those generated packages will not contains this "build" directory. - You can find in "build", following sub-directories: diff --git a/dev/README b/dev/README index 337928507fc..78666d77f3a 100644 --- a/dev/README +++ b/dev/README @@ -1,13 +1,14 @@ README (English) -------------------------------- -This directory contains sub-directories to provide tools or -documentation for developers. -Note: All files in this directory are in VCS only and are not -provided with a standard release. +This directory contains sub-directories to provide tools or documentation for developers. + +Note: All files in this directory are in the source repository only and are not provided with a standard release. They are useless to make Dolibarr working. + +You may find a more complete documentation on Dolibarr on the wiki: -There is also some documentation on Dolibarr Wiki: https://wiki.dolibarr.org/ -and -https://doxygen.dolibarr.org/ +and on + +https://doxygen.dolibarr.org/ diff --git a/doc/index.html b/doc/index.html index 5c655136e3e..333f96099c3 100644 --- a/doc/index.html +++ b/doc/index.html @@ -6,18 +6,15 @@ -This directory contains several subdirectories with entries for -informations on Dolibarr.
-But if you are looking for other resources (downloads, documentation, addons, ...), you can find this -on Internet on web following sites:
-
-* Dolibarr wiki (documentation)
+This directory contains several subdirectories with entries for informations on Dolibarr.
+But if you are looking for other resources (downloads, documentation, addons, ...), you can find this on Internet on web following sites:
+
* Dolibarr portal (official website)

-* Dolibarr demo (online)
+* Dolibarr wiki (documentation)

-* DoliWamp, the Dolibarr for Windows
+* Dolibarr demo (online)

* DoliStore (official addons/plugins market place)
diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 029550192f0..c905ad25cd0 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; $error = 0; // Load translation files required by the page -$langs->loadLangs(array("bills", "accountancy")); +$langs->loadLangs(array("bills", "accountancy", "compta")); $mesg = ''; $action = GETPOST('action', 'aZ09'); @@ -41,7 +41,9 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $rowid = GETPOST('rowid', 'int'); $cancel = GETPOST('cancel', 'alpha'); -$accountingaccount = GETPOST('accountingaccount', 'alpha'); + +$account_number = GETPOST('account_number', 'string'); +$label = GETPOST('label', 'alpha'); // Security check if ($user->socid > 0) accessforbidden(); @@ -65,104 +67,118 @@ if (GETPOST('cancel', 'alpha')) if ($action == 'add' && $user->rights->accounting->chartofaccount) { if (!$cancel) { - $sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS; - - dol_syslog('accountancy/admin/card.php:: $sql='.$sql); - $result = $db->query($sql); - $obj = $db->fetch_object($result); - - // Clean code - - // To manage zero or not at the end of the accounting account - if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) + if (!$account_number) { - $account_number = GETPOST('account_number', 'string'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors'); + $action = 'create'; + } elseif (!$label) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); + $action = 'create'; } else { - $account_number = clean_account(GETPOST('account_number', 'string')); - } + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; - if (GETPOST('account_parent', 'int') <= 0) - { - $account_parent = 0; - } else { - $account_parent = GETPOST('account_parent', 'int'); - } + dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); + $result = $db->query($sql); + $obj = $db->fetch_object($result); - $object->fk_pcg_version = $obj->pcg_version; - $object->pcg_type = GETPOST('pcg_type', 'alpha'); - $object->account_number = $account_number; - $object->account_parent = $account_parent; - $object->account_category = GETPOST('account_category', 'alpha'); - $object->label = GETPOST('label', 'alpha'); - $object->labelshort = GETPOST('labelshort', 'alpha'); - $object->active = 1; + // Clean code - $res = $object->create($user); - if ($res == - 3) { - $error = 1; - $action = "create"; - setEventMessages($object->error, $object->errors, 'errors'); - } elseif ($res == - 4) { - $error = 2; - $action = "create"; - setEventMessages($object->error, $object->errors, 'errors'); - } elseif ($res < 0) - { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $action = "create"; - } - if (!$error) - { - setEventMessages("RecordCreatedSuccessfully", null, 'mesgs'); - $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); - header("Location: ".$urltogo); - exit; + // To manage zero or not at the end of the accounting account + if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) { + $account_number = $account_number; + } else { + $account_number = clean_account($account_number); + } + + if (GETPOST('account_parent', 'int') <= 0) { + $account_parent = 0; + } else { + $account_parent = GETPOST('account_parent', 'int'); + } + + $object->fk_pcg_version = $obj->pcg_version; + $object->pcg_type = GETPOST('pcg_type', 'alpha'); + $object->account_number = $account_number; + $object->account_parent = $account_parent; + $object->account_category = GETPOST('account_category', 'alpha'); + $object->label = $label; + $object->labelshort = GETPOST('labelshort', 'alpha'); + $object->active = 1; + + $res = $object->create($user); + if ($res == -3) { + $error = 1; + $action = "create"; + setEventMessages($object->error, $object->errors, 'errors'); + } elseif ($res == -4) { + $error = 2; + $action = "create"; + setEventMessages($object->error, $object->errors, 'errors'); + } elseif ($res < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $action = "create"; + } + if (!$error) { + setEventMessages("RecordCreatedSuccessfully", null, 'mesgs'); + $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); + header("Location: " . $urltogo); + exit; + } } } } elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) { if (!$cancel) { - $result = $object->fetch($id); - - $sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS; - - dol_syslog('accountancy/admin/card.php:: $sql='.$sql); - $result2 = $db->query($sql); - $obj = $db->fetch_object($result2); - - // Clean code - - // To manage zero or not at the end of the accounting account - if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) + if (!$account_number) { - $account_number = GETPOST('account_number', 'string'); - } else { - $account_number = clean_account(GETPOST('account_number', 'string')); - } - - if (GETPOST('account_parent', 'int') <= 0) + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors'); + $action = 'update'; + } elseif (!$label) { - $account_parent = 0; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); + $action = 'update'; } else { - $account_parent = GETPOST('account_parent', 'int'); - } + $result = $object->fetch($id); - $object->fk_pcg_version = $obj->pcg_version; - $object->pcg_type = GETPOST('pcg_type', 'alpha'); - $object->account_number = $account_number; - $object->account_parent = $account_parent; - $object->account_category = GETPOST('account_category', 'alpha'); - $object->label = GETPOST('label', 'alpha'); - $object->labelshort = GETPOST('labelshort', 'alpha'); + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; - $result = $object->update($user); + dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); + $result2 = $db->query($sql); + $obj = $db->fetch_object($result2); - if ($result > 0) { - $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); - header("Location: ".$urltogo); - exit(); - } else { - $mesg = $object->error; + // Clean code + + // To manage zero or not at the end of the accounting account + if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) { + $account_number = $account_number; + } else { + $account_number = clean_account($account_number); + } + + if (GETPOST('account_parent', 'int') <= 0) { + $account_parent = 0; + } else { + $account_parent = GETPOST('account_parent', 'int'); + } + + $object->fk_pcg_version = $obj->pcg_version; + $object->pcg_type = GETPOST('pcg_type', 'alpha'); + $object->account_number = $account_number; + $object->account_parent = $account_parent; + $object->account_category = GETPOST('account_category', 'alpha'); + $object->label = $label; + $object->labelshort = GETPOST('labelshort', 'alpha'); + + $result = $object->update($user); + + if ($result > 0) { + $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: " . $urltogo); + exit(); + } else { + $mesg = $object->error; + } } } else { $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); @@ -222,7 +238,7 @@ if ($action == 'create') { // Account number print ''.$langs->trans("AccountNumber").''; - print ''; + print ''; // Label print ''.$langs->trans("Label").''; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 1547983da0c..fcd7efdab47 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page -$langs->loadLangs(array("accountancy")); +$langs->loadLangs(array("accountancy", "compta")); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -88,6 +88,7 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) } else { $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $year_start = dol_print_date(dol_now(), '%Y'); + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year $year_end = $year_start + 1; $month_end = $month_start - 1; if ($month_end < 1) @@ -322,7 +323,9 @@ if ($action != 'export_csv') $root_account_number = $tmparrayforrootaccount['account_number']; if (empty($accountingaccountstatic->label) && $accountingaccountstatic->id > 0) { - $link = ''.img_edit().''; + $link = '' . img_edit() . ''; + } elseif (empty($tmparrayforrootaccount['label'])) { + $link = '' . img_edit_add() . ''; } if (!empty($show_subgroup)) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 830896776b5..59ffdf2e899 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("accountancy")); +$langs->loadLangs(array("accountancy", "compta")); $socid = GETPOST('socid', 'int'); @@ -661,7 +661,7 @@ if (empty($reshook)) { } $newcardbutton .= ''.$langs->trans("IncludeDocsAlreadyExported").''; - $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export); + if (!empty($user->rights->accounting->mouvements->export)) $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 34a6b2d5ffd..9c7fef0232b 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -48,6 +48,14 @@ $search_date_endday = GETPOST('search_date_endday', 'int'); $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); $search_date_end = dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); +$search_date_export_startyear = GETPOST('search_date_export_startyear', 'int'); +$search_date_export_startmonth = GETPOST('search_date_export_startmonth', 'int'); +$search_date_export_startday = GETPOST('search_date_export_startday', 'int'); +$search_date_export_endyear = GETPOST('search_date_export_endyear', 'int'); +$search_date_export_endmonth = GETPOST('search_date_export_endmonth', 'int'); +$search_date_export_endday = GETPOST('search_date_export_endday', 'int'); +$search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear); +$search_date_export_end = dol_mktime(0, 0, 0, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear); $search_accountancy_code = GETPOST("search_accountancy_code"); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); @@ -128,6 +136,7 @@ $arrayfields = array( 't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1), 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1), 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), + 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), ); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); @@ -181,6 +190,14 @@ if (empty($reshook)) $search_date_endyear = ''; $search_date_endmonth = ''; $search_date_endday = ''; + $search_date_export_start = ''; + $search_date_export_end = ''; + $search_date_export_startyear = ''; + $search_date_export_startmonth = ''; + $search_date_export_startday = ''; + $search_date_export_endyear = ''; + $search_date_export_endmonth = ''; + $search_date_export_endday = ''; $search_debit = ''; $search_credit = ''; $search_lettering_code = ''; @@ -253,6 +270,14 @@ if (empty($reshook)) $filter['t.reconciled_option'] = $search_not_reconciled; $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); } + if (!empty($search_date_export_start)) { + $filter['t.date_export>='] = $search_date_export_start; + $param .= '&search_date_export_startmonth='.$search_date_export_startmonth.'&search_date_export_startday='.$search_date_export_startday.'&search_date_export_startyear='.$search_date_export_startyear; + } + if (!empty($search_date_export_end)) { + $filter['t.date_export<='] = $search_date_export_end; + $param .= '&search_date_export_endmonth='.$search_date_export_endmonth.'&search_date_export_endday='.$search_date_export_endday.'&search_date_export_endyear='.$search_date_export_endyear; + } } if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { @@ -494,6 +519,17 @@ if (!empty($arrayfields['t.lettering_code']['checked'])) print '
'.$langs->trans("NotReconciled").''; print ''; } +// Date export +if (!empty($arrayfields['t.date_export']['checked'])) { + print ''; + print '
'; + print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); + print '
'; + print '
'; + print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); + print '
'; + print ''; +} // Fields from hook $parameters = array('arrayfields'=>$arrayfields); @@ -516,6 +552,7 @@ if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_tit if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center '); // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -546,13 +583,12 @@ while ($i < min($num, $limit)) // Is it a break ? if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { - if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { - $colnumber = 3; - $colnumberend = 7; - } else { - $colnumber = 4; - $colnumberend = 7; - } + $colnumber = 5; + $colnumberend = 7; + + if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) $colnumber--; + if (empty($arrayfields['t.date_export']['checked'])) $colnumber--; + $colspan = $totalarray['nbfield'] - $colnumber; $colspanend = $totalarray['nbfield'] - $colnumberend; // Show a subtotal by accounting account @@ -585,7 +621,7 @@ while ($i < min($num, $limit)) // Show the break account print ""; - print ''; + print ''; if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte); else print ''.$langs->trans("Unknown").''; print ''; @@ -735,6 +771,13 @@ while ($i < min($num, $limit)) if (!$i) $totalarray['nbfield']++; } + // Exported operation date + if (!empty($arrayfields['t.date_export']['checked'])) + { + print ''.dol_print_date($line->date_export, 'dayhour').''; + if (!$i) $totalarray['nbfield']++; + } + // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook @@ -763,14 +806,6 @@ while ($i < min($num, $limit)) } if ($num > 0) { - // Show sub-total of last shown account - if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { - $colnumber = 3; - $colnumberend = 7; - } else { - $colnumber = 4; - $colnumberend = 7; - } $colspan = $totalarray['nbfield'] - $colnumber; $colspanend = $totalarray['nbfield'] - $colnumberend; print ''; diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php index 9f5f9d3ca93..2adcbe9f360 100644 --- a/htdocs/accountancy/bookkeeping/listbysubaccount.php +++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php @@ -48,6 +48,14 @@ $search_date_endday = GETPOST('search_date_endday', 'int'); $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); $search_date_end = dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); +$search_date_export_startyear = GETPOST('search_date_export_startyear', 'int'); +$search_date_export_startmonth = GETPOST('search_date_export_startmonth', 'int'); +$search_date_export_startday = GETPOST('search_date_export_startday', 'int'); +$search_date_export_endyear = GETPOST('search_date_export_endyear', 'int'); +$search_date_export_endmonth = GETPOST('search_date_export_endmonth', 'int'); +$search_date_export_endday = GETPOST('search_date_export_endday', 'int'); +$search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear); +$search_date_export_end = dol_mktime(0, 0, 0, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear); $search_accountancy_code = GETPOST("search_accountancy_code"); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); @@ -135,6 +143,7 @@ $arrayfields = array( 't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1), 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1), 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), + 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), ); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { @@ -193,6 +202,14 @@ if (empty($reshook)) { $search_date_endyear = ''; $search_date_endmonth = ''; $search_date_endday = ''; + $search_date_export_start = ''; + $search_date_export_end = ''; + $search_date_export_startyear = ''; + $search_date_export_startmonth = ''; + $search_date_export_startday = ''; + $search_date_export_endyear = ''; + $search_date_export_endmonth = ''; + $search_date_export_endday = ''; $search_debit = ''; $search_credit = ''; $search_lettering_code = ''; @@ -265,6 +282,14 @@ if (empty($reshook)) { $filter['t.reconciled_option'] = $search_not_reconciled; $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); } + if (!empty($search_date_export_start)) { + $filter['t.date_export>='] = $search_date_export_start; + $param .= '&search_date_export_startmonth='.$search_date_export_startmonth.'&search_date_export_startday='.$search_date_export_startday.'&search_date_export_startyear='.$search_date_export_startyear; + } + if (!empty($search_date_export_end)) { + $filter['t.date_export<='] = $search_date_export_end; + $param .= '&search_date_export_endmonth='.$search_date_export_endmonth.'&search_date_export_endday='.$search_date_export_endday.'&search_date_export_endyear='.$search_date_export_endyear; + } } if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { @@ -301,7 +326,7 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme } // Make a redirect to avoid to launch the delete later after a back button - header("Location: listbysubaccount.php".($param ? '?'.$param : '')); + header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : '')); exit; } else { setEventMessages("NoRecordDeleted", null, 'warnings'); @@ -318,7 +343,7 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); } - header("Location: listbysubaccount.php?noreset=1".($param ? '&'.$param : '')); + header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : '')); exit; } } @@ -419,7 +444,6 @@ if (empty($reshook)) { $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss' => 'marginleftonly')); $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php', '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); - $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); } @@ -522,6 +546,17 @@ if (!empty($arrayfields['t.lettering_code']['checked'])) { print '
'.$langs->trans("NotReconciled").''; print ''; } +// Date export +if (!empty($arrayfields['t.date_export']['checked'])) { + print ''; + print '
'; + print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); + print '
'; + print '
'; + print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); + print '
'; + print ''; +} // Fields from hook $parameters = array('arrayfields'=>$arrayfields); @@ -560,6 +595,9 @@ if (!empty($arrayfields['t.credit']['checked'])) { if (!empty($arrayfields['t.lettering_code']['checked'])) { print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); } +if (!empty($arrayfields['t.date_export']['checked'])) { + print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center '); +} // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -589,15 +627,15 @@ while ($i < min($num, $limit)) { // Is it a break ? if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { - if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { - $colnumber = 3; - $colnumberend = 7; - } else { - $colnumber = 4; - $colnumberend = 7; - } - $colspan = $totalarray['nbfield'] - $colnumber; - $colspanend = $totalarray['nbfield'] - $colnumberend; + $colnumber = 5; + $colnumberend = 7; + + if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) $colnumber--; + if (empty($arrayfields['t.date_export']['checked'])) $colnumber--; + + $colspan = $totalarray['nbfield'] - $colnumber; + $colspanend = $totalarray['nbfield'] - $colnumberend; + // Show a subtotal by accounting account if (isset($displayed_account_number)) { print ''; @@ -627,7 +665,7 @@ while ($i < min($num, $limit)) { // Show the break account print ""; - print ''; + print ''; if ($line->subledger_account != "" && $line->subledger_account != '-1') { print $object->get_compte_desc($line->numero_compte).' : '.length_accounta($line->subledger_account); } else { @@ -796,6 +834,13 @@ while ($i < min($num, $limit)) { } } + // Exported operation date + if (!empty($arrayfields['t.date_export']['checked'])) + { + print ''.dol_print_date($line->date_export, 'dayhour').''; + if (!$i) $totalarray['nbfield']++; + } + // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook @@ -826,14 +871,6 @@ while ($i < min($num, $limit)) { } if ($num > 0) { - // Show sub-total of last shown account - if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { - $colnumber = 3; - $colnumberend = 7; - } else { - $colnumber = 4; - $colnumberend = 7; - } $colspan = $totalarray['nbfield'] - $colnumber; $colspanend = $totalarray['nbfield'] - $colnumberend; print ''; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 3b03e6ae8ca..fe73ab9f376 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -795,7 +795,7 @@ class BookKeeping extends CommonObject $sql .= " t.label_operation,"; $sql .= " t.debit,"; $sql .= " t.credit,"; - $sql .= " t.montant,"; + $sql .= " t.montant as amount,"; $sql .= " t.sens,"; $sql .= " t.multicurrency_amount,"; $sql .= " t.multicurrency_code,"; @@ -806,7 +806,8 @@ class BookKeeping extends CommonObject $sql .= " t.code_journal,"; $sql .= " t.journal_label,"; $sql .= " t.piece_num,"; - $sql .= " t.date_creation"; + $sql .= " t.date_creation,"; + $sql .= " t.date_export"; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -823,6 +824,8 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } elseif ($key == 't.reconciled_option') { @@ -878,7 +881,8 @@ class BookKeeping extends CommonObject $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->montant; + $line->montant = $obj->amount; // deprecated + $line->amount = $obj->amount; $line->sens = $obj->sens; $line->multicurrency_amount = $obj->multicurrency_amount; $line->multicurrency_code = $obj->multicurrency_code; @@ -889,7 +893,8 @@ class BookKeeping extends CommonObject $line->code_journal = $obj->code_journal; $line->journal_label = $obj->journal_label; $line->piece_num = $obj->piece_num; - $line->date_creation = $obj->date_creation; + $line->date_creation = $this->db->jdate($obj->date_creation); + $line->date_export = $this->db->jdate($obj->date_export); $this->lines[] = $line; @@ -941,7 +946,7 @@ class BookKeeping extends CommonObject $sql .= " t.credit,"; $sql .= " t.lettering_code,"; $sql .= " t.date_lettering,"; - $sql .= " t.montant,"; + $sql .= " t.montant as amount,"; $sql .= " t.sens,"; $sql .= " t.fk_user_author,"; $sql .= " t.import_key,"; @@ -1019,7 +1024,8 @@ class BookKeeping extends CommonObject $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->montant; + $line->montant = $obj->amount; // deprecated + $line->amount = $obj->amount; $line->sens = $obj->sens; $line->lettering_code = $obj->lettering_code; $line->date_lettering = $obj->date_lettering; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 1a5098bda38..3634fba2e79 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2020 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * @@ -123,9 +123,9 @@ if ($action == 'validatehistory') { $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; - $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; + $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,"; $sql .= " co.code as country_code, co.label as country_label,"; - $sql .= " s.tva_intra"; + $sql .= " s.tva_intra, s.accountancy_code_sell as company_code_sell"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; @@ -134,6 +134,7 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON s.accountancy_code_sell = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; @@ -153,7 +154,7 @@ if ($action == 'validatehistory') { $isBuyerInEEC = isInEEC($objp); - // Search suggested account for product/service (similar code exists in page list.php to make manual binding) + // Level 2: Search suggested account for product/service (similar code exists in page list.php to make manual binding) $suggestedaccountingaccountfor = ''; if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) $objp->code_sell_p = $objp->code_sell; @@ -179,6 +180,13 @@ if ($action == 'validatehistory') { } } + // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) + if (!empty($objp->company_code_sell)) { + $objp->code_sell_t = $objp->company_code_sell; + $objp->aarowid_suggest = $objp->aarowid_thirdparty; + $suggestedaccountingaccountfor = ''; + } + if ($objp->aarowid_suggest > 0) { $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index eb2743258d7..cb47e436cbd 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -211,9 +211,9 @@ $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; $sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,"; $sql .= " p.tosell as status, p.tobuy as status_buy,"; -$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; +$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,"; $sql .= " co.code as country_code, co.label as country_label,"; -$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur"; +$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur, s.accountancy_code_sell as company_code_sell"; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; @@ -225,6 +225,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON s.accountancy_code_sell = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; // Define begin binding date @@ -456,11 +457,12 @@ if ($result) { $facture_static->type = $objp->ftype; $code_sell_p_notset = ''; + $code_sell_t_notset = ''; $objp->aarowid_suggest = ''; // Will be set later $isBuyerInEEC = isInEEC($objp); - // Search suggested default account for product/service + // Level 1: Search suggested default account for product/service $suggestedaccountingaccountbydefaultfor = ''; if ($objp->type_l == 1) { if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) @@ -503,7 +505,7 @@ if ($result) { } if ($objp->code_sell_l == -1) $objp->code_sell_l = ''; - // Search suggested account for product/service (similar code exists in page index.php to make automatic binding) + // Level 2: Search suggested account for product/service (similar code exists in page index.php to make automatic binding) $suggestedaccountingaccountfor = ''; if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) $objp->code_sell_p = $objp->code_sell; @@ -529,6 +531,13 @@ if ($result) { } } + // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) + if (!empty($objp->company_code_sell)) { + $objp->code_sell_t = $objp->company_code_sell; + $objp->aarowid_suggest = $objp->aarowid_thirdparty; + $suggestedaccountingaccountfor = ''; + } + // Manage Deposit if ($objp->description == "(DEPOSIT)") { $accountdeposittoventilated = new AccountingAccount($db); @@ -547,6 +556,7 @@ if ($result) { // $objp->code_sell_l is now default code of product/service // $objp->code_sell_p is now code of product/service + // $objp->code_sell_t is now code of thirdparty print ''; @@ -596,7 +606,7 @@ if ($result) { // Found accounts print ''; - $s = ''.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; + $s = '1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC"); elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport"); @@ -605,7 +615,7 @@ if ($result) { if ($objp->product_id > 0) { print '
'; - $s = ''.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; + $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC"); elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT"); @@ -613,16 +623,23 @@ if ($result) { elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport"); $s .= (empty($objp->code_sell_p) ? ''.$langs->trans("NotDefined").'' : length_accountg($objp->code_sell_p)); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); + } else { + print '
'; + $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; + $shelp = ''; + $s .= $langs->trans("NotDefined"); + print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); } + print '
'; + $s = '3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': '; + $shelp = ''; + $s .= ($objp->code_sell_t > 0 ? length_accountg($objp->code_sell_t) : ''.$langs->trans("NotDefined").''); + print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); print ''; // Suggested accounting account - // $objp->code_sell_l = default (it takes the country into consideration), $objp->code_sell_p is value for product (it takes the country into consideration too) print ''; $suggestedid = $objp->aarowid_suggest; - /*var_dump($suggestedid); - var_dump($objp->code_sell_p); - var_dump($objp->code_sell_l);*/ if (empty($suggestedid) && empty($objp->code_sell_p) && !empty($objp->code_sell_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) { if (empty($accountingaccount_codetotid_cache[$objp->code_sell_l])) @@ -642,7 +659,6 @@ if ($result) { // Column with checkbox print ''; - //var_dump($objp->aarowid);var_dump($objp->aarowid_intra);var_dump($objp->aarowid_export);var_dump($objp->aarowid_suggest); $ischecked = $objp->aarowid_suggest; if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $ischecked = 0; print ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 0dbe09fa468..9dd097f3d0c 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -120,9 +120,9 @@ if ($action == 'validatehistory') { $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type,"; $sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export, p.tva_tx as tva_tx_prod,"; - $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; + $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,"; $sql .= " co.code as country_code, co.label as country_label,"; - $sql .= " s.tva_intra"; + $sql .= " s.tva_intra, s.accountancy_code_buy as company_code_buy"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; @@ -131,6 +131,7 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON s.accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; @@ -151,7 +152,7 @@ if ($action == 'validatehistory') { $isSellerInEEC = isInEEC($objp); - // Search suggested account for product/service + // Level 2: Search suggested account for product/service (similar code exists in page list.php to make manual binding) $suggestedaccountingaccountfor = ''; if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) $objp->code_buy_p = $objp->code_buy; @@ -169,6 +170,13 @@ if ($action == 'validatehistory') { } } + // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) + if (!empty($objp->company_code_buy)) { + $objp->code_buy_t = $objp->company_code_buy; + $objp->aarowid_suggest = $objp->aarowid_thirdparty; + $suggestedaccountingaccountfor = ''; + } + if ($objp->aarowid_suggest > 0) { $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index cbdecd2e85e..919130e80d3 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -215,9 +215,9 @@ $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; $sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,"; $sql .= " p.tosell as status, p.tobuy as status_buy,"; -$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; +$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,"; $sql .= " co.code as country_code, co.label as country_label,"; -$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur"; +$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur, s.accountancy_code_buy as company_code_buy"; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; @@ -229,6 +229,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON s.accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; // Define begin binding date @@ -460,10 +461,12 @@ if ($result) { $facturefourn_static->label = $objp->invoice_label; $code_buy_p_notset = ''; + $code_buy_t_notset = ''; $objp->aarowid_suggest = ''; // Will be set later $isSellerInEEC = isInEEC($objp); + // Level 1: Search suggested default account for product/service $suggestedaccountingaccountbydefaultfor = ''; if ($objp->type_l == 1) { if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) @@ -494,7 +497,7 @@ if ($result) { } if ($objp->code_sell_l == -1) $objp->code_sell_l = ''; - // Search suggested account for product/service + // Level 2: Search suggested account for product/service (similar code exists in page index.php to make automatic binding) $suggestedaccountingaccountfor = ''; if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) $objp->code_buy_p = $objp->code_buy; @@ -512,6 +515,13 @@ if ($result) { } } + // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) + if (!empty($objp->company_code_buy)) { + $objp->code_buy_t = $objp->company_code_buy; + $objp->aarowid_suggest = $objp->aarowid_thirdparty; + $suggestedaccountingaccountfor = ''; + } + if (!empty($objp->code_buy_p)) { // Value was defined previously } else { @@ -521,6 +531,7 @@ if ($result) { // $objp->code_buy_l is now default code of product/service // $objp->code_buy_p is now code of product/service + // $objp->code_buy_t is now code of thirdparty print ''; @@ -576,7 +587,7 @@ if ($result) { // Found accounts print ''; - $s = ''.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; + $s = '1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC"); elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport"); @@ -585,13 +596,24 @@ if ($result) { if ($objp->product_id > 0) { print '
'; - $s = ''.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; + $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC"); elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport"); $s .= (empty($objp->code_buy_p) ? ''.$langs->trans("NotDefined").'' : length_accountg($objp->code_buy_p)); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); + } else { + print '
'; + $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; + $shelp = ''; + $s .= $langs->trans("NotDefined"); + print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); } + print '
'; + $s = '3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': '; + $shelp = ''; + $s .= ($objp->code_buy_t > 0 ? length_accountg($objp->code_buy_t) : ''.$langs->trans("NotDefined").''); + print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); print ''; // Suggested accounting account diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 16f72ef6911..bb4f142cc2a 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -393,7 +393,7 @@ print ''.$langs->trans( // Name print ''; -print 'global->MAIN_INFO_SOCIETE_NOM) ? ' autofocus="autofocus"' : '')).'>'."\n"; +print 'global->MAIN_INFO_SOCIETE_NOM) ? ' autofocus="autofocus"' : '').'>'."\n"; // Address print ''; diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 1c96ce68780..32aa7accfcf 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -34,7 +34,7 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'aZ09'); - +$form = new Form($db); /* * Actions @@ -49,6 +49,7 @@ if ($action == 'setvalue') $checkread = GETPOST('value', 'alpha'); $checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY', 'alpha'); $mailingdelay = GETPOST('MAILING_DELAY', 'int'); + $contactbulkdefault = GETPOST('MAILING_CONTACT_DEFAULT_BULK_STATUS', 'int'); $res = dolibarr_set_const($db, "MAILING_EMAIL_FROM", $mailfrom, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; @@ -56,11 +57,14 @@ if ($action == 'setvalue') if (!$res > 0) $error++; $res = dolibarr_set_const($db, "MAILING_DELAY", $mailingdelay, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; + $res = dolibarr_set_const($db, "MAILING_CONTACT_DEFAULT_BULK_STATUS", $contactbulkdefault, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; // Create temporary encryption key if nedded $res = dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY", $checkread_key, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; + if (!$error) { $db->commit(); @@ -70,7 +74,17 @@ if ($action == 'setvalue') setEventMessages($langs->trans("Error"), null, 'errors'); } } - +if ($action == 'setonsearchandlistgooncustomerorsuppliercard') { + $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity); + if (!$res > 0) $error++; + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} /* * View @@ -136,6 +150,16 @@ print ''; +// default blacklist from mailing +print ''; +print '' . $langs->trans("DefaultBlacklistMailingStatus") . ''; +print ''; +$blacklist_setting=array(0=>$langs->trans('No'),1=>$langs->trans('Yes'),-1=>$langs->trans('DefaultStatusEmptyMandatory')); +print $form->selectarray("MAILING_CONTACT_DEFAULT_BULK_STATUS", $blacklist_setting, $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS); +print ''; +print ''; + + if (!empty($conf->use_javascript_ajax) && $conf->global->MAIN_FEATURES_LEVEL >= 1) { print ''; print $langs->trans("MailAdvTargetRecipients").''; diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 031b0ef102f..db7f005284f 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -707,7 +707,15 @@ if (!empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { print "\n"; print "\n"; } - +print ''; +print ''.$langs->trans("WarehouseAskWarehouseDuringPropal").''; +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL); +} print ''; print ''.$langs->trans("WarehouseAskWarehouseDuringOrder").''; print ''; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index a94a78a9794..4ed21144346 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -264,7 +264,7 @@ if (!$error && $xml) $out .= "\n"; } } else { - $out .= ''.$langs->trans("None").''; + $out .= ''.$langs->trans("None").''; } $out .= ''; $out .= ''; @@ -317,7 +317,7 @@ if (!$error && $xml) $out .= ''."\n"; $out .= "\n"; } else { - $out .= ''.$langs->trans("None").''; + $out .= ''.$langs->trans("None").''; } $out .= ''; $out .= ''; @@ -370,12 +370,11 @@ if (!$error && $xml) $out .= ''."\n"; $out .= "\n"; } else { - $out .= ''.$langs->trans("None").''; + $out .= ''.$langs->trans("None").''; } $out .= ''; $out .= ''; - // Show warning if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) { diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 6bd3edca2b8..c1e099362ad 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; if (!$user->admin) accessforbidden(); // Load translation files required by the page -$langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposal", "receptions", "errors")); +$langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposal", "receptions", "errors", 'sendings')); $action = GETPOST('action', 'aZ09'); @@ -130,6 +130,14 @@ $workflowcodes = array( 'enabled'=>(!empty($conf->reception->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), 'picto'=>'bill' ), + + // Automatic classification shipping + 'WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE' => array( + 'family' => 'classify_shipping', + 'position' => 66, + 'enabled' => ! empty($conf->expedition->enabled) && ! empty($conf->facture->enabled), + 'picto' => 'shipment' + ) ); if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) { @@ -190,6 +198,7 @@ foreach ($workflowcodes as $key => $params) { if ($reg[1] == 'supplier_proposal') $header .= ' - '.$langs->trans('SupplierProposal'); if ($reg[1] == 'supplier_order') $header .= ' - '.$langs->trans('SupplierOrder'); if ($reg[1] == 'reception') $header .= ' - '.$langs->trans('Reception'); + if ($reg[1] == 'shipping') $header .= ' - '.$langs->trans('Shipment'); } else { $header = $langs->trans("Description"); } diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 5c170d0aa72..47f1d336279 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -134,10 +134,10 @@ if (empty($reshook)) // Set if we used free entry or predefined product $idprod = (int) GETPOST('idprod', 'int'); - $qty = GETPOST('qty', 'int'); - $qty_frozen = GETPOST('qty_frozen', 'int'); + $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); + $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); - $efficiency = GETPOST('efficiency', 'int'); + $efficiency = price2num(GETPOST('efficiency', 'alpha')); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); @@ -155,8 +155,6 @@ if (empty($reshook)) if (!$error) { - $lastposition = 0; - $bomline = new BOMLine($db); $bomline->fk_bom = $id; $bomline->fk_product = $idprod; @@ -181,8 +179,10 @@ if (empty($reshook)) unset($_POST['qty_frozen']); unset($_POST['disable_stock_change']); - $object->fetchLines(); - } + $object->fetchLines(); + + $object->calculateCosts(); + } } } @@ -193,10 +193,10 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $qty = price2num(GETPOST('qty', 'int')); - $qty_frozen = GETPOST('qty_frozen', 'int'); + $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); + $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); - $efficiency = price2num(GETPOST('efficiency', 'int')); + $efficiency = price2num(GETPOST('efficiency', 'alpha')); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); @@ -221,7 +221,9 @@ if (empty($reshook)) unset($_POST['qty_frozen']); unset($_POST['disable_stock_change']); - $object->fetchLines(); + $object->fetchLines(); + + $object->calculateCosts(); } } } diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 1f0a00cb4b8..9e54fc67e8a 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -141,7 +141,7 @@ print ''; print ''; if (is_object($objectline)) { - print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', 1); + print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', 1, 'line'); } ?> diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index f31db94403b..4d10539c824 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -141,7 +141,7 @@ print ''; print ''; if (is_object($objectline)) { - print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', 1); + print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', 1, 'line'); } print "\n"; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 87c1a72789d..bc8506b2151 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -161,7 +161,7 @@ print ''; //Line extrafield if (!empty($extrafields)) { - print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"', 'colspan'=>$coldisplay), '', '', 1); + print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"', 'colspan'=>$coldisplay), '', '', 1, 'line'); } print "\n"; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 53e498fe303..cf64e0a1d04 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1266,6 +1266,12 @@ if ($object->id > 0) } } + // Allow external modules to add their own shortlist of recent objects + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreRecentObjects', $parameters, $object, $action); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + else print $hookmanager->resPrint; + print ''; print '
'; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index f6a63ba9a48..23c960d3a4b 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -130,6 +130,8 @@ $permissiondellink = $usercancreate; // Used by the include of actions_dellink.i $permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php +//if ($thirdparty->fk_warehouse > 0) $object->warehouse_id = $thirdparty->fk_warehouse; + /* * Actions */ @@ -242,6 +244,7 @@ if (empty($reshook)) } // Validation elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) { + $idwarehouse = GETPOST('idwarehouse', 'int'); $result = $object->valid($user); if ($result >= 0) { @@ -349,6 +352,7 @@ if (empty($reshook)) $object->demand_reason_id = GETPOST('demand_reason_id'); $object->fk_delivery_address = GETPOST('fk_address', 'int'); $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); + $object->warehouse_id = GETPOST('warehouse_id', 'int'); $object->duree_validite = $duration; $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); @@ -380,6 +384,7 @@ if (empty($reshook)) $object->demand_reason_id = GETPOST('demand_reason_id', 'int'); $object->fk_delivery_address = GETPOST('fk_address', 'int'); $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); + $object->warehouse_id = GETPOST('warehouse_id', 'int'); $object->duree_validite = price2num(GETPOST('duree_validite', 'alpha')); $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int'); $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); @@ -796,7 +801,7 @@ if (empty($reshook)) } elseif ($action == 'addline' && $usercancreate) { // Add line // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOSTISSET('dp_desc') ?GETPOST('dp_desc', 'restricthtml') : ''); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $price_ht = price2num(GETPOST('price_ht')); $price_ht_devise = price2num(GETPOST('multicurrency_price_ht')); $prod_entry_mode = GETPOST('prod_entry_mode'); @@ -809,7 +814,7 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = price2num(GETPOST('qty'.$predef), 'MS'); + $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); $remise_percent = GETPOST('remise_percent'.$predef); if (empty($remise_percent)) $remise_percent = 0; @@ -999,11 +1004,16 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); } - $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + $desc = (!empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; } else { $desc = $prod->description; } + //If text set in desc is the same as product description (as now it's preloaded) whe add it only one time + if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { + $product_desc=''; + } + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); @@ -1234,7 +1244,7 @@ if (empty($reshook)) } } - $qty = price2num(GETPOST('qty'), 'MS'); + $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); $result = $object->updateline(GETPOST('lineid', 'int'), $pu_ht, $qty, GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, $_POST["units"], $pu_ht_devise); @@ -1320,6 +1330,9 @@ if (empty($reshook)) } // shipping method elseif ($action == 'setshippingmethod' && $usercancreate) { $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); + }// warehouse + elseif ($action == 'setwarehouse' && $usercancreate) { + $result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); } elseif ($action == 'update_extras') { $object->oldcopy = dol_clone($object); @@ -1464,6 +1477,7 @@ if ($action == 'create') $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0)); $dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice); // Replicate extrafields @@ -1480,6 +1494,13 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; } + //Warehouse default if null + if (!empty($conf->stock->enabled) && empty($warehouse_id) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) + { + if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE; + if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $warehouse_id = $user->fk_warehouse; + } + $object = new Propal($db); print '
'; @@ -1512,9 +1533,13 @@ if ($action == 'create') print $soc->getNomUrl(1); print ''; print ''; + if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) { + $shipping_method_id = $soc->shipping_method_id; + } + //$warehouse_id = $soc->warehouse_id; } else { print ''; - print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500'); + print img_picto('', 'company').$form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500'); // reload page to retrieve customer informations if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) { @@ -1538,6 +1563,7 @@ if ($action == 'create') { // Contacts (ask contact only if thirdparty already defined). print "".$langs->trans("DefaultContact").''; + print img_picto('', 'contact'); $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist); print ''; @@ -1555,25 +1581,28 @@ if ($action == 'create') // Date print ''.$langs->trans('Date').''; - print $form->selectDate('', '', '', '', '', "addprop", 1, 1); + print img_picto('', 'object_calendarday').' '.$form->selectDate('', '', '', '', '', "addprop", 1, 1); print ''; // Validaty duration - print ''.$langs->trans("ValidityDuration").' '.$langs->trans("days").''; + print ''.$langs->trans("ValidityDuration").''.img_picto('', 'clock').'  '.$langs->trans("days").''; // Terms of payment print ''.$langs->trans('PaymentConditionsShort').''; + print img_picto('', 'paiment'); $form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id), 'cond_reglement_id', -1, 1); print ''; // Mode of payment print ''.$langs->trans('PaymentMode').''; + print img_picto('', 'bank').' '; $form->select_types_paiements((GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $soc->mode_reglement_id), 'mode_reglement_id'); print ''; // Bank Account if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) { print ''.$langs->trans('BankAccount').''; + print img_picto('', 'bank_account'); $form->select_comptes($soc->fk_account, 'fk_account', 0, '', 1); print ''; } @@ -1588,6 +1617,7 @@ if ($action == 'create') if (!empty($conf->commande->enabled)) print ' ('.$langs->trans('AfterOrder').')'; print ''; + print img_picto('', 'clock').' '; $form->selectAvailabilityDelay('', 'availability_id', '', 1); print ''; @@ -1597,13 +1627,24 @@ if ($action == 'create') $shipping_method_id = $soc->shipping_method_id; } print ''.$langs->trans('SendingMethod').''; + print img_picto('', 'object_dollyrevert').' '; print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1); print ''; } + // Warehouse + if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + print ''.$langs->trans('Warehouse').''; + print img_picto('', 'stock').$formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth175 maxwidth500 widthcentpercentminusxx'); + print ''; + } + // Delivery date (or manufacturing) print ''.$langs->trans("DeliveryDate").''; print ''; + print img_picto('', 'object_calendarday').' '; if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") { $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); $syear = date("Y", $tmpdte); @@ -1621,6 +1662,7 @@ if ($action == 'create') $langs->load("projects"); print ''; print ''.$langs->trans("Project").''; + print img_picto('', 'project'); $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); print ' id).'">'; print ''; @@ -1641,6 +1683,7 @@ if ($action == 'create') print ''; print ''.$langs->trans("DefaultModel").''; print ''; + print img_picto('', 'pdf').' '; $liste = ModelePDFPropales::liste_modeles($db); print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF)); print ""; @@ -2097,6 +2140,24 @@ if ($action == 'create') print ''; } + // Warehouse + if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL)) { + $langs->load('stocks'); + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + print ''; + $editenable = $usercancreate; + print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); + print ''; + if ($action == 'editwarehouse') { + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1); + } else { + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none'); + } + print ''; + print ''; + } + // Origin of demand print ''; print ''; } + if (!empty($arrayfields['s.name_alias']['checked'])) + { + print ''; + } if (!empty($arrayfields['s.town']['checked'])) print ''; if (!empty($arrayfields['s.zip']['checked'])) print ''; // State @@ -670,6 +700,27 @@ if ($resql) print ajax_combobox('search_availability'); print ''; } + // Shipping Method + if (!empty($arrayfields['p.fk_shipping_method']['checked'])) + { + print ''; + } + // Payment term + if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) + { + print ''; + } + // Payment mode + if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) + { + print ''; + } if (!empty($arrayfields['p.total_ht']['checked'])) { // Amount @@ -821,6 +872,7 @@ if ($resql) if (!empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['pr.title']['checked'])) print_liste_field_titre($arrayfields['pr.title']['label'], $_SERVER["PHP_SELF"], 'pr.title', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); @@ -830,6 +882,9 @@ if ($resql) if (!empty($arrayfields['p.fin_validite']['checked'])) print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['p.date_livraison']['checked'])) print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'ddelivery', '', $param, 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['ava.rowid']['checked'])) print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.fk_shipping_method']['checked'])) print_liste_field_titre($arrayfields['p.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "p.fk_shipping_method", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['p.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['p.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "p.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'], $_SERVER["PHP_SELF"], 'p.tva', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder); @@ -981,6 +1036,15 @@ if ($resql) if (!$i) $totalarray['nbfield']++; } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Town if (!empty($arrayfields['s.town']['checked'])) { @@ -1064,7 +1128,30 @@ if ($resql) print ''; if (!$i) $totalarray['nbfield']++; } - + //Shipping Method + if (!empty($arrayfields['p.fk_shipping_method']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Payment terms + if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Payment mode + if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } // Amount HT if (!empty($arrayfields['p.total_ht']['checked'])) { @@ -1105,7 +1192,6 @@ if ($resql) if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced'; $totalarray['val']['p.total_invoiced'] += $totalInvoicedTTC; } - // Currency if (!empty($arrayfields['p.multicurrency_code']['checked'])) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b8061bcea93..6dd6fc6911a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -113,11 +113,6 @@ $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { - if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $object->warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE; - if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $object->warehouse_id = $user->fk_warehouse; -} - $error = 0; $date_delivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); @@ -633,7 +628,7 @@ if (empty($reshook)) $predef = ''; $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $price_ht = price2num(GETPOST('price_ht'), 'MU'); - $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU'); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { @@ -644,7 +639,7 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = price2num(GETPOST('qty'.$predef, 'alpha')); + $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha')) : 0); // Extrafields @@ -846,6 +841,11 @@ if (empty($reshook)) $desc = $prod->description; } + //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time + if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { + $product_desc=''; + } + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); @@ -1533,6 +1533,13 @@ if ($action == 'create' && $usercancreate) $note_public = $object->getDefaultCreateValueFor('note_public'); } + //Warehouse default if null + if (!empty($conf->stock->enabled) && empty($warehouse_id) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) + { + if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE; + if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $warehouse_id = $user->fk_warehouse; + } + print ''; print ''; print ''; @@ -1590,6 +1597,7 @@ if ($action == 'create' && $usercancreate) if ($socid > 0) { // Contacts (ask contact only if thirdparty already defined). print "'; @@ -1608,14 +1616,14 @@ if ($action == 'create' && $usercancreate) // Date print ''; // Date delivery planned print ''; print '\n"; print ''; @@ -1626,6 +1634,7 @@ if ($action == 'create' && $usercancreate) // Mode de reglement print ''; @@ -1633,24 +1642,27 @@ if ($action == 'create' && $usercancreate) if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && !empty($conf->banque->enabled)) { print ''; } // Delivery delay print ''; // Shipping Method if (!empty($conf->expedition->enabled)) { print ''; } // Warehouse - if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); print ''; print ''; } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) + { + print ''; + } // Town if (!empty($arrayfields['s.town']['checked'])) print ''; // Zip @@ -726,6 +753,27 @@ if ($resql) print ''; print ''; } + // Shipping Method + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) + { + print ''; + } + // Payment term + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) + { + print ''; + } + // Payment mode + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) + { + print ''; + } if (!empty($arrayfields['c.total_ht']['checked'])) { // Amount @@ -881,6 +929,7 @@ if ($resql) if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); @@ -888,6 +937,9 @@ if ($resql) if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['c.date_commande']['checked'])) print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['c.date_delivery']['checked'])) print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) print_liste_field_titre($arrayfields['c.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "c.fk_shipping_method", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['c.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['c.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); @@ -1038,6 +1090,14 @@ if ($resql) if (!$i) $totalarray['nbfield']++; } // Town + if (!empty($arrayfields['s.name_alias']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Town if (!empty($arrayfields['s.town']['checked'])) { print ''; if (!$i) $totalarray['nbfield']++; } + //Shipping Method + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Payment terms + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Payment mode + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } // Amount HT if (!empty($arrayfields['c.total_ht']['checked'])) { @@ -1326,7 +1410,6 @@ if ($resql) print ''; if (!$i) $totalarray['nbfield']++; } - // Status if (!empty($arrayfields['c.fk_statut']['checked'])) { diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 0efe367089c..0c2db362e75 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2021 Alexandre Spangaro * Copyright (C) 2018-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -266,6 +266,18 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->banque->m $object->datev = $newdatepayment; } + if (GETPOSTISSET("clone_sens")) { + $object->sens = GETPOST("clone_sens", 'int'); + } else { + $object->sens = $object->sens; + } + + if (GETPOST("clone_amount", "alpha")) { + $object->amount = price2num(GETPOST("clone_amount", "alpha")); + } else { + $object->amount = price2num($object->amount); + } + if ($object->check()) { $id = $object->create($user); @@ -486,14 +498,19 @@ if ($id) // Clone confirmation if ($action === 'clone') { + $set_value_help = $form->textwithpicto('', $langs->trans($langs->trans("AccountingDirectionHelp"))); + $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit")); + $formquestion = array( array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label), - ); - $formquestion[] = array('type' => 'date', 'tdclass'=>'fieldrequired', 'name' => 'clone_date_payment', 'label' => $langs->trans("DatePayment"), 'value' => -1); - $formquestion[] = array('type' => 'date', 'name' => 'clone_date_value', 'label' => $langs->trans("DateValue"), 'value' => -1); - $formquestion[] = array('type' => 'other', 'tdclass'=>'fieldrequired', 'name' => 'accountid', 'label' => $langs->trans("BankAccount"), 'value' => $form->select_comptes($accountid, "accountid", 0, '', 1, '', 0, 'minwidth200', 1)); + array('type' => 'date', 'tdclass'=>'fieldrequired', 'name' => 'clone_date_payment', 'label' => $langs->trans("DatePayment"), 'value' => -1), + array('type' => 'date', 'name' => 'clone_date_value', 'label' => $langs->trans("DateValue"), 'value' => -1), + array('type' => 'other', 'tdclass'=>'fieldrequired', 'name' => 'clone_accountid', 'label' => $langs->trans("BankAccount"), 'value' => $form->select_comptes($object->fk_account, "accountid", 0, '', 1, '', 0, 'minwidth200', 1)), + array('type' => 'text', 'name' => 'clone_amount', 'label' => $langs->trans("Amount"), 'value' => price($object->amount)), + array('type' => 'select', 'name' => 'clone_sens', 'label' => $langs->trans("Sens") . ' ' . $set_value_help, 'values' => $sensarray, 'default' => $object->sens), + ); - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 300); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 350); } print dol_get_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto); diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 25505325c98..35d70e1edd6 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -439,7 +439,7 @@ if (empty($reshook)) $predef = ''; $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $price_ht = price2num(GETPOST('price_ht'), 'MU'); - $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU'); $prod_entry_mode = GETPOST('prod_entry_mode', 'alpha'); if ($prod_entry_mode == 'free') { @@ -450,7 +450,7 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = price2num(GETPOST('qty'.$predef), 'alpha'); + $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); $remise_percent = GETPOST('remise_percent'.$predef); // Extrafields diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index cbcb49583b1..7250d673494 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -977,11 +977,14 @@ if (empty($reshook)) if ($_POST['type'] == Facture::TYPE_REPLACEMENT) { $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($dateinvoice)) - { + if (empty($dateinvoice)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $action = 'create'; + } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { + $error++; + setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); + $action = 'create'; } if (!($_POST['fac_replacement'] > 0)) { @@ -1029,7 +1032,7 @@ if (empty($reshook)) // Credit note invoice if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) { - $sourceinvoice = GETPOST('fac_avoir'); + $sourceinvoice = GETPOST('fac_avoir', 'int'); if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) { $error++; @@ -1038,11 +1041,14 @@ if (empty($reshook)) } $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($dateinvoice)) - { + if (empty($dateinvoice)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $action = 'create'; + } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { + $error++; + setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); + $action = 'create'; } $date_pointoftax = dol_mktime(12, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int')); @@ -1255,11 +1261,14 @@ if (empty($reshook)) if (($_POST['type'] == Facture::TYPE_STANDARD || $_POST['type'] == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec', 'int') > 0) { $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($dateinvoice)) - { + if (empty($dateinvoice)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $action = 'create'; + } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { + $error++; + setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); + $action = 'create'; } $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); @@ -1305,11 +1314,14 @@ if (empty($reshook)) } $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($dateinvoice)) - { + if (empty($dateinvoice)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $action = 'create'; + } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { + $error++; + setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); + $action = 'create'; } $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); @@ -1725,11 +1737,15 @@ if (empty($reshook)) // Situation invoices if (GETPOST('type') == Facture::TYPE_SITUATION && (!empty($_POST['situations']))) { - $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($datefacture)) { + $dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + if (empty($dateinvoice)) { $error++; $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")); setEventMessages($mesg, null, 'errors'); + } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { + $error++; + setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); + $action = 'create'; } $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); @@ -1811,7 +1827,7 @@ if (empty($reshook)) } $object->fetch_thirdparty(); - $object->date = $datefacture; + $object->date = $dateinvoice; $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'restricthtml')); $object->note = trim(GETPOST('note', 'restricthtml')); @@ -1894,7 +1910,7 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc', 'none') ?GETPOST('dp_desc', 'restricthtml') : ''); + $product_desc =(GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $price_ht = price2num(GETPOST('price_ht')); $price_ht_devise = price2num(GETPOST('multicurrency_price_ht')); $prod_entry_mode = GETPOST('prod_entry_mode', 'alpha'); @@ -2064,6 +2080,11 @@ if (empty($reshook)) $desc = $prod->description; } + //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time + if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { + $product_desc=''; + } + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); @@ -3342,11 +3363,11 @@ if ($action == 'create') print ''; } - $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $newdateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); // Date invoice print ''; // Date point of tax @@ -3504,7 +3525,7 @@ if ($action == 'create') $htmltext = ''; if (GETPOST('fac_rec', 'int') > 0) { - $dateexample = ($datefacture ? $datefacture : $dateinvoice); + $dateexample = ($newdateinvoice ? $newdateinvoice : $dateinvoice); if (empty($dateexample)) $dateexample = dol_now(); $substitutionarray = array( '__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($exampletemplateinvoice->total_ht).')', diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a1bde7e4f3d..da5bab5b47e 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -85,6 +85,7 @@ $search_type = GETPOST('search_type', 'int'); $search_project_ref = GETPOST('search_project_ref', 'alpha'); $search_project = GETPOST('search_project', 'alpha'); $search_societe = GETPOST('search_societe', 'alpha'); +$search_societe_alias = GETPOST('search_societe_alias', 'alpha'); $search_montant_ht = GETPOST('search_montant_ht', 'alpha'); $search_montant_vat = GETPOST('search_montant_vat', 'alpha'); $search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha'); @@ -182,6 +183,7 @@ $arrayfields = array( 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>40), 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>40), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>50), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1, 'position'=>51), 's.town'=>array('label'=>"Town", 'checked'=>1, 'position'=>55), 's.zip'=>array('label'=>"Zip", 'checked'=>1, 'position'=>60), 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>65), @@ -254,6 +256,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_project_ref = ''; $search_project = ''; $search_societe = ''; + $search_societe_alias = ''; $search_montant_ht = ''; $search_montant_vat = ''; $search_montant_localtax1 = ''; @@ -422,7 +425,7 @@ $sql .= ' f.datef as df, f.date_valid, f.date_lim_reglement as datelimite, f.mod $sql .= ' f.paye as paye, f.fk_statut, f.close_code,'; $sql .= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,'; $sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; -$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,'; +$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as name_alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,'; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= " country.code as country_code,"; @@ -486,12 +489,14 @@ if ($search_type != '' && $search_type != '-1') $sql .= " AND f.type IN (".$db-> if ($search_project_ref) $sql .= natural_search('p.ref', $search_project_ref); if ($search_project) $sql .= natural_search('p.title', $search_project); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); +if ($search_societe_alias) $sql .= natural_search('s.name_alias', $search_societe_alias); if ($search_town) $sql .= natural_search('s.town', $search_town); if ($search_zip) $sql .= natural_search("s.zip", $search_zip); if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); +if ($search_company_alias) $sql .= natural_search('s.name_alias', $search_company_alias); if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1); if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1); @@ -551,7 +556,7 @@ if (!$sall) $sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; $sql .= ' f.fk_user_author, f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva,'; $sql .= ' f.multicurrency_total_tva, f.multicurrency_total_ttc,'; - $sql .= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; + $sql .= ' s.rowid, s.nom, s.name_alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; $sql .= ' typent.code,'; $sql .= ' state.code_departement, state.nom,'; $sql .= ' country.code,'; @@ -628,6 +633,7 @@ if ($resql) if ($search_project) $param .= '&search_project='.urlencode($search_project); if ($search_type != '') $param .= '&search_type='.urlencode($search_type); if ($search_societe) $param .= '&search_societe='.urlencode($search_societe); + if ($search_societe_alias) $param .= '&search_societe_alias='.urlencode($search_societe_alias); if ($search_town) $param .= '&search_town='.urlencode($search_town); if ($search_zip) $param .= '&search_zip='.urlencode($search_zip); if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); @@ -861,6 +867,11 @@ if ($resql) { print ''; } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) + { + print ''; + } // Town if (!empty($arrayfields['s.town']['checked'])) print ''; // Zip @@ -1099,6 +1110,7 @@ if ($resql) if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER['PHP_SELF'], "p.title", '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER['PHP_SELF'], 's.name_alias', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); @@ -1361,6 +1373,14 @@ if ($resql) print ''; if (!$i) $totalarray['nbfield']++; } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } // Town if (!empty($arrayfields['s.town']['checked'])) { diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index bf28ceb0996..ccb413ecf6f 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -182,8 +182,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->tax->charges->cre if (!$dateech) { - setEventMessages($langs->trans("ErrorFieldReqrequire_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; -uired", $langs->transnoentities("Date")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $action = 'edit'; } elseif (!$dateperiod) { diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 35c4bdc43e5..566b044c81e 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -200,7 +200,7 @@ if (empty($reshook)) } } } - $object->email = (string) GETPOST("email", 'alpha'); + $object->email = (string) GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL); $object->no_email = GETPOST("no_email", "int"); $object->phone_pro = (string) GETPOST("phone_pro", 'alpha'); $object->phone_perso = (string) GETPOST("phone_perso", 'alpha'); @@ -225,44 +225,59 @@ if (empty($reshook)) $action = 'create'; } - if (!GETPOST("lastname")) { + if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1 && $object->no_email==-1 && !empty($object->email)) { + $error++; + $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")); + $action = 'create'; + } + + if (!empty($object->email) && !isValidEMail($object->email)) + { + $langs->load("errors"); + $error++; + $errors[] = $langs->trans("ErrorBadEMail", GETPOST('email', 'alpha')); + $action = 'create'; + } + + if (empty($object->lastname)) { $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); $action = 'create'; } - if (!$error) - { + if (empty($error)) { $id = $object->create($user); - if ($id <= 0) - { + if ($id <= 0) { $error++; $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); $action = 'create'; - } else { - // Categories association - $contcats = GETPOST('contcats', 'array'); - $object->setCategories($contcats); + } + } - // Add mass emailing flag into table mailing_unsubscribe - if (GETPOST('no_email', 'int') && $object->email) - { - $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - if (empty($obj->nb)) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; - $resql = $db->query($sql); - } - } + if (empty($error)) { + // Categories association + $contcats = GETPOST('contcats', 'array'); + if (count($contcats)>0) { + $result = $object->setCategories($contcats); + if ($result <= 0) { + $error++; + $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); + $action = 'create'; } } } - if (!$error && $id > 0) + if (empty($error) && !empty($conf->mailing->enabled) && !empty($object->email)) { + // Add mass emailing flag into table mailing_unsubscribe + $result=$object->setNoEmail($object->no_email); + if ($result<0) { + $error++; + $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); + $action = 'create'; + } + } + + if (empty($error) && $id > 0) { $db->commit(); if (!empty($backtopage)) $url = $backtopage; @@ -298,12 +313,26 @@ if (empty($reshook)) if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) { - if (empty($_POST["lastname"])) + if (empty(GETPOST("lastname", 'alpha'))) { $error++; $errors = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); $action = 'edit'; } + if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1 && GETPOST("no_email", "int")==-1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) { + $error++; + $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")); + $action = 'edit'; + } + + if (!empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)) && !isValidEMail(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) + { + $langs->load("errors"); + $error++; + $errors[] = $langs->trans("ErrorBadEMail", GETPOST('email', 'alpha')); + $action = 'edit'; + } + if (!$error) { $contactid = GETPOST("contactid", 'int'); @@ -374,7 +403,7 @@ if (empty($reshook)) $object->state_id = GETPOST("state_id", 'int'); $object->country_id = GETPOST("country_id", 'int'); - $object->email = (string) GETPOST("email", 'alpha'); + $object->email = (string) GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL); $object->no_email = GETPOST("no_email", "int"); //$object->jabberid = GETPOST("jabberid", 'alpha'); //$object->skype = GETPOST("skype", 'alpha'); @@ -411,31 +440,15 @@ if (empty($reshook)) $categories = GETPOST('contcats', 'array'); $object->setCategories($categories); - $no_email = GETPOST('no_email', 'int'); - // Update mass emailing flag into table mailing_unsubscribe if (GETPOSTISSET('no_email') && $object->email) { - if ($no_email) - { - $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - $noemail = $obj->nb; - if (empty($noemail)) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; - $resql = $db->query($sql); - } - } - } else { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$db->escape($object->email)."' AND entity = ".$db->escape(getEntity('mailing', 0)); - $resql = $db->query($sql); + $no_email = GETPOST('no_email', 'int'); + $result=$object->setNoEmail($no_email); + if ($result<0) { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit'; } - - $object->no_email = $no_email; } $object->old_lastname = ''; @@ -738,27 +751,36 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; print ''; + //Unsubscribe if (!empty($conf->mailing->enabled)) { - $noemail = ''; - if (empty($noemail) && !empty($object->email)) + if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1) { - $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; - //print $sql; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - $noemail = $obj->nb; + print "\n".''."\n"; + } + if (!GETPOSTISSET("no_email") && !empty($object->email)) + { + $result=$object->getNoEmail(); + if ($result<0) { + setEventMessages($object->error, $object->errors, 'errors'); } } - print ''; - print ''; - print ''; + print ''; + print ''; print ''; } - print ''; + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { @@ -774,39 +796,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } } } - // if (! empty($conf->socialnetworks->enabled)) - // { - // // Jabber - // if (! empty($conf->global->SOCIALNETWORKS_JABBER)) - // { - // print ''; - // print ''; - // } - // // Skype - // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) - // { - // print ''; - // print ''; - // } - // // Twitter - // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) - // { - // print ''; - // print ''; - // } - // // Facebook - // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - // { - // print ''; - // print ''; - // } - // // LinkedIn - // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) - // { - // print ''; - // print ''; - // } - // } // Visibility print ''; // Unsubscribe - print ''; if (!empty($conf->mailing->enabled)) { - $noemail = ''; - if (empty($noemail) && !empty($object->email)) + if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1) { - $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; - //print $sql; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - $noemail = $obj->nb; + print "\n".''."\n"; + } + if (!GETPOSTISSET("no_email") && !empty($object->email)) + { + $result=$object->getNoEmail(); + if ($result<0) { + setEventMessages($object->error, $object->errors, 'errors'); } } - - print ''; - print ''; - } else { - print ''; + print ''; + print ''; + print ''; + print ''; } - print ''; if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { @@ -1300,20 +1301,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Unsubscribe opt-out if (!empty($conf->mailing->enabled)) { - //print 'eee'.$object->email; - $noemail = $object->no_email; - if (empty($noemail) && !empty($object->email)) - { - $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; - //print $sql; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - $noemail = $obj->nb; - } + $result=$object->getNoEmail(); + if ($result<0) { + setEventMessages($object->error, $object->errors, 'errors'); } - print ''; + print ''; } print ''; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER) && $action == 'view') { - $out .= ''; + if ($display_type=='card') { + $out .= ''; + $out .= ''; + + $out .= ($display_type=='card' ? '' : ''); $html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : ''; - - $out .= ''; + $out .= ($display_type=='card' ? '' : ''); /*for($ii = 0; $ii < ($colspan - 1); $ii++) { $out .=''; }*/ - if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= ''; - else $out .= ''; + if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) { + $out .= ($display_type=='card' ? '' : ''); + } else { + $out .= ($display_type=='card' ? '' : ''); + } $e++; } } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 3191e5edd47..1eb3b9911ba 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -697,6 +697,12 @@ class Conf if (!empty($this->global->MAIN_TZUSERINPUTKEY)) $this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel' + if (!empty($this->global->PRODUIT_AUTOFILL_DESC)) { + $this->global->MAIN_NO_CONCAT_DESCRIPTION = 1; + } else { + unset($this->global->MAIN_NO_CONCAT_DESCRIPTION); + } + // For backward compatibility if (isset($this->product)) $this->produit = $this->product; if (isset($this->facture)) $this->invoice = $this->facture; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index cf499bbde5d..21db0656c0e 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -924,15 +924,15 @@ class ExtraFields * Return HTML string to put an input field into a page * Code very similar with showInputField of common object * - * @param string $key Key of attribute - * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) - * @param string $moreparam To add more parametes on html input tag - * @param string $keysuffix Prefix string to add after name and id of field (can be used to avoid duplicate names) - * @param string $keyprefix Suffix string to add before name and id of field (can be used to avoid duplicate names) - * @param string $morecss More css (to defined size of field. Old behaviour: may also be a numeric) - * @param int $objectid Current object id - * @param string $extrafieldsobjectkey If defined (for example $object->table_element), use the new method to get extrafields data - * @param string $mode 1=Used for search filters + * @param string $key Key of attribute + * @param string|array $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value); for dates in filter mode, a range array('start'=>, 'end'=>) should be provided + * @param string $moreparam To add more parameters on html input tag + * @param string $keysuffix Prefix string to add after name and id of field (can be used to avoid duplicate names) + * @param string $keyprefix Suffix string to add before name and id of field (can be used to avoid duplicate names) + * @param string $morecss More css (to defined size of field. Old behaviour: may also be a numeric) + * @param int $objectid Current object id + * @param string $extrafieldsobjectkey If defined (for example $object->table_element), use the new method to get extrafields data + * @param string $mode 1=Used for search filters * @return string */ public function showInputField($key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $objectid = 0, $extrafieldsobjectkey = '', $mode = 0) @@ -1024,8 +1024,22 @@ class ExtraFields // Do not show current date when field not required (see selectDate() method) if (!$required && $value == '') $value = '-1'; - // TODO Must also support $moreparam - $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); + if ($mode == 1) { + // search filter on a date extrafield shows two inputs to select a date range + $prefill = array( + 'start' => isset($value['start']) ? $value['start'] : '', + 'end' => isset($value['end']) ? $value['end'] : ''); + $out = '
' + . $langs->trans('From') . ' ' + . $form->selectDate($prefill['start'], $keyprefix . $key . $keysuffix . '_start', 0, 0, 1) + . '
' + . $langs->trans('to') . ' ' + . $form->selectDate($prefill['end'], $keyprefix . $key . $keysuffix . '_end', 0, 0, 1) + . '
'; + } else { + // TODO Must also support $moreparam + $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); + } } elseif (in_array($type, array('int', 'integer'))) { $tmp = explode(',', $size); @@ -1907,15 +1921,29 @@ class ExtraFields * @param string $key Key of attribute * @param string $object Object * @param int $colspan Value of colspan to use (it must includes the first column with title) + * @param string $display_type "card" for form display, "line" for document line display (extrafields on propal line, order line, etc...) * @return string HTML code with line for separator */ - public function showSeparator($key, $object, $colspan = 2) + public function showSeparator($key, $object, $colspan = 2, $display_type = 'card') { global $langs; - $out = '
'; + $out .= ''; + $out .= ''; + $out .= ''; $extrafield_param = $this->attributes[$object->table_element]['param'][$key]; if (!empty($extrafield_param) && is_array($extrafield_param)) { @@ -1925,27 +1953,27 @@ class ExtraFields $extrafield_collapse_display_value = intval($extrafield_param_list[0]); if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) { // Set the collapse_display status to cookie in priority or if ignorecollapsesetup is 1, if cookie and ignorecollapsesetup not defined, use the setup. - $collapse_display = ((isset($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key]) || GETPOST('ignorecollapsesetup', 'int')) ? ($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key] ? true : false) : ($extrafield_collapse_display_value == 2 ? false : true)); - $extrafields_collapse_num = $this->attributes[$object->table_element]['pos'][$key]; + $collapse_display = ((isset($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.(!empty($object->id)?'_'.$object->id:'')]) || GETPOST('ignorecollapsesetup', 'int')) ? ($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.(!empty($object->id)?'_'.$object->id:'')] ? true : false) : ($extrafield_collapse_display_value == 2 ? false : true)); + $extrafields_collapse_num = $this->attributes[$object->table_element]['pos'][$key].(!empty($object->id)?'_'.$object->id:''); $out .= ''; $out .= ''."\n"; print '
'; @@ -1356,7 +1392,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Email / Web print '
'; - print ''; + print 'browser->layout == 'phone') || empty($conf->mailing->enabled) ? ' colspan="3"' : '').'>'.img_picto('', 'object_email').' '; + if (!empty($conf->mailing->enabled) && !empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) { + if ($conf->browser->layout == 'phone') print ''; + print ''; + print ''; + } + print ''; print ''; print ''; @@ -1512,13 +1554,29 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ""; //} + if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) + { + print '"; + } + + if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) + { + print '"; + } + // Supplier - //if ($object->fournisseur) { - print '"; - //} + if (!empty($conf->fournisseur->enabled)) { + print '"; + } } // Multicurrency @@ -1555,6 +1613,39 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '
'; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 10a2238088b..f689e7c3a4c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -208,6 +208,8 @@ class Propal extends CommonObject public $demand_reason_id; public $demand_reason_code; + public $warehouse_id; + public $extraparams = array(); /** @@ -231,8 +233,6 @@ class Propal extends CommonObject public $multicurrency_total_tva; public $multicurrency_total_ttc; - public $oldcopy; - /** * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') @@ -298,6 +298,7 @@ class Propal extends CommonObject 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'PDFTemplate', 'enabled'=>1, 'visible'=>0, 'position'=>180), 'date_livraison' =>array('type'=>'date', 'label'=>'DateDeliveryPlanned', 'enabled'=>1, 'visible'=>-1, 'position'=>185), 'fk_shipping_method' =>array('type'=>'integer', 'label'=>'ShippingMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>190), + 'fk_warehouse' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Fk warehouse', 'enabled'=>1, 'visible'=>-1, 'position'=>191), 'fk_availability' =>array('type'=>'integer', 'label'=>'Availability', 'enabled'=>1, 'visible'=>-1, 'position'=>195), 'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>0, 'position'=>200), // deprecated 'fk_input_reason' =>array('type'=>'integer', 'label'=>'InputReason', 'enabled'=>1, 'visible'=>-1, 'position'=>205), @@ -1051,6 +1052,7 @@ class Propal extends CommonObject $sql .= ", ref_client"; $sql .= ", date_livraison"; $sql .= ", fk_shipping_method"; + $sql .= ", fk_warehouse"; $sql .= ", fk_availability"; $sql .= ", fk_input_reason"; $sql .= ", fk_projet"; @@ -1083,6 +1085,7 @@ class Propal extends CommonObject $sql .= ", '".$this->db->escape($this->ref_client)."'"; $sql .= ", ".(empty($delivery_date) ? "NULL" : "'".$this->db->idate($delivery_date)."'"); $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : 'NULL'); + $sql .= ", ".($this->warehouse_id > 0 ? $this->warehouse_id : 'NULL'); $sql .= ", ".$this->availability_id; $sql .= ", ".$this->demand_reason_id; $sql .= ", ".($this->fk_project ? $this->fk_project : "null"); @@ -1437,6 +1440,7 @@ class Propal extends CommonObject $sql .= ", p.fk_mode_reglement"; $sql .= ', p.fk_account'; $sql .= ", p.fk_shipping_method"; + $sql .= ", p.fk_warehouse"; $sql .= ", p.fk_incoterms, p.location_incoterms"; $sql .= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc"; $sql .= ", p.tms as date_modification"; @@ -1510,6 +1514,7 @@ class Propal extends CommonObject $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated $this->delivery_date = $this->db->jdate($obj->delivery_date); $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; + $this->warehouse_id = ($obj->fk_warehouse > 0) ? $obj->fk_warehouse : null; $this->availability_id = $obj->fk_availability; $this->availability_code = $obj->availability_code; $this->availability = $obj->availability; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index d8f523f16da..1e3f4080678 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -47,6 +47,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'categories')); +if (!empty($conf->expedition->enabled)) $langs->loadLangs(array('sendings')); $socid = GETPOST('socid', 'int'); @@ -66,6 +67,7 @@ $search_refproject = GETPOST('search_refproject', 'alpha'); $search_project = GETPOST('search_project', 'alpha'); $search_societe = GETPOST('search_societe', 'alpha'); +$search_societe_alias = GETPOST('search_societe_alias', 'alpha'); $search_montant_ht = GETPOST('search_montant_ht', 'alpha'); $search_montant_vat = GETPOST('search_montant_vat', 'alpha'); $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); @@ -89,6 +91,9 @@ $search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_st $search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_endmonth', 'int'), GETPOST('search_datedelivery_endday', 'int'), GETPOST('search_datedelivery_endyear', 'int')); $search_availability = GETPOST('search_availability', 'int'); $search_categ_cus = GETPOST("search_categ_cus", 'int'); +$search_fk_cond_reglement = GETPOST("search_fk_cond_reglement", 'int'); +$search_fk_shipping_method = GETPOST("search_fk_shipping_method", 'int'); +$search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'int'); $search_btn = GETPOST('button_search', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha'); @@ -157,6 +162,7 @@ $arrayfields = array( 'pr.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), 'pr.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1), 's.town'=>array('label'=>"Town", 'checked'=>1), 's.zip'=>array('label'=>"Zip", 'checked'=>1), 'state.nom'=>array('label'=>"StateShort", 'checked'=>0), @@ -166,6 +172,9 @@ $arrayfields = array( 'p.fin_validite'=>array('label'=>"DateEnd", 'checked'=>1), 'p.date_livraison'=>array('label'=>"DeliveryDate", 'checked'=>0), 'ava.rowid'=>array('label'=>"AvailabilityPeriod", 'checked'=>0), + 'p.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>0, 'enabled'=>!empty($conf->expedition->enabled)), + 'p.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>0), + 'p.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>0), 'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), 'p.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), 'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), @@ -187,6 +196,7 @@ $arrayfields = array( 'p.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES))), 'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -215,6 +225,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_refproject = ''; $search_project = ''; $search_societe = ''; + $search_societe_alias = ''; $search_montant_ht = ''; $search_montant_vat = ''; $search_montant_ttc = ''; @@ -243,6 +254,9 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $toselect = ''; $search_array_options = array(); $search_categ_cus = 0; + $search_fk_cond_reglement = ''; + $search_fk_shipping_method = ''; + $search_fk_mode_reglement = ''; } if ($object_statut != '') $search_status = $object_statut; @@ -278,7 +292,7 @@ $help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos' $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; +$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql .= " typent.code as typent_code,"; $sql .= " ava.rowid as availability,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; @@ -286,6 +300,7 @@ $sql .= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.t $sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva as multicurrency_total_vat, p.multicurrency_total_ttc,'; $sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,'; $sql .= ' p.note_public, p.note_private,'; +$sql .= ' p.fk_cond_reglement,p.fk_mode_reglement,p.fk_shipping_method,'; $sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,"; $sql .= ' u.login'; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; @@ -337,6 +352,7 @@ if ($search_project) $sql .= natural_search('pr.title', $search_project); if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->sanitize($db->escape($search_availability)).')'; if ($search_societe) $sql .= natural_search('s.nom', $search_societe); +if ($search_societe_alias) $sql .= natural_search('s.name_alias', $search_societe_alias); if ($search_login) $sql .= natural_search("u.login", $search_login); if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1); if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1); @@ -352,6 +368,10 @@ if ($sall) { if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; +if ($search_fk_cond_reglement > 0) $sql .= " AND p.fk_cond_reglement = ".$db->escape($search_fk_cond_reglement); +if ($search_fk_shipping_method > 0) $sql .= " AND p.fk_shipping_method = ".$db->escape($search_fk_shipping_method); +if ($search_fk_mode_reglement > 0) $sql .= " AND p.fk_mode_reglement = ".$db->escape($search_fk_mode_reglement); + if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$db->escape($search_product_category); if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; if ($search_status != '' && $search_status != '-1') @@ -443,6 +463,7 @@ if ($resql) if ($search_refcustomer) $param .= '&search_refcustomer='.urlencode($search_refcustomer); if ($search_refproject) $param .= '&search_refproject='.urlencode($search_refproject); if ($search_societe) $param .= '&search_societe='.urlencode($search_societe); + if ($search_societe_alias) $param .= '&search_societe_alias='.urlencode($search_societe_alias); if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); if ($search_montant_ht) $param .= '&search_montant_ht='.urlencode($search_montant_ht); @@ -458,6 +479,9 @@ if ($resql) if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); if ($search_product_category != '') $param .= '&search_product_category='.$search_product_category; + if ($search_fk_cond_reglement > 0) $param .= '&search_fk_cond_reglement='.$search_fk_cond_reglement; + if ($search_fk_shipping_method > 0) $param .= '&search_fk_shipping_method='.$search_fk_shipping_method; + if ($search_fk_mode_reglement > 0) $param .= '&search_fk_mode_reglement='.$search_fk_mode_reglement; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -602,6 +626,12 @@ if ($resql) print ''; print ''; + print ''; + print ''; + $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1); + print ''; + $form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', -1, 1, 1); + print ''; + $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1); + print ''; + print $obj->alias; + print ''; + $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); + print ''; + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none'); + print ''; + $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); + print '
".$langs->trans("DefaultContact").''; + print img_picto('', 'contact'); $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist, '', 1); print '
'.$langs->trans('Date').''; - print $form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date + print img_picto('', 'object_calendarday').' '.$form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date print '
'.$langs->trans("DateDeliveryPlanned").''; $date_delivery = ($date_delivery ? $date_delivery : $object->date_delivery); - print $form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1); + print img_picto('', 'object_calendarday').' '.$form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1); print "
'.$langs->trans('PaymentMode').''; + print img_picto('', 'bank').' '; $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id'); print '
'.$langs->trans('BankAccount').''; + print img_picto('', 'bank_account'); $form->select_comptes($fk_account, 'fk_account', 0, '', 1); print '
'.$langs->trans('AvailabilityPeriod').''; + print img_picto('', 'clock').' '; $form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1); print '
'.$langs->trans('SendingMethod').''; + print img_picto('', 'object_dollyrevert').' '; print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1); print '
'.$langs->trans('Warehouse').''; @@ -1716,6 +1728,7 @@ if ($action == 'create' && $usercancreate) // Template to use by default print '
'.$langs->trans('DefaultModel').''; + print img_picto('', 'pdf').' '; include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; $liste = ModelePDFCommandes::liste_modeles($db); print $form->selectarray('model', $liste, $conf->global->COMMANDE_ADDON_PDF); @@ -2160,7 +2173,7 @@ if ($action == 'create' && $usercancreate) } // Warehouse - if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { $langs->load('stocks'); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3cc0fa72ae6..248a45c629a 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -200,6 +200,8 @@ class Commande extends CommonOrder public $special_code; public $source; // Order mode. How we received order (by phone, by email, ...) + public $warehouse_id; + public $extraparams = array(); public $linked_objects = array(); @@ -231,11 +233,6 @@ class Commande extends CommonOrder public $multicurrency_total_tva; public $multicurrency_total_ttc; - /** - * @var Commande clone of order object - */ - public $oldcopy; - //! key of module source when order generated from a dedicated module ('cashdesk', 'takepos', ...) public $module_source; //! key of pos source ('0', '1', ...) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 885081e84a1..1531dfd622e 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -67,6 +67,7 @@ $search_product_category = GETPOST('search_product_category', 'int'); $search_ref = GETPOST('search_ref', 'alpha') != '' ?GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha'); $search_ref_customer = GETPOST('search_ref_customer', 'alpha'); $search_company = GETPOST('search_company', 'alpha'); +$search_company_alias = GETPOST('search_company_alias', 'alpha'); $search_town = GETPOST('search_town', 'alpha'); $search_zip = GETPOST('search_zip', 'alpha'); $search_state = GETPOST("search_state", 'alpha'); @@ -95,7 +96,9 @@ $search_remove_btn = GETPOST('button_removefilter', 'alpha'); $search_project_ref = GETPOST('search_project_ref', 'alpha'); $search_project = GETPOST('search_project', 'alpha'); $search_shippable = GETPOST('search_shippable', 'aZ09'); - +$search_fk_cond_reglement = GETPOST("search_fk_cond_reglement", 'int'); +$search_fk_shipping_method = GETPOST("search_fk_shipping_method", 'int'); +$search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'int'); // Security check $id = (GETPOST('orderid') ?GETPOST('orderid', 'int') : GETPOST('id', 'int')); @@ -147,6 +150,7 @@ $arrayfields = array( 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>20), 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>25), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1, 'position'=>31), 's.town'=>array('label'=>"Town", 'checked'=>1, 'position'=>35), 's.zip'=>array('label'=>"Zip", 'checked'=>1, 'position'=>40), 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45), @@ -154,6 +158,9 @@ $arrayfields = array( 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55), 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60), 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE), 'position'=>65), + 'c.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>0, 'position'=>66 , 'enabled'=>!empty($conf->expedition->enabled)), + 'c.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>0, 'position'=>67), + 'c.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>0, 'position'=>68), 'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>75), 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>80), 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>85), @@ -206,6 +213,7 @@ if (empty($reshook)) $search_ref = ''; $search_ref_customer = ''; $search_company = ''; + $search_company_alias = ''; $search_town = ''; $search_zip = ""; $search_state = ""; @@ -235,6 +243,9 @@ if (empty($reshook)) $search_categ_cus = 0; $search_datecloture_start = ''; $search_datecloture_end = ''; + $search_fk_cond_reglement = ''; + $search_fk_shipping_method = ''; + $search_fk_mode_reglement = ''; } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) @@ -272,7 +283,7 @@ $help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_P $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as name_alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client, c.fk_user_author,'; @@ -280,7 +291,8 @@ $sql .= ' c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multic $sql .= ' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; $sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,'; $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,"; -$sql .= " u.login"; +$sql .= " u.login,"; +$sql .= ' c.fk_cond_reglement,c.fk_mode_reglement,c.fk_shipping_method'; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) @@ -353,6 +365,7 @@ if ($search_state) $sql .= natural_search("state.nom", if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); +if ($search_company_alias) $sql .= natural_search('s.name_alias', $search_company_alias); if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1); @@ -369,6 +382,9 @@ if ($search_project_ref != '') $sql .= natural_search("p.ref", $se if ($search_project != '') $sql .= natural_search("p.title", $search_project); if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; +if ($search_fk_cond_reglement > 0) $sql .= " AND c.fk_cond_reglement = ".$db->escape($search_fk_cond_reglement); +if ($search_fk_shipping_method > 0) $sql .= " AND c.fk_shipping_method = ".$db->escape($search_fk_shipping_method); +if ($search_fk_mode_reglement > 0) $sql .= " AND c.fk_mode_reglement = ".$db->escape($search_fk_mode_reglement); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -454,6 +470,7 @@ if ($resql) if ($search_datedelivery_end) $param .= '&search_datedelivery_end_day='.dol_print_date($search_datedelivery_end, '%d').'&search_datedelivery_end_month='.dol_print_date($search_datedelivery_end, '%m').'&search_datedelivery_end_year='.dol_print_date($search_datedelivery_end, '%Y'); if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); if ($search_company) $param .= '&search_company='.urlencode($search_company); + if ($search_company_alias) $param .= '&search_company_alias='.urlencode($search_company_alias); if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); @@ -478,6 +495,9 @@ if ($resql) if ($show_files) $param .= '&show_files='.urlencode($show_files); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($search_billed != '') $param .= '&search_billed='.urlencode($search_billed); + if ($search_fk_cond_reglement > 0) $param .= '&search_fk_cond_reglement='.$search_fk_cond_reglement; + if ($search_fk_shipping_method > 0) $param .= '&search_fk_shipping_method='.$search_fk_shipping_method; + if ($search_fk_mode_reglement > 0) $param .= '&search_fk_mode_reglement='.$search_fk_mode_reglement; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -678,6 +698,13 @@ if ($resql) print ''; print ''; + print ''; + print ''; + $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1); + print ''; + $form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', -1, 1, 1); + print ''; + $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1); + print ''; + print $obj->alias; + print ''; @@ -1094,6 +1154,30 @@ if ($resql) print ''; + $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); + print ''; + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none'); + print ''; + $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); + print ''.yn($obj->billed).'
'.$langs->trans('DateInvoice').''; - print $form->selectDate($datefacture ? $datefacture : $dateinvoice, '', '', '', '', "add", 1, 1); + print $form->selectDate($newdateinvoice ? $newdateinvoice : $dateinvoice, '', '', '', '', "add", 1, 1); print '
'; + print $obj->name_alias; + print '
'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'alpha') : $noemail), 1).''.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'int') : $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS), 1, false, ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1)).'
jabberid).'">
skype).'">
twitter).'">
facebook).'">
linkedin).'">
'; @@ -1050,28 +1039,40 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '
'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).'
'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'int') : $object->no_email), 1, false, ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1)).'
'.$langs->trans("No_Email").''.yn($noemail).'
'.$langs->trans("No_Email").''.yn($object->no_email).'
'.$langs->trans("ContactVisibility").''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 8fe4943d267..0283a01074d 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1180,6 +1180,20 @@ class Contact extends CommonObject } } + if (!$error) + { + // Remove Roles + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople = ".$this->id; + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->error .= $this->db->lasterror(); + $errorflag = -1; + } + } + if (!$error) { // Remove category @@ -1880,4 +1894,94 @@ class Contact extends CommonObject return "Error, mode/status not found"; } + + + /** + * Set "blacklist" mailing status + * + * @param int $no_email 1=Do not send mailing, 0=Ok to recieve mailling + * @return int <0 if KO, >0 if OK + */ + public function setNoEmail($no_email) + { + $error = 0; + + // Update mass emailing flag into table mailing_unsubscribe + if ($this->email) + { + $this->db->begin(); + + if ($no_email) + { + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$this->db->escape($this->email)."'"; + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + $noemail = $obj->nb; + if (empty($noemail)) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$this->db->escape($this->email)."', ".$this->db->escape(getEntity('mailing', 0)).", '".$this->db->idate(dol_now())."')"; + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + } + } + } else { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + } + } else { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$this->db->escape($this->email)."' AND entity = ".$this->db->escape(getEntity('mailing', 0)); + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + } + } + + if (empty($error)) { + $this->no_email = $no_email; + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return $error * -1; + } + } + + return 0; + } + + /** + * get "blacklist" mailing status + * set no_email attribut to 1 or 0 + * + * @return int <0 if KO, >0 if OK + */ + public function getNoEmail() + { + if ($this->email) + { + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($this->email)."'"; + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + $this->no_email = $obj->nb; + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + return -1; + } + } + return 0; + } } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 678ed9bbbd6..ca03905b834 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -385,7 +385,7 @@ if (empty($reshook)) $predef = ''; $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $price_ht = price2num(GETPOST('price_ht'), 'MU'); - $price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CR')); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CU')); if (GETPOST('prod_entry_mode', 'alpha') == 'free') { $idprod = 0; @@ -395,7 +395,7 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = price2num(GETPOST('qty'.$predef), 'alpha'); + $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); $remise_percent = ((GETPOST('remise_percent'.$predef) != '') ? GETPOST('remise_percent'.$predef) : 0); if ($qty == '') @@ -499,6 +499,12 @@ if (empty($reshook)) } $desc = $prod->description; + + //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time + if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { + $product_desc=''; + } + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 9a2ccd33cf7..ea83e022079 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -91,7 +91,7 @@ class box_birthdays extends ModeleBoxes $sql .= " WHERE u.entity IN (".getEntity('user').")"; $sql .= " AND u.statut = 1"; $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); - $sql .= " ORDER BY u.birth ASC"; + $sql .= " ORDER BY DAY(u.birth) ASC"; $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index 02a315ea836..56619fac581 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -91,7 +91,7 @@ class box_birthdays_members extends ModeleBoxes $sql .= " WHERE u.entity IN (".getEntity('adherent').")"; $sql .= " AND u.statut = 1"; $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); - $sql .= " ORDER BY u.birth ASC"; + $sql .= " ORDER BY DAY(u.birth) ASC"; $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 4ef11019cd3..97ebbee1d85 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -120,7 +120,8 @@ class box_graph_invoices_permonth extends ModeleBoxes if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) $endyear = $nowarray['year']; - $startyear = $endyear - 1; + $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); + $mode = 'customer'; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; $HEIGHT = '192'; diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index d346bae36d9..d044c65b9f0 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -118,7 +118,8 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $nowarray = dol_getdate(dol_now(), true); if (empty($year)) $year = $nowarray['year']; if (empty($endyear)) $endyear = $nowarray['year']; - $startyear = $endyear - 1; + $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); + $mode = 'supplier'; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; $HEIGHT = '192'; diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index b1059dc02ff..9f0f5ece978 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -120,7 +120,8 @@ class box_graph_orders_permonth extends ModeleBoxes if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) $endyear = $nowarray['year']; - $startyear = $endyear - 1; + $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); + $mode = 'customer'; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; $HEIGHT = '192'; diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 354aa071946..c16c0616fbc 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -119,7 +119,8 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) $endyear = $nowarray['year']; - $startyear = $endyear - 1; + $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); + $mode = 'supplier'; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; $HEIGHT = '192'; diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 5014c4b3817..29b7cab5a78 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -120,7 +120,8 @@ class box_graph_propales_permonth extends ModeleBoxes if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) $endyear = $nowarray['year']; - $startyear = $endyear - 1; + $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); + $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; $HEIGHT = '192'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1702019b092..c7634a6d638 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3257,14 +3257,18 @@ abstract class CommonObject * * @param string $origin Linked element type * @param int $origin_id Linked element id + * @param User $f_user User that create + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <=0 if KO, >0 if OK * @see fetchObjectLinked(), updateObjectLinked(), deleteObjectLinked() */ - public function add_object_linked($origin = null, $origin_id = null) + public function add_object_linked($origin = null, $origin_id = null, $f_user = null, $notrigger = 0) { // phpcs:enable + global $user; $origin = (!empty($origin) ? $origin : $this->origin); $origin_id = (!empty($origin_id) ? $origin_id : $this->origin_id); + $f_user = isset($f_user) ? $f_user : $user; // Special case if ($origin == 'order') $origin = 'commande'; @@ -3272,26 +3276,41 @@ abstract class CommonObject if ($origin == 'invoice_template') $origin = 'facturerec'; if ($origin == 'supplierorder') $origin = 'order_supplier'; $this->db->begin(); + $error = 0; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "element_element ("; $sql .= "fk_source"; $sql .= ", sourcetype"; $sql .= ", fk_target"; $sql .= ", targettype"; $sql .= ") VALUES ("; $sql .= $origin_id; - $sql .= ", '".$this->db->escape($origin)."'"; - $sql .= ", ".$this->id; - $sql .= ", '".$this->db->escape($this->element)."'"; + $sql .= ", '" . $this->db->escape($origin) . "'"; + $sql .= ", " . $this->id; + $sql .= ", '" . $this->db->escape($this->element) . "'"; $sql .= ")"; - dol_syslog(get_class($this)."::add_object_linked", LOG_DEBUG); - if ($this->db->query($sql)) - { + dol_syslog(get_class($this) . "::add_object_linked", LOG_DEBUG); + if ($this->db->query($sql)) { + if (!$notrigger) { + // Call trigger + $this->context['link_origin'] = $origin; + $this->context['link_origin_id'] = $origin_id; + $result = $this->call_trigger('OBJECT_LINK_INSERT', $f_user); + if ($result < 0) { + $error++; + } + // End call triggers + } + } else { + $this->error = $this->db->lasterror(); + $error++; + } + + if (!$error) { $this->db->commit(); return 1; } else { - $this->error = $this->db->lasterror(); $this->db->rollback(); return 0; } @@ -3502,38 +3521,61 @@ abstract class CommonObject * @param string $sourcetype Object source type * @param int $targetid Object target id * @param string $targettype Object target type + * @param User $f_user User that create + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int >0 if OK, <0 if KO * @see add_object_linked(), fetObjectLinked(), deleteObjectLinked() */ - public function updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '') + public function updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $f_user = null, $notrigger = 0) { + global $user; $updatesource = false; $updatetarget = false; + $f_user = isset($f_user) ? $f_user : $user; if (!empty($sourceid) && !empty($sourcetype) && empty($targetid) && empty($targettype)) $updatesource = true; elseif (empty($sourceid) && empty($sourcetype) && !empty($targetid) && !empty($targettype)) $updatetarget = true; - $sql = "UPDATE ".MAIN_DB_PREFIX."element_element SET "; - if ($updatesource) - { - $sql .= "fk_source = ".$sourceid; - $sql .= ", sourcetype = '".$this->db->escape($sourcetype)."'"; - $sql .= " WHERE fk_target = ".$this->id; - $sql .= " AND targettype = '".$this->db->escape($this->element)."'"; - } elseif ($updatetarget) - { - $sql .= "fk_target = ".$targetid; - $sql .= ", targettype = '".$this->db->escape($targettype)."'"; - $sql .= " WHERE fk_source = ".$this->id; - $sql .= " AND sourcetype = '".$this->db->escape($this->element)."'"; + $this->db->begin(); + $error = 0; + + $sql = "UPDATE " . MAIN_DB_PREFIX . "element_element SET "; + if ($updatesource) { + $sql .= "fk_source = " . $sourceid; + $sql .= ", sourcetype = '" . $this->db->escape($sourcetype) . "'"; + $sql .= " WHERE fk_target = " . $this->id; + $sql .= " AND targettype = '" . $this->db->escape($this->element) . "'"; + } elseif ($updatetarget) { + $sql .= "fk_target = " . $targetid; + $sql .= ", targettype = '" . $this->db->escape($targettype) . "'"; + $sql .= " WHERE fk_source = " . $this->id; + $sql .= " AND sourcetype = '" . $this->db->escape($this->element) . "'"; } - dol_syslog(get_class($this)."::updateObjectLinked", LOG_DEBUG); - if ($this->db->query($sql)) - { - return 1; + dol_syslog(get_class($this) . "::updateObjectLinked", LOG_DEBUG); + if ($this->db->query($sql)) { + if (!$notrigger) { + // Call trigger + $this->context['link_source_id'] = $sourceid; + $this->context['link_source_type'] = $sourcetype; + $this->context['link_target_id'] = $targetid; + $this->context['link_target_type'] = $targettype; + $result = $this->call_trigger('OBJECT_LINK_UPDATE', $f_user); + if ($result < 0) { + $error++; + } + // End call triggers + } } else { $this->error = $this->db->lasterror(); + $error++; + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); return -1; } } @@ -3546,13 +3588,17 @@ abstract class CommonObject * @param int $targetid Object target id * @param string $targettype Object target type * @param int $rowid Row id of line to delete. If defined, other parameters are not used. + * @param User $f_user User that create + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int >0 if OK, <0 if KO * @see add_object_linked(), updateObjectLinked(), fetchObjectLinked() */ - public function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '') + public function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '', $f_user = null, $notrigger = 0) { + global $user; $deletesource = false; $deletetarget = false; + $f_user = isset($f_user) ? $f_user : $user; if (!empty($sourceid) && !empty($sourcetype) && empty($targetid) && empty($targettype)) $deletesource = true; elseif (empty($sourceid) && empty($sourcetype) && !empty($targetid) && !empty($targettype)) $deletetarget = true; @@ -3561,36 +3607,56 @@ abstract class CommonObject $sourcetype = (!empty($sourcetype) ? $sourcetype : $this->element); $targetid = (!empty($targetid) ? $targetid : $this->id); $targettype = (!empty($targettype) ? $targettype : $this->element); + $this->db->begin(); + $error = 0; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element"; - $sql .= " WHERE"; - if ($rowid > 0) - { - $sql .= " rowid = ".$rowid; - } else { - if ($deletesource) - { - $sql .= " fk_source = ".$sourceid." AND sourcetype = '".$this->db->escape($sourcetype)."'"; - $sql .= " AND fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."'"; - } elseif ($deletetarget) - { - $sql .= " fk_target = ".$targetid." AND targettype = '".$this->db->escape($targettype)."'"; - $sql .= " AND fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."'"; + if (!$notrigger) { + // Call trigger + $this->context['link_id'] = $rowid; + $this->context['link_source_id'] = $sourceid; + $this->context['link_source_type'] = $sourcetype; + $this->context['link_target_id'] = $targetid; + $this->context['link_target_type'] = $targettype; + $result = $this->call_trigger('OBJECT_LINK_DELETE', $f_user); + if ($result < 0) { + $error++; + } + // End call triggers + } + + if (!$error) { + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "element_element"; + $sql .= " WHERE"; + if ($rowid > 0) { + $sql .= " rowid = " . $rowid; } else { - $sql .= " (fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."')"; - $sql .= " OR"; - $sql .= " (fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."')"; + if ($deletesource) { + $sql .= " fk_source = " . $sourceid . " AND sourcetype = '" . $this->db->escape($sourcetype) . "'"; + $sql .= " AND fk_target = " . $this->id . " AND targettype = '" . $this->db->escape($this->element) . "'"; + } elseif ($deletetarget) { + $sql .= " fk_target = " . $targetid . " AND targettype = '" . $this->db->escape($targettype) . "'"; + $sql .= " AND fk_source = " . $this->id . " AND sourcetype = '" . $this->db->escape($this->element) . "'"; + } else { + $sql .= " (fk_source = " . $this->id . " AND sourcetype = '" . $this->db->escape($this->element) . "')"; + $sql .= " OR"; + $sql .= " (fk_target = " . $this->id . " AND targettype = '" . $this->db->escape($this->element) . "')"; + } + } + + dol_syslog(get_class($this) . "::deleteObjectLinked", LOG_DEBUG); + if (!$this->db->query($sql)) { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + $error++; } } - dol_syslog(get_class($this)."::deleteObjectLinked", LOG_DEBUG); - if ($this->db->query($sql)) - { + if (!$error) { + $this->db->commit(); return 1; } else { - $this->error = $this->db->lasterror(); - $this->errors[] = $this->error; - return -1; + $this->db->rollback(); + return 0; } } @@ -6753,9 +6819,10 @@ abstract class CommonObject * @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names) * @param string $onetrtd All fields in same tr td. Used by objectline_create.tpl.php for example. + * @param string $display_type "card" for form display, "line" for document line display (extrafields on propal line, order line, etc...) * @return string */ - public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0) + public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0, $display_type = 'card') { global $db, $conf, $langs, $action, $form, $hookmanager; @@ -6810,7 +6877,7 @@ abstract class CommonObject } $colspan = ''; - if (is_array($params) && count($params) > 0) { + if (is_array($params) && count($params) > 0 && $display_type=='card') { if (array_key_exists('cols', $params)) { $colspan = $params['cols']; } elseif (array_key_exists('colspan', $params)) { // For backward compatibility. Use cols instead now. @@ -6869,7 +6936,7 @@ abstract class CommonObject } } - $out .= $extrafields->showSeparator($key, $this, ($colspan + 1)); + $out .= $extrafields->showSeparator($key, $this, ($colspan + 1), $display_type); } else { $class = (!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : ''); $csstyle = ''; @@ -6888,10 +6955,11 @@ abstract class CommonObject $domData .= ' data-targetid="'.$this->id.'"'; $html_id = (empty($this->id) ? '' : 'extrarow-'.$this->element.'_'.$key.'_'.$this->id); + if ($display_type=='card') { + if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan = '0'; } - if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan = '0'; } - - if ($action == 'selectlines') { $colspan++; } + if ($action == 'selectlines') { $colspan++; } + } // Convert date into timestamp format (value in memory must be a timestamp) if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime'))) @@ -6918,11 +6986,13 @@ abstract class CommonObject $labeltoshow = $langs->trans($label); $helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]); - $out .= '
'; + $out .= '
attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $helptoshow); else $out .= $labeltoshow; } - $out .= '
'; + if ($display_type=='card') { + $out .= ''; + } elseif ($display_type=='line') { + $out .= '
'; + } switch ($mode) { case "view": @@ -6956,15 +7030,18 @@ abstract class CommonObject break; } - $out .= '
'; + if ($display_type=='card') { + $tagtype='tr'; + $tagtype_dyn='td'; + }elseif ($display_type=='line') { + $tagtype='div'; + $tagtype_dyn='span'; + $colspan=0; + } + + $out = '<'.$tagtype.' id="trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'" class="trextrafieldseparator trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'">'; + $out .= '<'.$tagtype_dyn.' '.(!empty($colspan)?'colspan="' . $colspan . '"':'').'>'; + $out .=''; $out .= $langs->trans($this->attributes[$object->table_element]['label'][$key]); - $out .= '
'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', empty($conf->global->SOCIETE_EMAIL_MANDATORY) ? '' : $conf->global->SOCIETE_EMAIL_MANDATORY).''.img_picto('', 'object_email').'
'.$form->editfieldkey($langs->trans('No_Email') .' ('.$langs->trans('Contact').')', 'contact_no_email', '', $object, 0).'browser->layout == 'phone') || empty($conf->mailing->enabled) ? ' colspan="3"' : '').'>'.$form->selectyesno('contact_no_email', (GETPOSTISSET("contact_no_email") ?GETPOST("contact_no_email", 'alpha') : $object->no_email), 1, false, 1).'
'.$form->editfieldkey('Web', 'url', '', $object, 0).''.img_picto('', 'globe').'
'.$form->editfieldkey('ContactCategoriesShort', 'contcats', '', $object, 0).''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, 'parent', null, null, 1); + print img_picto('', 'category').$form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print "
'.$form->editfieldkey('ContactCategoriesShort', 'contcats', '', $object, 0).''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, 'parent', null, null, 1); + print img_picto('', 'category').$form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print "
'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1); - print img_picto('', 'category').$form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); - print "
'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1); + print img_picto('', 'category').$form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print "
'."\n"; + // Accountancy codes + print ''; + + if (! empty($conf->accounting->enabled)) + { + // Accountancy_code_sell + print ''; + print ''; + + // Accountancy_code_buy + print ''; + print ''; + } + else // For external software + { + // Accountancy_code_sell + print ''; + print ''; + + // Accountancy_code_buy + print ''; + print ''; + } + print '
'.$langs->trans("ProductAccountancySellCode").''; + $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, null, 1, 1, ''); + print '
'.$langs->trans("ProductAccountancyBuyCode").''; + $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, ''); + print '
'.$langs->trans("ProductAccountancySellCode").''; + print '
'.$langs->trans("ProductAccountancyBuyCode").''; + print '
'; + print dol_get_fiche_end(); print '
'; @@ -1669,6 +1760,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL); $object->webservices_key = GETPOST('webservices_key', 'san_alpha'); + $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + //Incoterms if (!empty($conf->incoterm->enabled)) { @@ -2133,17 +2227,19 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ""; // Supplier - print ''.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; - print ''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1); - $c = new Categorie($db); - $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER); - $arrayselected = array(); - foreach ($cats as $cat) { - $arrayselected[] = $cat->id; + if (!empty($conf->fournisseur->enabled)) { + print ''.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; + print ''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1); + $c = new Categorie($db); + $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER); + $arrayselected = array(); + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; + } + print img_picto('', 'category').$form->multiselectarray('suppcats', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print ""; } - print img_picto('', 'category').$form->multiselectarray('suppcats', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); - print ""; } // Multicurrency @@ -2196,10 +2292,42 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print img_picto('', 'user').$form->multiselectarray('commercial', $userlist, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0, '', '', '', 1); print ''; + print ''; + + print '
'; + + print ''; + + if (! empty($conf->accounting->enabled)) + { + // Accountancy_code_sell + print ''; + print ''; + + // Accountancy_code_buy + print ''; + print ''; + } + else // For external software + { + // Accountancy_code_sell + print ''; + print ''; + + // Accountancy_code_buy + print ''; + print ''; + } print '
'.$langs->trans("ProductAccountancySellCode").''; + print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1); + print '
'.$langs->trans("ProductAccountancyBuyCode").''; + print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1); + print '
'.$langs->trans("ProductAccountancySellCode").''; + print '
'.$langs->trans("ProductAccountancyBuyCode").''; + print '
'; print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -2520,7 +2648,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Supplier - if ($object->fournisseur) { + if (!empty($conf->fournisseur->enabled) && $object->fournisseur) { print ''.$langs->trans("SuppliersCategoriesShort").''; print ''; print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1); @@ -2577,6 +2705,42 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; } + // Accountancy sell code + print ''; + print $langs->trans("ProductAccountancySellCode"); + print ''; + if (! empty($conf->accounting->enabled)) + { + if (! empty($object->accountancy_code_sell)) + { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('', $object->accountancy_code_sell, 1); + + print $accountingaccount->getNomUrl(0, 1, 1, '', 1); + } + } else { + print $object->accountancy_code_sell; + } + print ''; + + // Accountancy buy code + print ''; + print $langs->trans("ProductAccountancyBuyCode"); + print ''; + if (! empty($conf->accounting->enabled)) + { + if (! empty($object->accountancy_code_buy)) + { + $accountingaccount2 = new AccountingAccount($db); + $accountingaccount2->fetch('', $object->accountancy_code_buy, 1); + + print $accountingaccount2->getNomUrl(0, 1, 1, '', 1); + } + } else { + print $object->accountancy_code_buy; + } + print ''; + // Other attributes $parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index d1513af17de..14e2cbe3277 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -693,6 +693,15 @@ class Societe extends CommonObject */ public $logo_squarred_mini; + /** + * @var string Accountancy account for sales + */ + public $accountancy_code_sell; + + /** + * @var string Accountancy account for bought + */ + public $accountancy_code_buy; // Multicurrency /** @@ -798,6 +807,9 @@ class Societe extends CommonObject } $this->import_key = trim($this->import_key); + $this->accountancy_code_buy = trim($this->accountancy_code_buy); + $this->accountancy_code_sell= trim($this->accountancy_code_sell); + if (!empty($this->multicurrency_code)) { $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); } @@ -827,8 +839,24 @@ class Societe extends CommonObject if ($result >= 0) { $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key, fk_multicurrency, multicurrency_code)"; - $sql .= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe ("; + $sql .= "nom"; + $sql .= ", name_alias"; + $sql .= ", entity"; + $sql .= ", datec"; + $sql .= ", fk_user_creat"; + $sql .= ", canvas"; + $sql .= ", status"; + $sql .= ", ref_ext"; + $sql .= ", fk_stcomm"; + $sql .= ", fk_incoterms"; + $sql .= ", location_incoterms"; + $sql .= ", import_key"; + $sql .= ", fk_multicurrency"; + $sql .= ", multicurrency_code"; + $sql .= ", accountancy_code_buy"; + $sql .= ", accountancy_code_sell"; + $sql .= ") VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'"; $sql .= ", ".(!empty($user->id) ? ((int) $user->id) : "null"); $sql .= ", ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null"); $sql .= ", ".$this->status; @@ -838,7 +866,10 @@ class Societe extends CommonObject $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= ", ".(int) $this->fk_multicurrency; - $sql .= ", '".$this->db->escape($this->multicurrency_code)."')"; + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'"; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); @@ -900,10 +931,18 @@ class Societe extends CommonObject * Create a contact/address from thirdparty * * @param User $user Object user + * @param int $no_email 1=Do not send mailing, 0=Ok to recieve mailling + * @param array $tags Array of tag to affect to contact * @return int <0 if KO, >0 if OK */ - public function create_individual(User $user) + public function create_individual(User $user, $no_email, $tags = array()) { + global $conf; + + $error = 0; + + $this->db->begin(); + // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contact = new Contact($this->db); @@ -923,14 +962,43 @@ class Societe extends CommonObject $contact->town = $this->town; $contact->phone_pro = $this->phone; - $result = $contact->create($user); - if ($result < 0) { + $contactId = $contact->create($user); + if ($contactId < 0) { + $error++; $this->error = $contact->error; $this->errors = $contact->errors; dol_syslog(get_class($this)."::create_individual ERROR:".$this->error, LOG_ERR); } - return $result; + if (empty($error) && is_array($tags) && !empty($tags)) { + $result = $contact->setCategories($tags); + if ($result < 0) { + $error++; + $this->error = $contact->error; + $this->errors = array_merge($this->errors, $contact->errors); + dol_syslog(get_class($this) . "::create_individual Affect Tag ERROR:" . $this->error, LOG_ERR); + $contactId = $result; + } + } + + if (empty($error) && !empty($conf->mailing->enabled) && !empty($contact->email) && isset($no_email)) { + $result = $contact->setNoEmail($no_email); + if ($result < 0) { + $this->error = $contact->error; + $this->errors = array_merge($this->errors, $contact->errors); + dol_syslog(get_class($this) . "::create_individual set mailing status ERROR:" . $this->error, LOG_ERR); + $contactId = $result; + } + } + + if (!empty($error)) { + dol_syslog(get_class($this)."::create_individual success"); + $this->db->commit(); + } else { + $this->db->rollback(); + } + + return $contactId; } /** @@ -1193,6 +1261,9 @@ class Societe extends CommonObject $this->webservices_url = $this->webservices_url ?clean_url($this->webservices_url, 0) : ''; $this->webservices_key = trim($this->webservices_key); + $this->accountancy_code_buy = trim($this->accountancy_code_buy); + $this->accountancy_code_sell= trim($this->accountancy_code_sell); + //Incoterms $this->fk_incoterms = (int) $this->fk_incoterms; $this->location_incoterms = trim($this->location_incoterms); @@ -1318,6 +1389,9 @@ class Societe extends CommonObject $sql .= ",supplier_order_min_amount= ".($this->supplier_order_min_amount != '' ? $this->supplier_order_min_amount : 'null'); $sql .= ",fk_prospectlevel='".$this->db->escape($this->fk_prospectlevel)."'"; + $sql.= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy)."'"; + $sql.= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell)."'"; + $sql .= ",webservices_url = ".(!empty($this->webservices_url) ? "'".$this->db->escape($this->webservices_url)."'" : "null"); $sql .= ",webservices_key = ".(!empty($this->webservices_key) ? "'".$this->db->escape($this->webservices_key)."'" : "null"); @@ -1489,6 +1563,7 @@ class Societe extends CommonObject $sql .= ', s.fk_effectif as effectif_id'; $sql .= ', s.fk_forme_juridique as forme_juridique_code'; $sql .= ', s.webservices_url, s.webservices_key'; + $sql .= ', s.accountancy_code_buy, s.accountancy_code_sell'; $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; $sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.remise_supplier, s.mode_reglement, s.cond_reglement, s.transport_mode'; $sql .= ', s.fk_account, s.tva_assuj'; @@ -1673,6 +1748,9 @@ class Societe extends CommonObject $this->webservices_url = $obj->webservices_url; $this->webservices_key = $obj->webservices_key; + $this->accountancy_code_buy = $obj->accountancy_code_buy; + $this->accountancy_code_sell = $obj->accountancy_code_sell; + $this->outstanding_limit = $obj->outstanding_limit; $this->order_min_amount = $obj->order_min_amount; $this->supplier_order_min_amount = $obj->supplier_order_min_amount; @@ -4490,4 +4568,57 @@ class Societe extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + + /** + * Sets an accountancy code for a thirdparty. + * Also calls COMPANY_MODIFY trigger when modified + * + * @param string $type It can be only 'buy' or 'sell' + * @param string $value Accountancy code + * @return int <0 KO >0 OK + */ + public function setAccountancyCode($type, $value) + { + global $user, $langs, $conf; + + $this->db->begin(); + + if ($type == 'buy') { + $field = 'accountancy_code_buy'; + } elseif ($type == 'sell') { + $field = 'accountancy_code_sell'; + } else { + return -1; + } + + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET "; + $sql.= "$field = '".$this->db->escape($value)."'"; + $sql.= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::".__FUNCTION__." sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + + if ($resql) { + // Call triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('COMPANY_MODIFY', $this, $user, $langs, $conf); + if ($result < 0) { + $this->errors=$interface->errors; + $this->db->rollback(); + return -1; + } + // End call triggers + + $this->$field = $value; + + $this->db->commit(); + return 1; + } + else { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } } diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index a571a207bc5..a9411e6d283 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -555,9 +555,9 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = price2num(GETPOST('qty'.$predef), 'alpha'); + $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); $remise_percent = GETPOST('remise_percent'.$predef); - $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU'); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -869,7 +869,7 @@ if (empty($reshook)) } $price_base_type = 'HT'; - $pu_ht_devise = GETPOST('multicurrency_subprice'); + $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), 'CU'); // Add buying price $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); diff --git a/htdocs/takepos/freezone.php b/htdocs/takepos/freezone.php index 4cca5816fab..a010ba184eb 100644 --- a/htdocs/takepos/freezone.php +++ b/htdocs/takepos/freezone.php @@ -95,7 +95,7 @@ top_htmlhead($head, '', 0, 0, $arrayofjs, $arrayofcss); */ function Save() { console.log("We click so we call page invoice.php with place= tva_tx="+vatRate); - $.get( "invoice.php", { action: "", place: "", desc:$('#desc').val(), number:$('#number').val(), tva_tx: vatRate} ); + parent.$("#poslines").load("invoice.php?action=freezone&place=&desc="+$('#desc').val()+"&number="+$('#number').val()+"&tva_tx="+vatRate); parent.$.colorbox.close(); } diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index ec012a8ddcd..6fedcd0292a 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -475,7 +475,7 @@ function Floors() { function FreeZone() { console.log("Open box to enter a free product"); - $.colorbox({href:"freezone.php?action=freezone&place="+place, onClosed: function () { Refresh(); },width:"80%", height:"200px", transition:"none", iframe:"true", title:"trans("FreeZone"); ?>"}); + $.colorbox({href:"freezone.php?action=freezone&place="+place, width:"80%", height:"200px", transition:"none", iframe:"true", title:"trans("FreeZone"); ?>"}); } function TakeposOrderNotes() { diff --git a/htdocs/user/list.php b/htdocs/user/list.php index d3012f855f2..3b21e19f349 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -36,7 +36,7 @@ if (!$user->rights->user->user->lire && !$user->admin) { } // Load translation files required by page -$langs->loadLangs(array('users', 'companies', 'hrm')); +$langs->loadLangs(array('users', 'companies', 'hrm', 'salaries')); $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)