Merge branch 'develop' into develop_new_workstation

This commit is contained in:
Laurent Destailleur 2021-01-11 17:59:13 +01:00 committed by GitHub
commit c2187b2ff1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
63 changed files with 1122 additions and 350 deletions

View File

@ -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

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
*
@ -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";

View File

@ -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 '<tr class="oddeven">';
@ -596,7 +606,7 @@ if ($result) {
// Found accounts
print '<td>';
$s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>';
$s = '<span class="small">1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>';
$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 '<br>';
$s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>';
$s = '<span class="small">2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>';
$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) ? '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>' : length_accountg($objp->code_sell_p));
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
} else {
print '<br>';
$s = '<span class="small">2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>';
$shelp = '';
$s .= $langs->trans("NotDefined");
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
}
print '<br>';
$s = '<span class="small">3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': </span>';
$shelp = '';
$s .= ($objp->code_sell_t > 0 ? length_accountg($objp->code_sell_t) : '<span style="'.$code_sell_t_notset.'">'.$langs->trans("NotDefined").'</span>');
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
print '</td>';
// 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 '<td>';
$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 '<td class="center">';
//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 '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="'.$objp->rowid."_".$i.'"'.($ischecked ? "checked" : "").'/>';

View File

@ -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";

View File

@ -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 '<tr class="oddeven">';
@ -576,7 +587,7 @@ if ($result) {
// Found accounts
print '<td>';
$s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>';
$s = '<span class="small">1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>';
$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 '<br>';
$s = '<span class="small">'.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>';
$s = '<span class="small">2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>';
$shelp = '';
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
$s .= (empty($objp->code_buy_p) ? '<span style="'.$code_buy_p_notset.'">'.$langs->trans("NotDefined").'</span>' : length_accountg($objp->code_buy_p));
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
} else {
print '<br>';
$s = '<span class="small">2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>';
$shelp = '';
$s .= $langs->trans("NotDefined");
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
}
print '<br>';
$s = '<span class="small">3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': </span>';
$shelp = '';
$s .= ($objp->code_buy_t > 0 ? length_accountg($objp->code_buy_t) : '<span style="'.$code_buy_t_notset.'">'.$langs->trans("NotDefined").'</span>');
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
print '</td>';
// Suggested accounting account

View File

@ -393,7 +393,7 @@ print '<tr class="liste_titre"><th class="titlefield wordbreak">'.$langs->trans(
// Name
print '<tr class="oddeven"><td class="fieldrequired wordbreak"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
print '<input name="nom" id="name" class="minwidth200" value="'.dol_escape_htmltag((GETPOSTISSET('nom') ? GETPOST('nom', 'nohtml') : (!empty($conf->global->MAIN_INFO_SOCIETE_NOM) ? $conf->global->MAIN_INFO_SOCIETE_NOM : '')).'"'.(empty($conf->global->MAIN_INFO_SOCIETE_NOM) ? ' autofocus="autofocus"' : '')).'></td></tr>'."\n";
print '<input name="nom" id="name" class="minwidth200" value="'.dol_escape_htmltag((GETPOSTISSET('nom') ? GETPOST('nom', 'nohtml') : (!empty($conf->global->MAIN_INFO_SOCIETE_NOM) ? $conf->global->MAIN_INFO_SOCIETE_NOM : ''))).'"'.(empty($conf->global->MAIN_INFO_SOCIETE_NOM) ? ' autofocus="autofocus"' : '').'></td></tr>'."\n";
// Address
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->trans("CompanyAddress").'</label></td><td>';

View File

@ -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 '<input size="32" type="text" name="MAILING_EMAIL_UNSUBSCRIBE_KEY" id="MAI
if (!empty($conf->use_javascript_ajax)) print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
print '</td></tr>';
// default blacklist from mailing
print '<tr class="oddeven">';
print '<td>' . $langs->trans("DefaultBlacklistMailingStatus") . '</td>';
print '<td>';
$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 '</td>';
print '</tr>';
if (!empty($conf->use_javascript_ajax) && $conf->global->MAIN_FEATURES_LEVEL >= 1) {
print '<tr class="oddeven"><td>';
print $langs->trans("MailAdvTargetRecipients").'</td><td>';

View File

@ -707,7 +707,15 @@ if (!empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
print "</td>\n";
print "</tr>\n";
}
print '<tr class="oddeven">';
print '<td>'.$langs->trans("WarehouseAskWarehouseDuringPropal").'</td>';
print '<td class="right">';
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 '<tr class="oddeven">';
print '<td>'.$langs->trans("WarehouseAskWarehouseDuringOrder").'</td>';
print '<td class="right">';

View File

@ -264,7 +264,7 @@ if (!$error && $xml)
$out .= "</tr>\n";
}
} else {
$out .= '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
$out .= '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
$out .= '</table>';
$out .= '</div>';
@ -317,7 +317,7 @@ if (!$error && $xml)
$out .= '<td class="right"></td>'."\n";
$out .= "</tr>\n";
} else {
$out .= '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
$out .= '<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
$out .= '</table>';
$out .= '</div>';
@ -370,12 +370,11 @@ if (!$error && $xml)
$out .= '<td class="right"></td>'."\n";
$out .= "</tr>\n";
} else {
$out .= '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
$out .= '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
$out .= '</table>';
$out .= '</div>';
// Show warning
if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3))
{

View File

@ -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");
}

View File

@ -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;
@ -195,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');

View File

@ -141,7 +141,7 @@ print '</td>';
print '</tr>';
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');
}
?>

View File

@ -141,7 +141,7 @@ print '</td>';
print '</tr>';
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 "<!-- END PHP TEMPLATE objectline_edit.tpl.php -->\n";

View File

@ -161,7 +161,7 @@ print '</tr>';
//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 "<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n";

View File

@ -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 '</div></div></div>';
print '<div style="clear:both"></div>';

View File

