Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2020-03-18 19:07:26 +01:00
commit a56a3d64b3
8 changed files with 51 additions and 25 deletions

View File

@ -70,11 +70,11 @@ $arrayfields = array(
'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1), 'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1),
'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1),
'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'),
'aa.reconciliable'=>array('label'=>$langs->trans("Reconciliable"), 'checked'=>1), 'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1),
'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1)
); );
if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['aa.reconciliable']); if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['aa.reconcilable']);
$accounting = new AccountingAccount($db); $accounting = new AccountingAccount($db);
@ -197,7 +197,7 @@ if ($action == 'delete') {
$pcgver = $conf->global->CHARTOFACCOUNTS; $pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent , aa.label, aa.labelshort, aa.reconciliable, aa.active, "; $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent , aa.label, aa.labelshort, aa.reconcilable, aa.active, ";
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity;
@ -357,7 +357,7 @@ if ($resql)
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="'.$search_pcgtype.'"></td>'; if (!empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="'.$search_pcgtype.'"></td>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($arrayfields['aa.reconciliable']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($arrayfields['aa.reconcilable']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; }
if (!empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; if (!empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre maxwidthsearch">'; print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
@ -371,7 +371,7 @@ if ($resql)
if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); if (!empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left ');
if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']); if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']);
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($arrayfields['aa.reconciliable']['checked'])) print_liste_field_titre($arrayfields['aa.reconciliable']['label'], $_SERVER["PHP_SELF"], 'aa.reconciliable', '', $param, '', $sortfield, $sortorder); } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($arrayfields['aa.reconcilable']['checked'])) print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); }
if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";
@ -450,9 +450,9 @@ if ($resql)
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
// Activated or not reconciliation on accounting account // Activated or not reconciliation on accounting account
if (!empty($arrayfields['aa.reconciliable']['checked'])) { if (!empty($arrayfields['aa.reconcilable']['checked'])) {
print '<td class="center">'; print '<td class="center">';
if (empty($obj->reconciliable)) { if (empty($obj->reconcilable)) {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=enable&mode=1">'; print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=enable&mode=1">';
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>'; print '</a>';

View File

@ -136,9 +136,9 @@ class AccountingAccount extends CommonObject
public $active; public $active;
/** /**
* @var int reconciliable * @var int reconcilable
*/ */
public $reconciliable; public $reconcilable;
/** /**
* Constructor * Constructor
@ -167,7 +167,7 @@ class AccountingAccount extends CommonObject
global $conf; global $conf;
if ($rowid || $account_number) { if ($rowid || $account_number) {
$sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active, a.reconciliable"; $sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active, a.reconcilable";
$sql .= ", ca.label as category_label"; $sql .= ", ca.label as category_label";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid";
@ -208,7 +208,7 @@ class AccountingAccount extends CommonObject
$this->fk_user_modif = $obj->fk_user_modif; $this->fk_user_modif = $obj->fk_user_modif;
$this->active = $obj->active; $this->active = $obj->active;
$this->status = $obj->active; $this->status = $obj->active;
$this->reconciliable = $obj->reconciliable; $this->reconcilable = $obj->reconcilable;
return $this->id; return $this->id;
} else { } else {
@ -267,7 +267,7 @@ class AccountingAccount extends CommonObject
$sql .= ", fk_accounting_category"; $sql .= ", fk_accounting_category";
$sql .= ", fk_user_author"; $sql .= ", fk_user_author";
$sql .= ", active"; $sql .= ", active";
$sql .= ", reconciliable"; $sql .= ", reconcilable";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= " '" . $this->db->idate($now) . "'"; $sql .= " '" . $this->db->idate($now) . "'";
$sql .= ", " . $conf->entity; $sql .= ", " . $conf->entity;
@ -280,7 +280,7 @@ class AccountingAccount extends CommonObject
$sql .= ", " . (empty($this->account_category) ? 0 : (int) $this->account_category); $sql .= ", " . (empty($this->account_category) ? 0 : (int) $this->account_category);
$sql .= ", " . $user->id; $sql .= ", " . $user->id;
$sql .= ", " . (int) $this->active; $sql .= ", " . (int) $this->active;
$sql .= ", " . (int) $this->reconciliable; $sql .= ", " . (int) $this->reconcilable;
$sql .= ")"; $sql .= ")";
$this->db->begin(); $this->db->begin();
@ -348,7 +348,7 @@ class AccountingAccount extends CommonObject
$sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : (int) $this->account_category); $sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : (int) $this->account_category);
$sql .= " , fk_user_modif = " . $user->id; $sql .= " , fk_user_modif = " . $user->id;
$sql .= " , active = " . (int) $this->active; $sql .= " , active = " . (int) $this->active;
$sql .= " , reconciliable = " . (int) $this->reconciliable; $sql .= " , reconcilable = " . (int) $this->reconcilable;
$sql .= " WHERE rowid = " . $this->id; $sql .= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
@ -588,7 +588,7 @@ class AccountingAccount extends CommonObject
} }
elseif ($mode == 1) elseif ($mode == 1)
{ {
$fieldtouse = 'reconciliable'; $fieldtouse = 'reconcilable';
} }
if ($result > 0) { if ($result > 0) {
@ -619,7 +619,7 @@ class AccountingAccount extends CommonObject
* Account activated * Account activated
* *
* @param int $id Id * @param int $id Id
* @param int $mode 0=field active, 1=field reconciliable, 2=field active_customer_list, 3=field_active_supplier_list * @param int $mode 0=field active, 1=field reconcilable
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function account_activate($id, $mode = 0) public function account_activate($id, $mode = 0)
@ -633,7 +633,7 @@ class AccountingAccount extends CommonObject
} }
elseif ($mode == 1) elseif ($mode == 1)
{ {
$fieldtouse = 'reconciliable'; $fieldtouse = 'reconcilable';
} }
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account "; $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";

View File

@ -1618,7 +1618,7 @@ class Form
public function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $noactive = 0, $outputmode = 0, $multiple = false) public function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $noactive = 0, $outputmode = 0, $multiple = false)
{ {
// phpcs:enable // phpcs:enable
global $conf, $user, $langs; global $conf, $user, $langs, $hookmanager;
// If no preselected user defined, we take current user // If no preselected user defined, we take current user
if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected = $user->id; if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected = $user->id;
@ -1679,6 +1679,10 @@ class Form
if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) $sql .= " AND u.statut <> 0"; if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) $sql .= " AND u.statut <> 0";
if (!empty($morefilter)) $sql .= " ".$morefilter; if (!empty($morefilter)) $sql .= " ".$morefilter;
//Add hook to filter on user (for exemple on usergroup define in custom modules)
$reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectUsers', array(), $this, $action);
if (!empty($reshook)) $sql .= $hookmanager->resPrint;
if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname
{ {
$sql .= " ORDER BY u.firstname ASC"; $sql .= " ORDER BY u.firstname ASC";

View File

@ -424,7 +424,7 @@ class FormOther
public function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '', $norepresentative = 0) public function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '', $norepresentative = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs; global $conf, $langs, $hookmanager;
$langs->load('users'); $langs->load('users');
@ -440,6 +440,9 @@ class FormOther
$out .= $comboenhancement; $out .= $comboenhancement;
} }
} }
$reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectSalesRep', array(), $this, $action);
// Select each sales and print them in a select input // Select each sales and print them in a select input
$out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">'; $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">';
if ($showempty) $out .= '<option value="0">&nbsp;</option>'; if ($showempty) $out .= '<option value="0">&nbsp;</option>';
@ -464,6 +467,10 @@ class FormOther
if (empty($user->rights->user->user->lire)) $sql_usr .= " AND u.rowid = ".$user->id; if (empty($user->rights->user->user->lire)) $sql_usr .= " AND u.rowid = ".$user->id;
if (!empty($user->socid)) $sql_usr .= " AND u.fk_soc = ".$user->socid; if (!empty($user->socid)) $sql_usr .= " AND u.fk_soc = ".$user->socid;
//Add hook to filter on user (for exemple on usergroup define in custom modules)
if (!empty($reshook)) $sql_usr .= $hookmanager->resArray[0];
// Add existing sales representatives of thirdparty of external user // Add existing sales representatives of thirdparty of external user
if (empty($user->rights->user->user->lire) && $user->socid) if (empty($user->rights->user->user->lire) && $user->socid)
{ {
@ -485,6 +492,9 @@ class FormOther
} }
$sql_usr .= " AND u2.rowid = sc.fk_user AND sc.fk_soc=".$user->socid; $sql_usr .= " AND u2.rowid = sc.fk_user AND sc.fk_soc=".$user->socid;
//Add hook to filter on user (for exemple on usergroup define in custom modules)
if (!empty($reshook)) $sql_usr .= $hookmanager->resArray[1];
} }
$sql_usr .= " ORDER BY statut DESC, lastname ASC"; // Do not use 'ORDER BY u.statut' here, not compatible with the UNION. $sql_usr .= " ORDER BY statut DESC, lastname ASC"; // Do not use 'ORDER BY u.statut' here, not compatible with the UNION.
//print $sql_usr;exit; //print $sql_usr;exit;

View File

@ -330,11 +330,20 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
} }
// Recipient name // Recipient name
$contactobject = null;
if (!empty($usecontact)) if (!empty($usecontact))
{ {
// On peut utiliser le nom de la societe du contact // On peut utiliser le nom de la societe du contact
if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
else $socobject = $object->thirdparty; {
$socobject = $object->contact;
}
else
{
$socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
$contactobject = $object->contact;
}
} }
else else
{ {
@ -405,7 +414,10 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_other = $this->get_substitutionarray_other($outputlangs); $array_other = $this->get_substitutionarray_other($outputlangs);
$tmparray = array_merge($substitutionarray, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other); $array_thirdparty_contact = array();
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
$tmparray = array_merge($substitutionarray, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
complete_substitutions_array($tmparray, $outputlangs, $object); complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook // Call the ODTSubstitution hook

View File

@ -193,4 +193,4 @@ ALTER TABLE llx_accounting_account DROP COLUMN pcg_subtype;
ALTER TABLE llx_product ADD COLUMN accountancy_code_buy_intra varchar(32) AFTER accountancy_code_buy; ALTER TABLE llx_product ADD COLUMN accountancy_code_buy_intra varchar(32) AFTER accountancy_code_buy;
ALTER TABLE llx_product ADD COLUMN accountancy_code_buy_export varchar(32) AFTER accountancy_code_buy_intra; ALTER TABLE llx_product ADD COLUMN accountancy_code_buy_export varchar(32) AFTER accountancy_code_buy_intra;
ALTER TABLE llx_accounting_account ADD COLUMN reconciliable tinyint DEFAULT 0 NOT NULL after active; ALTER TABLE llx_accounting_account ADD COLUMN reconcilable tinyint DEFAULT 0 NOT NULL after active;

View File

@ -35,7 +35,7 @@ create table llx_accounting_account
fk_user_author integer DEFAULT NULL, fk_user_author integer DEFAULT NULL,
fk_user_modif integer DEFAULT NULL, fk_user_modif integer DEFAULT NULL,
active tinyint DEFAULT 1 NOT NULL, active tinyint DEFAULT 1 NOT NULL,
reconciliable tinyint DEFAULT 0 NOT NULL, reconcilable tinyint DEFAULT 0 NOT NULL,
import_key varchar(14), import_key varchar(14),
extraparams varchar(255) -- for other parameters with json format extraparams varchar(255) -- for other parameters with json format
)ENGINE=innodb; )ENGINE=innodb;

View File

@ -239,7 +239,7 @@ HideOpeningBalance=Hide opening balance
Pcgtype=Group of account Pcgtype=Group of account
PcgtypeDesc=Group of account are used as predefined 'filter' and 'grouping' criteria for some accounting reports. For example, 'INCOME' or 'EXPENSE' are used as groups for accounting accounts of products to build the expense/income report. PcgtypeDesc=Group of account are used as predefined 'filter' and 'grouping' criteria for some accounting reports. For example, 'INCOME' or 'EXPENSE' are used as groups for accounting accounts of products to build the expense/income report.
Reconciliable=Reconcilable Reconcilable=Reconcilable
TotalVente=Total turnover before tax TotalVente=Total turnover before tax
TotalMarge=Total sales margin TotalMarge=Total sales margin