@ -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');
@ -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;
@ -1239,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);
@ -1325,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);
@ -1469,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
@ -1485,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 '<form name="addprop" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
@ -1517,9 +1533,13 @@ if ($action == 'create')
print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
print '</td>';
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 '<td>';
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))
{
@ -1543,6 +1563,7 @@ if ($action == 'create')
{
// Contacts (ask contact only if thirdparty already defined).
print "<tr><td>".$langs->trans("DefaultContact").'</td><td>';
print img_picto('', 'contact');
$form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist);
print '</td></tr>';
@ -1560,25 +1581,28 @@ if ($action == 'create')
// Date
print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td>';
print $form->selectDate('', '', '', '', '', "addprop", 1, 1);
print img_picto('', 'object_calendarday').'&ensp;'.$form->selectDate('', '', '', '', '', "addprop", 1, 1);
print '</td></tr>';
// Validaty duration
print '<tr><td class="fieldrequired">'.$langs->trans("ValidityDuration").'</td><td><input name="duree_validite" class="width50" value="'.(GETPOSTISSET('duree_validite') ? GETPOST('duree_validite', 'alphanohtml') : $conf->global->PROPALE_VALIDITY_DURATION).'"> '.$langs->trans("days").'</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("ValidityDuration").'</td><td>'.img_picto('', 'clock').'&ensp;<input name="duree_validite" class="width50" value="'.(GETPOSTISSET('duree_validite') ? GETPOST('duree_validite', 'alphanohtml') : $conf->global->PROPALE_VALIDITY_DURATION).'"> '.$langs->trans("days").'</td></tr>';
// Terms of payment
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
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 '</td></tr>';
// Mode of payment
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
print img_picto('', 'bank').'&ensp;';
$form->select_types_paiements((GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $soc->mode_reglement_id), 'mode_reglement_id');
print '</td></tr>';
// Bank Account
if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) {
print '<tr><td>'.$langs->trans('BankAccount').'</td><td>';
print img_picto('', 'bank_account');
$form->select_comptes($soc->fk_account, 'fk_account', 0, '', 1);
print '</td></tr>';
}
@ -1593,6 +1617,7 @@ if ($action == 'create')
if (!empty($conf->commande->enabled))
print ' ('.$langs->trans('AfterOrder').')';
print '</td><td>';
print img_picto('', 'clock').'&ensp;';
$form->selectAvailabilityDelay('', 'availability_id', '', 1);
print '</td></tr>';
@ -1602,13 +1627,24 @@ if ($action == 'create')
$shipping_method_id = $soc->shipping_method_id;
}
print '<tr><td>'.$langs->trans('SendingMethod').'</td><td>';
print img_picto('', 'object_dollyrevert').'&ensp;';
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1);
print '</td></tr>';
}
// 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 '<tr><td>'.$langs->trans('Warehouse').'</td><td>';
print img_picto('', 'stock').$formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth175 maxwidth500 widthcentpercentminusxx');
print '</td></tr>';
}
// Delivery date (or manufacturing)
print '<tr><td>'.$langs->trans("DeliveryDate").'</td>';
print '<td>';
print img_picto('', 'object_calendarday').'&ensp;';
if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") {
$tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60);
$syear = date("Y", $tmpdte);
@ -1626,6 +1662,7 @@ if ($action == 'create')
$langs->load("projects");
print '<tr>';
print '<td>'.$langs->trans("Project").'</td><td>';
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 ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddProject").'"></span></a>';
print '</td>';
@ -1646,6 +1683,7 @@ if ($action == 'create')
print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<td>';
print img_picto('', 'pdf').'&ensp;';
$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 "</td></tr>";
@ -2102,6 +2140,24 @@ if ($action == 'create')
print '</tr>';
}
// 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 '<tr><td>';
$editenable = $usercancreate;
print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable);
print '</td><td>';
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 '</td>';
print '</tr>';
}
// Origin of demand
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';

View File

@ -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;

View File

@ -67,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');
@ -161,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),
@ -223,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 = '';
@ -289,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,";
@ -349,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);
@ -459,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);
@ -621,6 +626,12 @@ if ($resql)
print '<input class="flat maxwidth100" type="text" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
print '</td>';
}
if (!empty($arrayfields['s.name_alias']['checked']))
{
print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth100" type="text" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).'">';
print '</td>';
}
if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>';
if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>';
// State
@ -861,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);
@ -1024,6 +1036,15 @@ if ($resql)
if (!$i) $totalarray['nbfield']++;
}
// Alias
if (!empty($arrayfields['s.name_alias']['checked']))
{
print '<td class="tdoverflowmax200">';
print $obj->alias;
print '</td>';
if (!$i) $totalarray['nbfield']++;
}
// Town
if (!empty($arrayfields['s.town']['checked']))
{

View File

@ -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
@ -1538,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 '<form name="crea_commande" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
@ -1595,6 +1597,7 @@ if ($action == 'create' && $usercancreate)
if ($socid > 0) {
// Contacts (ask contact only if thirdparty already defined).
print "<tr><td>".$langs->trans("DefaultContact").'</td><td>';
print img_picto('', 'contact');
$form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist, '', 1);
print '</td></tr>';
@ -1613,14 +1616,14 @@ if ($action == 'create' && $usercancreate)
// Date
print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td>';
print $form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date
print img_picto('', 'object_calendarday').'&ensp;'.$form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date
print '</td></tr>';
// Date delivery planned
print '<tr><td>'.$langs->trans("DateDeliveryPlanned").'</td>';
print '<td colspan="3">';
$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').'&ensp;'.$form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1);
print "</td>\n";
print '</tr>';
@ -1631,6 +1634,7 @@ if ($action == 'create' && $usercancreate)
// Mode de reglement
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
print img_picto('', 'bank').'&ensp;';
$form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
print '</td></tr>';
@ -1638,24 +1642,27 @@ if ($action == 'create' && $usercancreate)
if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && !empty($conf->banque->enabled))
{
print '<tr><td>'.$langs->trans('BankAccount').'</td><td>';
print img_picto('', 'bank_account');
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print '</td></tr>';
}
// Delivery delay
print '<tr class="fielddeliverydelay"><td>'.$langs->trans('AvailabilityPeriod').'</td><td>';
print img_picto('', 'clock').'&ensp;';
$form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1);
print '</td></tr>';
// Shipping Method
if (!empty($conf->expedition->enabled)) {
print '<tr><td>'.$langs->trans('SendingMethod').'</td><td>';
print img_picto('', 'object_dollyrevert').'&ensp;';
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1);
print '</td></tr>';
}
// 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 '<tr><td>'.$langs->trans('Warehouse').'</td><td>';
@ -1721,6 +1728,7 @@ if ($action == 'create' && $usercancreate)
// Template to use by default
print '<tr><td>'.$langs->trans('DefaultModel').'</td>';
print '<td>';
print img_picto('', 'pdf').'&ensp;';
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);
@ -2165,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);

View File

@ -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');
@ -149,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),
@ -211,6 +213,7 @@ if (empty($reshook))
$search_ref = '';
$search_ref_customer = '';
$search_company = '';
$search_company_alias = '';
$search_town = '';
$search_zip = "";
$search_state = "";
@ -280,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,';
@ -362,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);
@ -466,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);
@ -693,6 +698,13 @@ if ($resql)
print '<input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
print '</td>';
}
// Alias
if (!empty($arrayfields['s.name_alias']['checked']))
{
print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth100" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'">';
print '</td>';
}
// Town
if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
// Zip
@ -917,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);
@ -1077,6 +1090,14 @@ if ($resql)
if (!$i) $totalarray['nbfield']++;
}
// Town
if (!empty($arrayfields['s.name_alias']['checked']))
{
print '<td class="nocellnopadd">';
print $obj->alias;
print '</td>';
if (!$i) $totalarray['nbfield']++;
}
// Town
if (!empty($arrayfields['s.town']['checked']))
{
print '<td class="nocellnopadd">';

View File

@ -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

View File

@ -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'));
@ -3347,11 +3363,11 @@ if ($action == 'create')
print '</td></tr>';
}
$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 '<tr><td class="fieldrequired">'.$langs->trans('DateInvoice').'</td><td colspan="2">';
print $form->selectDate($datefacture ? $datefacture : $dateinvoice, '', '', '', '', "add", 1, 1);
print $form->selectDate($newdateinvoice ? $newdateinvoice : $dateinvoice, '', '', '', '', "add", 1, 1);
print '</td></tr>';
// Date point of tax
@ -3509,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).')',

View File

@ -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 '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_societe" value="'.$search_societe.'"></td>';
}
// Alias
if (!empty($arrayfields['s.name_alias']['checked']))
{
print '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_societe_alias" value="'.$search_societe_alias.'"></td>';
}
// Town
if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
// 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 '</td>';
if (!$i) $totalarray['nbfield']++;
}
// Alias
if (!empty($arrayfields['s.name_alias']['checked']))
{
print '<td>';
print $obj->name_alias;
print '</td>';
if (!$i) $totalarray['nbfield']++;
}
// Town
if (!empty($arrayfields['s.town']['checked']))
{

View File

@ -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 '<input type="text" name="email" id="email" value="'.(GETPOSTISSET('email') ? GETPOST('email', 'alpha') : $object->email).'"></td>';
print '</tr>';
//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".'<script type="text/javascript" language="javascript">'."\n";
print '$(document).ready(function () {
$("#email").keyup(function() {
if ($(this).val()!="") {
$(".noemail").addClass("fieldrequired");
} else {
$(".noemail").removeClass("fieldrequired");
}
});
})'."\n";
print '</script>'."\n";
}
if (!GETPOSTISSET("no_email") && !empty($object->email))
{
$result=$object->getNoEmail();
if ($result<0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
print '<tr>';
print '<td><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
print '<td>'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'alpha') : $noemail), 1).'</td>';
print '<td class="noemail"><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
print '<td>'.$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)).'</td>';
print '</tr>';
}
print '</tr>';
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 '<tr><td><label for="skype">'.$form->editfieldkey('Jabber', 'jabberid', '', $object, 0).'</label></td>';
// print '<td colspan="3"><input type="text" name="jabberid" id="jabberid" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("jabberid")?GETPOST("jabberid", 'alpha'):$object->jabberid).'"></td></tr>';
// }
// // Skype
// if (! empty($conf->global->SOCIALNETWORKS_SKYPE))
// {
// print '<tr><td><label for="skype">'.$form->editfieldkey('Skype', 'skype', '', $object, 0).'</label></td>';
// print '<td colspan="3"><input type="text" name="skype" id="skype" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("skype")?GETPOST("skype", 'alpha'):$object->skype).'"></td></tr>';
// }
// // Twitter
// if (! empty($conf->global->SOCIALNETWORKS_TWITTER))
// {
// print '<tr><td><label for="twitter">'.$form->editfieldkey('Twitter', 'twitter', '', $object, 0).'</label></td>';
// print '<td colspan="3"><input type="text" name="twitter" id="twitter" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("twitter")?GETPOST("twitter", 'alpha'):$object->twitter).'"></td></tr>';
// }
// // Facebook
// if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK))
// {
// print '<tr><td><label for="facebook">'.$form->editfieldkey('Facebook', 'facebook', '', $object, 0).'</label></td>';
// print '<td colspan="3"><input type="text" name="facebook" id="facebook" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("facebook")?GETPOST("facebook", 'alpha'):$object->facebook).'"></td></tr>';
// }
// // LinkedIn
// if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN))
// {
// print '<tr><td><label for="linkedin">'.$form->editfieldkey('LinkedIn', 'linkedin', '', $object, 0).'</label></td>';
// print '<td colspan="3"><input type="text" name="linkedin" id="linkedin" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("linkedin")?GETPOST("linkedin", 'alpha'):$object->linkedin).'"></td></tr>';
// }
// }
// Visibility
print '<tr><td><label for="priv">'.$langs->trans("ContactVisibility").'</label></td><td colspan="3">';
@ -1050,28 +1039,34 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '</tr>';
// Unsubscribe
print '<tr>';
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".'<script type="text/javascript" language="javascript">'."\n";
print 'jQuery(document).ready(function () {
jQuery("#email").keyup(function() {
if ($(this).val()!="") {
$(".noemail").addClass("fieldrequired");
} else {
$(".noemail").removeClass("fieldrequired");
}
})
})'."\n";
print '</script>'."\n";
}
if (!GETPOSTISSET("no_email") && !empty($object->email))
{
$result=$object->getNoEmail();
if ($result<0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
print '<td><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
print '<td>'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).'</td>';
} else {
print '<td colspan="2"></td>';
print '<tr>';
print '<td class="noemail"><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
print '<td>'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'int') : $object->no_email), 1, false, ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1)).'</td>';
print '</tr>';
}
print '</tr>';
if (!empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) {
@ -1300,20 +1295,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 '<tr><td>'.$langs->trans("No_Email").'</td><td>'.yn($noemail).'</td></tr>';
print '<tr><td>'.$langs->trans("No_Email").'</td><td>'.yn($object->no_email).'</td></tr>';
}
print '<tr><td>'.$langs->trans("ContactVisibility").'</td><td>';

View File

@ -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;
}
}

View File

@ -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 == '')

View File

@ -6870,9 +6870,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;
@ -6927,7 +6928,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.
@ -6986,7 +6987,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 = '';
@ -7005,10 +7006,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')))
@ -7035,11 +7037,13 @@ abstract class CommonObject
$labeltoshow = $langs->trans($label);
$helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]);
$out .= '<tr '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.'" '.$domData.' >';
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER) && $action == 'view') {
$out .= '<td></td>';
if ($display_type=='card') {
$out .= '<tr '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.'" '.$domData.' >';
$out .= '<td class="wordbreak';
} elseif ($display_type=='line') {
$out .= '<div '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.(!empty($this->id)?'_'.$this->id:'').'" '.$domData.' >';
$out .= '<div style="display: inline-block; padding-right:4px" class="wordbreak';
}
$out .= '<td class="wordbreak';
//$out .= "titlefield";
//if (GETPOST('action', 'restricthtml') == 'create') $out.='create';
// BUG #11554 : For public page, use red dot for required fields, instead of bold label
@ -7055,11 +7059,15 @@ abstract class CommonObject
if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $helptoshow);
else $out .= $labeltoshow;
}
$out .= '</td>';
$out .= ($display_type=='card' ? '</td>' : '</div>');
$html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : '';
$out .= '<td '.($html_id ? 'id="'.$html_id.'" ' : '').'class="'.$this->element.'_extras_'.$key.'" '.($colspan ? ' colspan="'.$colspan.'"' : '').'>';
if ($display_type=='card') {
$out .= '<td '.($html_id ? 'id="'.$html_id.'" ' : '').' class="'.$this->element.'_extras_'.$key.'" '.($colspan ? ' colspan="'.$colspan.'"' : '').'>';
} elseif ($display_type=='line') {
$out .= '<div '.($html_id ? 'id="'.$html_id.'" ' : '').' style="display: inline-block" class="'.$this->element.'_extras_'.$key.'">';
}
switch ($mode) {
case "view":
@ -7073,15 +7081,18 @@ abstract class CommonObject
break;
}
$out .= '</td>';
$out .= ($display_type=='card' ? '</td>' : '</div>');
/*for($ii = 0; $ii < ($colspan - 1); $ii++)
{
$out .='<td class="'.$this->element.'_extras_'.$key.'"></td>';
}*/
if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>';
else $out .= '</tr>';
if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) {
$out .= ($display_type=='card' ? '</tr>' : '</div>');
} else {
$out .= ($display_type=='card' ? '</tr>' : '</div>');
}
$e++;
}
}

View File

@ -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'=><timestamp>, 'end'=><timestamp>) 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 = '<div ' . ($moreparam ? $moreparam : '') . '><div class="nowrap">'
. $langs->trans('From') . ' '
. $form->selectDate($prefill['start'], $keyprefix . $key . $keysuffix . '_start', 0, 0, 1)
. '</div><div class="nowrap">'
. $langs->trans('to') . ' '
. $form->selectDate($prefill['end'], $keyprefix . $key . $keysuffix . '_end', 0, 0, 1)
. '</div></div>';
} 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 = '<tr id="trextrafieldseparator'.$key.'" class="trextrafieldseparator trextrafieldseparator'.$key.'"><td colspan="'.$colspan.'"><strong>';
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 .='<strong>';
$out .= $langs->trans($this->attributes[$object->table_element]['label'][$key]);
$out .= '</strong></td></tr>';
$out .= '</strong>';
$out .= '</'.$tagtype_dyn.'>';
$out .= '</'.$tagtype.'>';
$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 .= '<!-- Add js script to manage the collpase/uncollapse of extrafields separators '.$key.' -->';
$out .= '<script type="text/javascript">';
$out .= 'jQuery(document).ready(function(){';
if ($collapse_display === false) {
$out .= ' jQuery("#trextrafieldseparator'.$key.' td").prepend("<span class=\"cursorpointer far fa-plus-square\"></span>&nbsp;");'."\n";
$out .= ' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').' '.$tagtype_dyn.'").prepend("<span class=\"cursorpointer far fa-plus-square\"></span>&nbsp;");'."\n";
$out .= ' jQuery(".trextrafields_collapse'.$extrafields_collapse_num.'").hide();'."\n";
} else {
$out .= ' jQuery("#trextrafieldseparator'.$key.' td").prepend("<span class=\"cursorpointer far fa-minus-square\"></span>&nbsp;");'."\n";
$out .= ' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').' '.$tagtype_dyn.'").prepend("<span class=\"cursorpointer far fa-minus-square\"></span>&nbsp;");'."\n";
$out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.'=1; path='.$_SERVER["PHP_SELF"].'"'."\n";
}
$out .= ' jQuery("#trextrafieldseparator'.$key.'").click(function(){'."\n";
$out .= ' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'").click(function(){'."\n";
$out .= ' jQuery(".trextrafields_collapse'.$extrafields_collapse_num.'").toggle(300, function(){'."\n";
$out .= ' if (jQuery(".trextrafields_collapse'.$extrafields_collapse_num.'").is(":hidden")) {'."\n";
$out .= ' jQuery("#trextrafieldseparator'.$key.' td span").addClass("fa-plus-square").removeClass("fa-minus-square");'."\n";
$out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.'=0; path='.$_SERVER["PHP_SELF"].'"'."\n";
$out .= ' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').' '.$tagtype_dyn.' span").addClass("fa-plus-square").removeClass("fa-minus-square");'."\n";
$out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.(!empty($object->id)?'_'.$object->id:'').'=0; path='.$_SERVER["PHP_SELF"].'"'."\n";
$out .= ' } else {'."\n";
$out .= ' jQuery("#trextrafieldseparator'.$key.' td span").addClass("fa-minus-square").removeClass("fa-plus-square");'."\n";
$out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.'=1; path='.$_SERVER["PHP_SELF"].'"'."\n";
$out .= ' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').' '.$tagtype_dyn.' span").addClass("fa-minus-square").removeClass("fa-plus-square");'."\n";
$out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.(!empty($object->id)?'_'.$object->id:'').'=1; path='.$_SERVER["PHP_SELF"].'"'."\n";
$out .= ' }'."\n";
$out .= ' });';
$out .= ' });';
@ -2090,9 +2118,28 @@ class ExtraFields
if (in_array($key_type, array('date', 'datetime')))
{
if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) continue; // Value was not provided, we should not set it.
// Clean parameters
$value_key = dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int'));
$dateparamname_start = $keysuffix . 'options_' . $key . $keyprefix . '_start';
$dateparamname_end = $keysuffix . 'options_' . $key . $keyprefix . '_end';
if (GETPOSTISSET($dateparamname_start . 'year') && GETPOSTISSET($dateparamname_end . 'year')) {
// values provided as a date pair (start date + end date), each date being broken down as year, month, day, etc.
$value_key = array(
'start' => dol_mktime(
0, 0, 0,
GETPOST($dateparamname_start . 'month', 'int'),
GETPOST($dateparamname_start . 'day', 'int'),
GETPOST($dateparamname_start . 'year', 'int')),
'end' => dol_mktime(
23, 59, 59,
GETPOST($dateparamname_end . 'month', 'int'),
GETPOST($dateparamname_end . 'day', 'int'),
GETPOST($dateparamname_end . 'year', 'int'))
);
} elseif (GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) {
// Clean parameters
$value_key = dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int'));
} else {
continue; // Value was not provided, we should not set it.
}
} elseif (in_array($key_type, array('checkbox', 'chkbxlst')))
{
if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it.

View File

@ -4952,7 +4952,7 @@ class Form
print '<form method="POST" action="'.$page.'">';
print '<input type="hidden" name="action" value="setmulticurrencyrate">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="text" class="maxwidth100" name="'.$htmlname.'" value="'.(!empty($rate) ? price(price2num($rate, 'CR')) : 1).'" /> ';
print '<input type="text" class="maxwidth100" name="'.$htmlname.'" value="'.(!empty($rate) ? price(price2num($rate, 'CU')) : 1).'" /> ';
print '<select name="calculation_mode">';
print '<option value="1">'.$currency.' > '.$conf->currency.'</option>';
print '<option value="2">'.$conf->currency.' > '.$currency.'</option>';

View File

@ -1976,7 +1976,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
{
global $conf, $langs;
if ($tzoutput == 'auto') {
if ($tzoutput == 'auto' && property_exists($conf, 'tzuserinputkey')) {
$tzoutput = $conf->tzuserinputkey;
}
@ -4826,7 +4826,8 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
* 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT)
* 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT)
* 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK)
* 'CR'=Foreign currency accurancy
* 'CU'=Round to Max unit price of foreign currency accuracy
* 'CT'=Round to Max for totals with Tax of foreign currency accuracy
* Numeric = Nb of digits for rounding
* @param int $option Put 1 if you know that content is already universal format number (so no correction on decimal will be done)
* Put 2 if you know that number is a user input (so we know we don't have to fix decimal separator).
@ -4896,8 +4897,11 @@ function price2num($amount, $rounding = '', $option = 0)
elseif ($rounding == 'MS') {
$nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK;
}
elseif ($rounding == 'CR') {
$nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8);
elseif ($rounding == 'CU') {
$nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_UNIT, 8); // TODO Use param of currency
}
elseif ($rounding == 'CT') {
$nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8); // TODO Use param of currency
}
elseif (is_numeric($rounding)) $nbofdectoround = $rounding;
//print "RR".$amount.' - '.$nbofdectoround.'<br>';

View File

@ -74,6 +74,14 @@ class modMailing extends DolibarrModules
// Constants
$this->const = array();
$r = 0;
$this->const[$r][0] = "MAILING_CONTACT_DEFAULT_BULK_STATUS";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "0";
$this->const[$r][3] = 'Default black list mailing';
$this->const[$r][4] = 0;
$r++;
// Boxes
$this->boxes = array();

View File

@ -57,7 +57,10 @@ foreach ($object->fields as $key => $val)
if (in_array($val['type'], array('int', 'integer'))) $value = GETPOST($key, 'int');
elseif ($val['type'] == 'double') $value = price2num(GETPOST($key, 'alphanohtml'));
elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOST($key, 'restricthtml');
else $value = GETPOST($key, 'alpha');
elseif ($val['type'] == 'date') $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int'));
elseif ($val['type'] == 'datetime') $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int'));
elseif ($val['type'] == 'boolean') $value = (GETPOST($key) == 'on' ? 1 : 0);
else $value = GETPOST($key, 'alphanohtml');
if ($val['noteditable']) print $object->showOutputField($val, $key, $value, '', '', '', 0);
else print $object->showInputField($val, $key, $value, '', '', '', 0);
print '</td>';

View File

@ -35,8 +35,8 @@ if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_e
print '<input class="flat'.($searchclass ? ' '.$searchclass : '').'" size="4" type="text" name="'.$search_options_pattern.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options[$search_options_pattern.$tmpkey]).'">';
} elseif (in_array($typeofextrafield, array('datetime', 'timestamp')))
{
// TODO
// Use showInputField in a particular manner to have input with a comparison operator, not input for a specific value date-hour-minutes
$morecss = '';
echo $extrafields->showInputField($key, $search_array_options[$search_options_pattern.$tmpkey], '', '', $search_options_pattern, $morecss, 0, $extrafieldsobjectkey, 1);
} else {
// for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid')
$morecss = '';

View File

@ -16,6 +16,22 @@ if (!empty($search_array_options) && is_array($search_array_options)) // $extraf
{
$crit = $val;
$tmpkey = preg_replace('/'.$search_options_pattern.'/', '', $key);
if (is_array($val) && array_key_exists('start', $val) && array_key_exists('end', $val)) {
// date range from list filters is stored as array('start' => <timestamp>, 'end' => <timestamp>)
// start date
$param .= '&' . $search_options_pattern.$tmpkey.'_startyear=' . dol_print_date($val['start'], '%Y');
$param .= '&' . $search_options_pattern.$tmpkey.'_startmonth=' . dol_print_date($val['start'], '%m');
$param .= '&' . $search_options_pattern.$tmpkey.'_startday=' . dol_print_date($val['start'], '%d');
$param .= '&' . $search_options_pattern.$tmpkey.'_starthour=' . dol_print_date($val['start'], '%H');
$param .= '&' . $search_options_pattern.$tmpkey.'_startmin=' . dol_print_date($val['start'], '%M');
// end date
$param .= '&' . $search_options_pattern.$tmpkey.'_endyear=' . dol_print_date($val['end'], '%Y');
$param .= '&' . $search_options_pattern.$tmpkey.'_endmonth=' . dol_print_date($val['end'], '%m');
$param .= '&' . $search_options_pattern.$tmpkey.'_endday=' . dol_print_date($val['end'], '%d');
$param .= '&' . $search_options_pattern.$tmpkey.'_endhour=' . dol_print_date($val['end'], '%H');
$param .= '&' . $search_options_pattern.$tmpkey.'_endmin=' . dol_print_date($val['end'], '%M');
$val = '';
}
if ($val != '') $param .= '&'.$search_options_pattern.$tmpkey.'='.urlencode($val);
}
}

View File

@ -23,7 +23,15 @@ if (!empty($extrafieldsobjectkey) && !empty($search_array_options) && is_array($
if ($crit != '' && in_array($typ, array('date', 'datetime', 'timestamp')))
{
$sql .= " AND ".$extrafieldsobjectprefix.$tmpkey." = '".$db->idate($crit)."'";
if (is_numeric($crit)) {
$sql .= " AND ".$extrafieldsobjectprefix.$tmpkey." = '".$db->idate($crit)."'";
} elseif (is_array($crit)) {
$sql .= ' AND (' . $extrafieldsobjectprefix.$tmpkey
.' BETWEEN "'
. $db->idate($crit['start'])
. '" AND "'
. $db->idate($crit['end']) . '")';
}
} elseif (in_array($typ, array('boolean')))
{
if ($crit !== '-1' && $crit !== '') {

View File

@ -319,6 +319,11 @@ if ($nolinesbefore) {
echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1);
echo '</div>';
}
if (is_object($objectline)) {
print '<div style="padding-top: 10px" id="extrafield_lines_area_create" name="extrafield_lines_area_create">';
print $objectline->showOptionals($extrafields, 'edit', array(), '', '', 1, 'line');
print '</div>';
}
echo '</td>';
if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines
{
@ -412,10 +417,6 @@ if ($nolinesbefore) {
</tr>
<?php
if (is_object($objectline)) {
print $objectline->showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', 1);
}
if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required
{
print '<tr id="trlinefordates" class="oddeven">'."\n";

View File

@ -125,6 +125,14 @@ $coldisplay++;
print '<textarea id="product_desc" class="flat" name="product_desc" readonly style="width: 200px; height:80px;">'.$line->description.'</textarea>';
}
//Line extrafield
if (!empty($extrafields))
{
print '<div style="padding-top: 10px" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
print $line->showOptionals($extrafields, 'edit', array('class'=>'tredited'), '', '', 1, 'line');
print '</div>';
}
// Show autofill date for recuring invoices
if (!empty($conf->service->enabled) && $line->product_type == 1 && $line->element == 'facturedetrec')
{
@ -270,14 +278,6 @@ $coldisplay++;
</td>
</tr>
<?php
//Line extrafield
if (!empty($extrafields))
{
print $line->showOptionals($extrafields, 'edit', array('class'=>'tredited', 'colspan'=>$coldisplay), '', '', 1);
}
?>
<?php if (!empty($conf->service->enabled) && $line->product_type == 1 && $dateSelector) { ?>
<tr id="service_duration_area" class="treditedlinefordate">
<?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>

View File

@ -157,6 +157,13 @@ if (($line->info_bits & 2) == 2) {
{
print (!empty($line->description) && $line->description != $line->product_label) ? '<br>'.dol_htmlentitiesbr($line->description) : '';
}
//Line extrafield
if (!empty($extrafields))
{
print '<div style="padding-top: 10px" id="extrafield_lines_area_'.$line->id.'" name="extrafield_lines_area_'.$line->id.'">';
print $line->showOptionals($extrafields, 'view', array(), '', '', 1, 'line');
print '</div>';
}
}
if ($user->rights->fournisseur->lire && $line->fk_fournprice > 0)
@ -360,10 +367,4 @@ if ($action == 'selectlines') { ?>
print "</tr>\n";
//Line extrafield
if (!empty($extrafields))
{
print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"', 'colspan'=>$coldisplay), '', '', 1);
}
print "<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n";

View File

@ -158,6 +158,18 @@ class InterfaceWorkflowManager extends DolibarrTriggers
}
}
if (! empty($conf->expedition->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE)) {
/** @var Facture $object */
$object->fetchObjectLinked('', 'shipping', $object->id, $object->element);
if (! empty($object->linkedObjects)) {
/** @var Expedition $shipment */
$shipment = array_shift($object->linkedObjects['shipping']);
$ret = $shipment->setClosed();
}
}
return $ret;
}

View File

@ -371,9 +371,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);

View File

@ -655,19 +655,23 @@ if (empty($reshook))
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
$datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$datedue = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']);
// Replacement invoice
if ($_POST['type'] == FactureFournisseur::TYPE_REPLACEMENT)
{
if ($datefacture == '')
{
if (empty($dateinvoice)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors');
$action = 'create';
$_GET['socid'] = $_POST['socid'];
$error++;
} 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 (!(GETPOST('fac_replacement', 'int') > 0)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), null, 'errors');
@ -682,7 +686,7 @@ if (empty($reshook))
$object->ref_supplier = GETPOST('ref_supplier', 'alpha');
$object->socid = GETPOST('socid', 'int');
$object->libelle = GETPOST('label', 'nohtml');
$object->date = $datefacture;
$object->date = $dateinvoice;
$object->date_echeance = $datedue;
$object->note_public = GETPOST('note_public', 'restricthtml');
$object->note_private = GETPOST('note_private', 'restricthtml');
@ -723,13 +727,18 @@ if (empty($reshook))
$action = 'create';
$error++;
}
if ($datefacture == '')
{
if (empty($dateinvoice)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors');
$action = 'create';
$_GET['socid'] = $_POST['socid'];
$error++;
} 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 (!GETPOST('ref_supplier'))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('RefSupplier')), null, 'errors');
@ -748,7 +757,7 @@ if (empty($reshook))
$object->socid = GETPOST('socid', 'int');
$object->libelle = GETPOST('label', 'nohtml');
$object->label = GETPOST('label', 'nohtml');
$object->date = $datefacture;
$object->date = $dateinvoice;
$object->date_echeance = $datedue;
$object->note_public = GETPOST('note_public', 'restricthtml');
$object->note_private = GETPOST('note_private', 'restricthtml');
@ -837,13 +846,17 @@ if (empty($reshook))
$error++;
}
if ($datefacture == '')
{
if (empty($dateinvoice)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors');
$action = 'create';
$_GET['socid'] = $_POST['socid'];
$error++;
} 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 (!GETPOST('ref_supplier'))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('RefSupplier')), null, 'errors');
@ -861,7 +874,7 @@ if (empty($reshook))
$object->ref_supplier = $_POST['ref_supplier'];
$object->socid = $_POST['socid'];
$object->libelle = $_POST['label'];
$object->date = $datefacture;
$object->date = $dateinvoice;
$object->date_echeance = $datedue;
$object->note_public = GETPOST('note_public', 'restricthtml');
$object->note_private = GETPOST('note_private', 'restricthtml');
@ -1191,9 +1204,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);
@ -1297,10 +1310,10 @@ if (empty($reshook))
if (!empty($product_desc) && trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
$type = $productsupplier->type;
if ($price_ht != '' || $price_ht_devise != '') {
if (GETPOST('price_ht') != '' || GETPOST('price_ht_devise') != '') {
$price_base_type = 'HT';
$pu = price2num($price_ht, 'MU');
$pu_ht_devise = price2num($price_ht_devise, 'MU');
$pu_ht_devise = price2num($price_ht_devise, 'CU');
} else {
$price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT');
if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency
@ -1378,15 +1391,14 @@ if (empty($reshook))
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
$localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
if ($price_ht !== '')
{
if (GETPOST('price_ht') != '' || GETPOST('price_ht_devise') != '') {
$pu_ht = price2num($price_ht, 'MU'); // $pu_ht must be rounded according to settings
} else {
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
$pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); // $pu_ht must be rounded according to settings
}
$price_base_type = 'HT';
$pu_ht_devise = price2num($price_ht_devise, 'MU');
$pu_ht_devise = price2num($price_ht_devise, 'CU');
$result = $object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_ht_devise, $ref_supplier);
}

View File

@ -409,6 +409,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
}
function callForResult(imgId)
{
console.log("callForResult Calculate total of payment");
var json = {};
var form = $("#payment_form");
@ -445,6 +446,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
}
});
}
callForResult();
$("#payment_form").find("input.amount").change(function() {
callForResult();
});
@ -690,10 +692,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
if (!empty($conf->use_javascript_ajax))
print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'");
print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
print '<input type="text" size="8" class="amount" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
print '<input type="text" size="8" class="amount" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">'; // class is requied to be used by javascript callForResult();
} else {
print '<input type="text" size="8" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>';
print '<input type="hidden" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
print '<input type="hidden" class="amount" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">'; // class is requied to be used by javascript callForResult();
}
print "</td>";

View File

@ -820,6 +820,7 @@ IMG;
// Export to PDF using LibreOffice
if ($conf->global->MAIN_ODT_AS_PDF == 'libreoffice')
{
// Install prerequisites: apt install soffice libreoffice-common libreoffice-writer
// using windows libreoffice that must be in path
// using linux/mac libreoffice that must be in path
// Note PHP Config "fastcgi.impersonate=0" must set to 0 - Default is 1
@ -856,7 +857,7 @@ IMG;
}
else
{
// deprecated old method
// deprecated old method using odt2pdf.sh (native, jodconverter, ...)
$tmpname=preg_replace('/\.odt/i', '', $name);
if (!empty($conf->global->MAIN_DOL_SCRIPTS_ROOT))

View File

@ -39,6 +39,9 @@ UPDATE llx_adherent SET ref = rowid WHERE ref = '' or ref IS NULL;
ALTER TABLE llx_adherent MODIFY COLUMN ref varchar(30) NOT NULL;
ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_ref (ref, entity);
ALTER TABLE llx_societe ADD COLUMN accountancy_code_sell varchar(32) AFTER webservices_key;
ALTER TABLE llx_societe ADD COLUMN accountancy_code_buy varchar(32) AFTER accountancy_code_sell;
ALTER TABLE llx_bank_account ADD COLUMN ics varchar(32) NULL;
ALTER TABLE llx_bank_account ADD COLUMN ics_transfer varchar(32) NULL;
@ -48,6 +51,7 @@ ALTER TABLE llx_website ADD COLUMN lastaccess datetime NULL;
ALTER TABLE llx_website ADD COLUMN pageviews_month BIGINT UNSIGNED DEFAULT 0;
ALTER TABLE llx_website ADD COLUMN pageviews_total BIGINT UNSIGNED DEFAULT 0;
CREATE TABLE llx_workstation_workstation(
-- BEGIN MODULEBUILDER FIELDS
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
@ -88,3 +92,9 @@ CREATE TABLE llx_workstation_workstation_usergroup(
fk_workstation integer
) ENGINE=innodb;
ALTER TABLE llx_propal ADD COLUMN fk_warehouse integer DEFAULT NULL AFTER fk_shipping_method;
ALTER TABLE llx_propal ADD CONSTRAINT llx_propal_fk_warehouse FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot(rowid);
ALTER TABLE llx_propal ADD INDEX idx_propal_fk_warehouse(fk_warehouse);

View File

@ -28,9 +28,11 @@ ALTER TABLE llx_propal ADD INDEX idx_propal_fk_user_cloture (fk_user_cloture);
ALTER TABLE llx_propal ADD INDEX idx_propal_fk_projet (fk_projet);
ALTER TABLE llx_propal ADD INDEX idx_propal_fk_account(fk_account);
ALTER TABLE llx_propal ADD INDEX idx_propal_fk_currency(fk_currency);
ALTER TABLE llx_propal ADD INDEX idx_propal_fk_warehouse(fk_warehouse);
ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid);
ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_cloture FOREIGN KEY (fk_user_cloture) REFERENCES llx_user (rowid);
ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid);
ALTER TABLE llx_propal ADD CONSTRAINT llx_propal_fk_warehouse FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot(rowid);

View File

@ -66,6 +66,7 @@ create table llx_propal
date_livraison date DEFAULT NULL, -- delivery date
fk_shipping_method integer, -- shipping method id
fk_warehouse integer DEFAULT NULL, -- warehouse id
fk_availability integer NULL,
fk_input_reason integer,
fk_incoterms integer, -- for incoterms

View File

@ -116,6 +116,9 @@ create table llx_societe
webservices_url varchar(255), -- supplier webservice url
webservices_key varchar(128), -- supplier webservice key
accountancy_code_sell varchar(32), -- Selling accountancy code
accountancy_code_buy varchar(32), -- Buying accountancy code
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- last modification date
datec datetime, -- creation date
fk_user_creat integer NULL, -- utilisateur qui a cree l'info

View File

@ -16,6 +16,8 @@ ThisService=This service
ThisProduct=This product
DefaultForService=Default for service
DefaultForProduct=Default for product
ProductForThisThirdparty=Product for this thirdparty
ServiceForThisThirdparty=Service for this thirdparty
CantSuggest=Can't suggest
AccountancySetupDoneFromAccountancyMenu=Most setup of the accountancy is done from the menu %s
ConfigAccountingExpert=Configuration of the module accounting (double entry)

View File

@ -175,3 +175,5 @@ Answered=Answered
IsNotAnAnswer=Is not answer (initial email)
IsAnAnswer=Is an answer of an initial email
RecordCreatedByEmailCollector=Record created by the Email Collector %s from email %s
DefaultBlacklistMailingStatus=Default contact status for refuse bulk emailing
DefaultStatusEmptyMandatory=Empty but mandatory

View File

@ -1113,6 +1113,7 @@ OutOfDate=Out-of-date
EventReminder=Event Reminder
UpdateForAllLines=Update for all lines
OnHold=On hold
Civility=Civility
AffectTag=Affect Tag
ConfirmAffectTag=Bulk Tag Affect
ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected record(s)?

View File

@ -62,6 +62,7 @@ EnhancedValueOfWarehouses=Warehouses value
UserWarehouseAutoCreate=Create a user warehouse automatically when creating a user
AllowAddLimitStockByWarehouse=Manage also value for minimum and desired stock per pairing (product-warehouse) in addition to the value for minimum and desired stock per product
RuleForWarehouse=Rule for warehouses
WarehouseAskWarehouseDuringPropal=Set a warehouse on Sale propal
WarehouseAskWarehouseDuringOrder=Set a warehouse on Sale orders
UserDefaultWarehouse=Set a warehouse on Users
MainDefaultWarehouse=Default warehouse

View File

@ -21,3 +21,5 @@ descWORKFLOW_BILL_ON_RECEPTION=Classify receptions to "billed" when a linked sup
descWORKFLOW_TICKET_CLOSE_INTERVENTION=Close all interventions linked to the ticket when a ticket is closed
AutomaticCreation=Automatic creation
AutomaticClassification=Automatic classification
# Autoclassify shipment
descWORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE=Classify linked source shipment as closed when customer invoice is validated

View File

@ -62,6 +62,7 @@ EnhancedValueOfWarehouses=Valorisation des stocks
UserWarehouseAutoCreate=Créer automatiquement un stock/entrepôt propre à l'utilisateur lors de sa création
AllowAddLimitStockByWarehouse=Gérez également les valeurs des stocks minimums et souhaités par paire (produit-entrepôt) en plus des valeurs de minimums et souhaités par produit
RuleForWarehouse=Règle pour les entrepôts
WarehouseAskWarehouseDuringPropal=Définir un entrepôt sur les Propositions
WarehouseAskWarehouseDuringOrder=Définir un entrepôt sur les commandes
UserDefaultWarehouse=Définir un entrepôt sur les utilisateurs
MainDefaultWarehouse=Entrepôt par défaut

View File

@ -145,7 +145,9 @@ if ($action == 'updateMask') {
$tmpobjectkey = GETPOST('object');
if (!empty($tmpobjectkey)) {
$constforval = 'MYMODULE_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
if ($conf->global->$constforval == "$value") dolibarr_del_const($db, $constforval, $conf->entity);
if ($conf->global->$constforval == "$value") {
dolibarr_del_const($db, $constforval, $conf->entity);
}
}
}
} elseif ($action == 'setdoc') {
@ -338,9 +340,10 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval);
$htmltooltip .= $nextval.'<br>';
}
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip .= $langs->trans($module->error).'<br>';
}

View File

@ -53,8 +53,11 @@ if (!$res) die("Include of main fails");
header('Content-Type: application/javascript');
// Important: Following code is to cache this file to avoid page request by browser at each Dolibarr page access.
// You can use CTRL+F5 to refresh your browser cache.
if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
else header('Cache-Control: no-cache');
if (empty($dolibarr_nocache)) {
header('Cache-Control: max-age=3600, public, must-revalidate');
} else {
header('Cache-Control: no-cache');
}
?>
/* Javascript library of module MyModule */

View File

@ -81,7 +81,7 @@ if (GETPOST('actioncode', 'array')) {
$actioncode = '0';
}
} else {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
$actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
}
$search_agenda_label = GETPOST('search_agenda_label');

View File

@ -128,7 +128,9 @@ $upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object-
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
$error = 0;
@ -137,8 +139,11 @@ if (empty($reshook)) {
if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
$backtopage = $backurlforlist;
} else {
$backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
}
}
}
@ -476,7 +481,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Validate
if ($object->status == $object::STATUS_DRAFT) {
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', $permissiontoadd);
} else {
$langs->load("errors");

View File

@ -73,36 +73,30 @@ $permission = $user->rights->mymodule->myobject->write;
* Add a new contact
*/
if ($action == 'addcontact' && $permission)
{
if ($action == 'addcontact' && $permission) {
$contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors");
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
} // Toggle the status of a contact
elseif ($action == 'swapstatut' && $permission)
{
} elseif ($action == 'swapstatut' && $permission) {
// Toggle the status of a contact
$result = $object->swapContactStatus(GETPOST('ligne'));
} // Deletes a contact
elseif ($action == 'deletecontact' && $permission)
{
} elseif ($action == 'deletecontact' && $permission) {
// Deletes a contact
$result = $object->delete_contact($lineid);
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@ -132,8 +126,7 @@ $userstatic = new User($db);
/* */
/* *************************************************************************** */
if ($object->id)
{
if ($object->id) {
/*
* Show tabs
*/
@ -191,10 +184,11 @@ if ($object->id)
// Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
foreach ($dirtpls as $reldir)
{
foreach ($dirtpls as $reldir) {
$res = @include dol_buildpath($reldir.'/contacts.tpl.php');
if ($res) break;
if ($res) {
break;
}
}
}

View File

@ -46,6 +46,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
$langs->loadLangs(array("companies", "commercial", "bills", "banks", "users"));
if (!empty($conf->adherent->enabled)) $langs->load("members");
@ -394,6 +397,11 @@ if (empty($reshook))
$error++;
}
if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1 && GETPOST('contact_no_email', 'int')==-1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")), null, 'errors');
}
if (!$error)
{
if ($action == 'update')
@ -476,6 +484,9 @@ if (empty($reshook))
$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))
{
@ -562,7 +573,9 @@ if (empty($reshook))
if ($object->particulier)
{
dol_syslog("We ask to create a contact/address too", LOG_DEBUG);
$result = $object->create_individual($user);
$contcats = GETPOST('contcats', 'array');
$no_email = GETPOST('contact_no_email', 'int');
$result = $object->create_individual($user, $no_email, $contcats);
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
@ -903,6 +916,7 @@ $form = new Form($db);
$formfile = new FormFile($db);
$formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db);
if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
if ($socid > 0 && empty($object->id))
{
@ -1043,6 +1057,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$object->commercial_id = GETPOST('commercial_id', 'int');
$object->default_lang = GETPOST('default_lang');
$object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
$object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
$object->logo = (isset($_FILES['photo']) ?dol_sanitizeFileName($_FILES['photo']['name']) : '');
// Gestion du logo de la société
@ -1146,8 +1163,23 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$("#selectcountry_id").change(function() {
document.formsoc.action.value="create";
document.formsoc.submit();
});
});';
});';
if ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1) {
print '
function init_check_no_email(input) {
if (input.val()!="") {
$(".noemail").addClass("fieldrequired");
} else {
$(".noemail").removeClass("fieldrequired");
}
}
$("#email").keyup(function() {
init_check_no_email($(this));
});
init_check_no_email($("#email"));
});';
}
print '});';
print '</script>'."\n";
print '<div id="selectthirdpartytype">';
@ -1356,7 +1388,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// Email / Web
print '<tr><td>'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', empty($conf->global->SOCIETE_EMAIL_MANDATORY) ? '' : $conf->global->SOCIETE_EMAIL_MANDATORY).'</td>';
print '<td colspan="3">'.img_picto('', 'object_email').' <input type="text" class="maxwidth500 widthcentpercentminusx" name="email" id="email" value="'.$object->email.'"></td></tr>';
print '<td'.(($conf->browser->layout == 'phone') || empty($conf->mailing->enabled) ? ' colspan="3"' : '').'>'.img_picto('', 'object_email').' <input type="text" class="maxwidth200 widthcentpercentminusx" name="email" id="email" value="'.$object->email.'"></td>';
if (!empty($conf->mailing->enabled) && !empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
if ($conf->browser->layout == 'phone') print '</tr><tr>';
print '<td class="individualline noemail">'.$form->editfieldkey($langs->trans('No_Email') .' ('.$langs->trans('Contact').')', 'contact_no_email', '', $object, 0).'</td>';
print '<td class="individualline" '.(($conf->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).'</td>';
}
print '</tr>';
print '<tr><td>'.$form->editfieldkey('Web', 'url', '', $object, 0).'</td>';
print '<td colspan="3">'.img_picto('', 'globe').' <input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="'.$object->url.'"></td></tr>';
@ -1512,6 +1550,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print "</td></tr>";
//}
if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION))
{
print '<tr class="individualline"><td class="toptd">'.$form->editfieldkey('ContactCategoriesShort', 'contcats', '', $object, 0).'</td><td colspan="3">';
$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 "</td></tr>";
}
// Supplier
if (!empty($conf->fournisseur->enabled)) {
print '<tr class="visibleifsupplier"><td class="toptd">'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).'</td><td colspan="3">';
@ -1555,6 +1601,39 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '</table>'."\n";
// Accountancy codes
print '<table class="border" width="100%">';
if (! empty($conf->accounting->enabled))
{
// Accountancy_code_sell
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
print '<td>';
$accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, null, 1, 1, '');
print '</td></tr>';
// Accountancy_code_buy
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
print '<td>';
$accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, '');
print '</td></tr>';
}
else // For external software
{
// Accountancy_code_sell
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.'">';
print '</td></tr>';
// Accountancy_code_buy
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.'">';
print '</td></tr>';
}
print '</table>';
print dol_get_fiche_end();
print '<div class="center">';
@ -1669,6 +1748,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))
{
@ -2198,10 +2280,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 '</td></tr>';
print '</table>';
print '<br>';
print '<table class="border" width="100%">';
if (! empty($conf->accounting->enabled))
{
// Accountancy_code_sell
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>';
print '<td>';
print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1);
print '</td></tr>';
// Accountancy_code_buy
print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
print '<td>';
print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1);
print '</td></tr>';
}
else // For external software
{
// Accountancy_code_sell
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>';
print '<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.'">';
print '</td></tr>';
// Accountancy_code_buy
print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
print '<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.'">';
print '</td></tr>';
}
print '</table>';
print '</div>';
print dol_get_fiche_end();
print dol_get_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
@ -2579,6 +2693,42 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '</td></tr>';
}
// Accountancy sell code
print '<tr><td class="nowrap">';
print $langs->trans("ProductAccountancySellCode");
print '</td><td colspan="2">';
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 '</td></tr>';
// Accountancy buy code
print '<tr><td class="nowrap">';
print $langs->trans("ProductAccountancyBuyCode");
print '</td><td colspan="2">';
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 '</td></tr>';
// Other attributes
$parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';

View File

@ -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;
}
}
}

View File

@ -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') : '');

View File

@ -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=<?php echo $place; ?> tva_tx="+vatRate);
$.get( "invoice.php", { action: "<?php echo $action; ?>", place: "<?php echo $place; ?>", desc:$('#desc').val(), number:$('#number').val(), tva_tx: vatRate} );
parent.$("#poslines").load("invoice.php?action=freezone&place=<?php echo $place; ?>&desc="+$('#desc').val()+"&number="+$('#number').val()+"&tva_tx="+vatRate);
parent.$.colorbox.close();
}

View File

@ -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:"<?php echo $langs->trans("FreeZone"); ?>"});
$.colorbox({href:"freezone.php?action=freezone&place="+place, width:"80%", height:"200px", transition:"none", iframe:"true", title:"<?php echo $langs->trans("FreeZone"); ?>"});
}
function TakeposOrderNotes() {