Merge branch 'develop' into salesrepresentativeinorderandinvoicelist

This commit is contained in:
Laurent Destailleur
2021-08-11 22:22:26 +02:00
committed by GitHub
3499 changed files with 60715 additions and 42387 deletions

View File

@@ -91,6 +91,10 @@ $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($con
if (!empty($user->socid)) {
$socid = $user->socid;
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('ordercard', 'globalcard'));
$result = restrictedArea($user, 'commande', $id);
$object = new Commande($db);
@@ -102,9 +106,6 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('ordercard', 'globalcard'));
$usercanread = $user->rights->commande->lire;
$usercancreate = $user->rights->commande->creer;
$usercandelete = $user->rights->commande->supprimer;
@@ -645,15 +646,15 @@ if (empty($reshook)) {
}
}
if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) {
if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) {
setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
$error++;
}
if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) {
if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('type') < 0) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
$error++;
}
if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht == '' && $price_ht_devise == '') { // Unit price can be 0 but not ''. Also price can be negative for order.
if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && $price_ht == '' && $price_ht_devise == '') { // Unit price can be 0 but not ''. Also price can be negative for order.
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
$error++;
}
@@ -661,7 +662,7 @@ if (empty($reshook)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
$error++;
}
if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) {
if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors');
$error++;
}
@@ -680,7 +681,7 @@ if (empty($reshook)) {
}
}
if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) {
if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
// Clean parameters
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
@@ -690,7 +691,7 @@ if (empty($reshook)) {
// Ecrase $desc par celui du produit
// Ecrase $tva_tx par celui du produit
// Ecrase $base_price_type par celui du produit
if (!empty($idprod)) {
if (!empty($idprod) && $idprod > 0) {
$prod = new Product($db);
$prod->fetch($idprod);
@@ -1626,36 +1627,36 @@ if ($action == 'create' && $usercancreate) {
print "</td>\n";
print '</tr>';
// terms of the settlement
// Terms of the settlement
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
print img_picto('', 'paiment');
$form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1);
print '</td></tr>';
// 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 img_picto('', 'bank', 'class="pictofixedwidth"');
$form->select_types_paiements($mode_reglement_id, 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';
// Bank Account
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 img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes($fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 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 img_picto('', 'clock', 'class="pictofixedwidth"');
$form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx');
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 img_picto('', 'object_dollyrevert', 'class="pictofixedwidth"');
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';
}
@@ -1664,13 +1665,14 @@ if ($action == 'create' && $usercancreate) {
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 img_picto('', 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx');
print '</td></tr>';
}
// What trigger creation
// Source / Channle - What trigger creation
print '<tr><td>'.$langs->trans('Channel').'</td><td>';
$form->selectInputReason($demand_reason_id, 'demand_reason_id', '', 1);
print img_picto('', 'question', 'class="pictofixedwidth"');
$form->selectInputReason($demand_reason_id, 'demand_reason_id', '', 1, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';
// TODO How record was recorded OrderMode (llx_c_input_method)
@@ -1680,8 +1682,7 @@ if ($action == 'create' && $usercancreate) {
$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, 0, 0, 0, 0, '', 0, 0, 'maxwidth175 maxwidth500 widthcentpercentminusxx');
print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx');
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" title="'.$langs->trans("AddProject").'"></span></a>';
print '</td>';
print '</tr>';
@@ -1723,11 +1724,11 @@ if ($action == 'create' && $usercancreate) {
// Template to use by default
print '<tr><td>'.$langs->trans('DefaultModel').'</td>';
print '<td>';
print img_picto('', 'pdf').'&ensp;';
print img_picto('', 'pdf', 'class="pictofixedwidth"');
include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
$liste = ModelePDFCommandes::liste_modeles($db);
$preselected = $conf->global->COMMANDE_ADDON_PDF;
print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1);
print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
print "</td></tr>";
// Multicurrency
@@ -2417,10 +2418,11 @@ if ($action == 'create' && $usercancreate) {
*/
$result = $object->getLinesArray();
print '<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
print '<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
<input type="hidden" name="token" value="' . newToken().'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value="">
<input type="hidden" name="page_y" value="">
<input type="hidden" name="id" value="' . $object->id.'">';
if (!empty($conf->use_javascript_ajax) && $object->statut == Commande::STATUS_DRAFT) {

View File

@@ -195,7 +195,7 @@ class Commande extends CommonOrder
/**
* @var int Date expected for delivery
* @see delivery_date
* @see $delivery_date
* @deprecated
*/
public $date_livraison;
@@ -1368,7 +1368,7 @@ class Commande extends CommonOrder
}
// Possibility to add external linked objects with hooks
$this->linked_objects[$this->origin] = $this->origin_id;
if (is_array($object->other_linked_objects) && !empty($object->other_linked_objects)) {
if (isset($object->other_linked_objects) && is_array($object->other_linked_objects) && !empty($object->other_linked_objects)) {
$this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
}
@@ -1518,7 +1518,7 @@ class Commande extends CommonOrder
$this->db->begin();
$product_type = $type;
if (!empty($fk_product)) {
if (!empty($fk_product) && $fk_product > 0) {
$product = new Product($this->db);
$result = $product->fetch($fk_product);
$product_type = $product->type;
@@ -2347,6 +2347,10 @@ class Commande extends CommonOrder
// For triggers
$line->fetch($lineid);
// Memorize previous line for triggers
$staticline = clone $line;
$line->oldline = $staticline;
if ($line->delete($user) > 0) {
$result = $this->update_price(1);
@@ -2539,7 +2543,7 @@ class Commande extends CommonOrder
$sql = "UPDATE ".MAIN_DB_PREFIX."commande";
$sql .= " SET date_commande = ".($date ? "'".$this->db->idate($date)."'" : 'null');
$sql .= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
$sql .= " WHERE rowid = ".$this->id." AND fk_statut = ".((int) self::STATUS_DRAFT);
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
@@ -4010,7 +4014,7 @@ class Commande extends CommonOrder
$now = dol_now();
return max($this->date_commande, $this->date_livraison) < ($now - $conf->commande->client->warning_delay);
return max($this->date, $this->date_livraison) < ($now - $conf->commande->client->warning_delay);
}
/**
@@ -4127,7 +4131,7 @@ class OrderLine extends CommonOrderLine
$sql .= ' cd.fk_unit,';
$sql .= ' cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc,';
$sql .= ' p.ref as product_ref, p.label as product_label, p.description as product_desc, p.tobatch as product_tobatch,';
$sql .= ' cd.date_start, cd.date_end';
$sql .= ' cd.date_start, cd.date_end, cd.vat_src_code';
$sql .= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
$sql .= ' WHERE cd.rowid = '.((int) $rowid);
@@ -4348,7 +4352,8 @@ class OrderLine extends CommonOrderLine
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0 && $pa_ht_isemptystring) {
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) {
$result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product);
if ($result < 0) {
return $result;
} else {
$this->pa_ht = $result;
@@ -4384,7 +4389,7 @@ class OrderLine extends CommonOrderLine
$sql .= " '".price2num($this->localtax2_tx)."',";
$sql .= " '".$this->db->escape($this->localtax1_type)."',";
$sql .= " '".$this->db->escape($this->localtax2_type)."',";
$sql .= ' '.(!empty($this->fk_product) ? $this->fk_product : "null").',';
$sql .= ' '.((!empty($this->fk_product) && $this->fk_product > 0) ? $this->fk_product : "null").',';
$sql .= " '".$this->db->escape($this->product_type)."',";
$sql .= " '".price2num($this->remise_percent)."',";
$sql .= " ".(price2num($this->subprice) !== '' ?price2num($this->subprice) : "null").",";
@@ -4525,7 +4530,8 @@ class OrderLine extends CommonOrderLine
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0 && $pa_ht_isemptystring) {
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) {
$result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product);
if ($result < 0) {
return $result;
} else {
$this->pa_ht = $result;
@@ -4559,14 +4565,14 @@ class OrderLine extends CommonOrderLine
}
$sql .= " , fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? $this->fk_fournprice : "null");
$sql .= " , buy_price_ht='".price2num($this->pa_ht)."'";
$sql .= " , info_bits=".$this->info_bits;
$sql .= " , special_code=".$this->special_code;
$sql .= " , info_bits=".((int) $this->info_bits);
$sql .= " , special_code=".((int) $this->special_code);
$sql .= " , date_start=".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null");
$sql .= " , date_end=".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null");
$sql .= " , product_type=".$this->product_type;
$sql .= " , fk_parent_line=".(!empty($this->fk_parent_line) ? $this->fk_parent_line : "null");
if (!empty($this->rang)) {
$sql .= ", rang=".$this->rang;
$sql .= ", rang=".((int) $this->rang);
}
$sql .= " , fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
@@ -4576,7 +4582,7 @@ class OrderLine extends CommonOrderLine
$sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva)."";
$sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc)."";
$sql .= " WHERE rowid = ".$this->rowid;
$sql .= " WHERE rowid = ".((int) $this->rowid);
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);

View File

@@ -44,7 +44,10 @@ class CommandeStats extends Stats
public $userid;
public $from;
public $from_line;
public $field;
public $field_line;
public $categ_link;
public $where;
public $join;
@@ -77,6 +80,7 @@ class CommandeStats extends Stats
$this->field = 'total_ht';
$this->field_line = 'total_ht';
//$this->where .= " c.fk_statut > 0"; // Not draft and not cancelled
$this->categ_link = MAIN_DB_PREFIX.'categorie_societe';
} elseif ($mode == 'supplier') {
$object = new CommandeFournisseur($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as c";
@@ -84,6 +88,7 @@ class CommandeStats extends Stats
$this->field = 'total_ht';
$this->field_line = 'total_ht';
//$this->where .= " c.fk_statut > 2"; // Only approved & ordered
$this->categ_link = MAIN_DB_PREFIX.'categorie_fournisseur';
}
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
$this->where .= ($this->where ? ' AND ' : '').'c.entity IN ('.getEntity('commande').')';
@@ -104,7 +109,7 @@ class CommandeStats extends Stats
}
if ($categid) {
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cats ON cats.fk_soc = c.fk_soc';
$this->join .= ' LEFT JOIN '.$this->categ_link.' as cats ON cats.fk_soc = c.fk_soc';
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cat.rowid = cats.fk_categorie';
$this->where .= ' AND cat.rowid = '.((int) $categid);
}

View File

@@ -89,9 +89,6 @@ $sql .= " AND s.entity IN (".getEntity('societe').")";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if (dol_strlen($stcomm)) {
$sql .= " AND s.fk_stcomm=".$stcomm;
}
if (GETPOST("search_nom")) {
$sql .= natural_search("s.nom", GETPOST("search_nom"));
}

View File

@@ -44,12 +44,6 @@ $confirm = GETPOST('confirm');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref');
// Security check
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'commande', $id, '');
// Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
@@ -78,6 +72,14 @@ if (!$sortfield) {
$object = new Commande($db);
$permissiontoadd = $user->rights->commande->creer;
// Security check
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'commande', $id, '');
/*
* Actions
@@ -182,7 +184,7 @@ if ($id > 0 || !empty($ref)) {
print dol_get_fiche_end();
$modulepart = 'commande';
$permission = $user->rights->commande->creer;
$permissiontoadd = $user->rights->commande->creer;
$permtoedit = $user->rights->commande->creer;
$param = '&id='.$object->id.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity);
include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';

View File

@@ -166,7 +166,7 @@ $sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('commande').")";
//$sql.= " AND c.fk_statut > 2";
if ($socid) {
$sql .= " AND c.fk_soc = ".$socid;
$sql .= " AND c.fk_soc = ".((int) $socid);
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
@@ -250,7 +250,7 @@ if (!empty($conf->commande->enabled)) {
$sql .= " AND c.entity IN (".getEntity('commande').")";
$sql .= " AND c.fk_statut = ".Commande::STATUS_VALIDATED;
if ($socid) {
$sql .= " AND c.fk_soc = ".$socid;
$sql .= " AND c.fk_soc = ".((int) $socid);
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
@@ -337,9 +337,9 @@ if (!empty($conf->commande->enabled)) {
}
$sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('commande').")";
$sql .= " AND c.fk_statut = ".Commande::STATUS_ACCEPTED;
$sql .= " AND c.fk_statut = ".((int) Commande::STATUS_ACCEPTED);
if ($socid) {
$sql .= " AND c.fk_soc = ".$socid;
$sql .= " AND c.fk_soc = ".((int) $socid);
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;

View File

@@ -418,17 +418,18 @@ $sql = 'SELECT';
if ($sall || $search_product_category > 0 || $search_user > 0) {
$sql = 'SELECT DISTINCT';
}
$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 .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, 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 .= " country.code as country_code,";
$sql .= ' c.rowid, c.ref, c.total_ht, c.total_tva, c.total_ttc, c.ref_client, c.fk_user_author,';
$sql .= ' c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva as multicurrency_total_vat, c.multicurrency_total_ttc,';
$sql .= ' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,';
$sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,';
$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
$sql .= " u.login,";
$sql .= ' c.fk_cond_reglement,c.fk_mode_reglement,c.fk_shipping_method';
$sql .= ' ,c.fk_input_reason';
$sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
$sql .= ' u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender,';
$sql .= ' c.fk_cond_reglement,c.fk_mode_reglement,c.fk_shipping_method,';
$sql .= ' c.fk_input_reason';
if ($search_categ_cus) {
$sql .= ", cc.fk_categorie, cc.fk_soc";
}
@@ -473,7 +474,7 @@ if ($search_user > 0) {
$sql .= ' WHERE c.fk_soc = s.rowid';
$sql .= ' AND c.entity IN ('.getEntity('commande').')';
if ($search_product_category > 0) {
$sql .= " AND cp.fk_categorie = ".$search_product_category;
$sql .= " AND cp.fk_categorie = ".((int) $search_product_category);
}
if ($socid > 0) {
$sql .= ' AND s.rowid = '.((int) $socid);
@@ -494,7 +495,7 @@ if ($search_billed != '' && $search_billed >= 0) {
$sql .= ' AND c.facture = '.((int) $search_billed);
}
if ($search_status <> '') {
if ($search_status < 4 && $search_status > -3) {
if ($search_status < 4 && $search_status > -4) {
if ($search_status == 1 && empty($conf->expedition->enabled)) {
$sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated'
} else {
@@ -513,6 +514,11 @@ if ($search_status <> '') {
//$sql.= ' AND c.facture = 0'; // invoice not created
$sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed
}
if ($search_status == -4) { // "validate and in progress"
$sql .= ' AND (c.fk_statut IN (1,2))'; // validated, in process
}
}
if ($search_datecloture_start) {
@@ -588,7 +594,7 @@ if ($search_multicurrency_montant_ttc != '') {
$sql .= natural_search('c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
}
if ($search_login) {
$sql .= natural_search("u.login", $search_login);
$sql .= natural_search(array("u.login", "u.firstname", "u.lastname"), $search_login);
}
if ($search_project_ref != '') {
$sql .= natural_search("p.ref", $search_project_ref);
@@ -675,6 +681,9 @@ if ($resql) {
if ($search_status == -3) {
$title .= ' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled) ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill');
}
if ($search_status == -4) {
$title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort");
}
$num = $db->num_rows($resql);
@@ -1239,6 +1248,7 @@ if ($resql) {
Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"),
Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"),
-3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"),
-4=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"),
Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort")
);
print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1);
@@ -1379,7 +1389,7 @@ if ($resql) {
$generic_product = new Product($db);
$userstatic = new User($db);
$i = 0;
$totalarray = array();
$totalarray = array('nbfield' => 0, 'val' => array(), 'pos' => array());
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
@@ -1390,10 +1400,16 @@ if ($resql) {
$nbprod = 0;
$companystatic->id = $obj->socid;
$companystatic->code_client = $obj->code_client;
$companystatic->name = $obj->name;
$companystatic->name_alias = $obj->alias;
$companystatic->client = $obj->client;
$companystatic->code_client = $obj->code_client;
$companystatic->email = $obj->email;
$companystatic->phone = $obj->phone;
$companystatic->address = $obj->address;
$companystatic->zip = $obj->zip;
$companystatic->town = $obj->town;
$companystatic->country_code = $obj->country_code;
if (!isset($getNomUrl_cache[$obj->socid])) {
$getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer');
}
@@ -1490,7 +1506,7 @@ if ($resql) {
$totalarray['nbfield']++;
}
}
// Town
// Alias name
if (!empty($arrayfields['s.name_alias']['checked'])) {
print '<td class="nocellnopadd">';
print $obj->alias;
@@ -1565,7 +1581,7 @@ if ($resql) {
$totalarray['nbfield']++;
}
}
//Shipping Method
// Shipping Method
if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
print '<td>';
$form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1);
@@ -1610,7 +1626,11 @@ if ($resql) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht';
}
$totalarray['val']['c.total_ht'] += $obj->total_ht;
if (isset($totalarray['val']['c.total_ht'])) {
$totalarray['val']['c.total_ht'] += $obj->total_ht;
} else {
$totalarray['val']['c.total_ht'] = $obj->total_ht;
}
}
// Amount VAT
if (!empty($arrayfields['c.total_vat']['checked'])) {
@@ -1676,12 +1696,23 @@ if ($resql) {
$userstatic->id = $obj->fk_user_author;
$userstatic->login = $obj->login;
$userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname;
$userstatic->email = $obj->email;
$userstatic->statut = $obj->statut;
$userstatic->entity = $obj->entity;
$userstatic->photo = $obj->photo;
$userstatic->office_phone = $obj->office_phone;
$userstatic->office_fax = $obj->office_fax;
$userstatic->user_mobile = $obj->user_mobile;
$userstatic->job = $obj->job;
$userstatic->gender = $obj->gender;
// Author
if (!empty($arrayfields['u.login']['checked'])) {
print '<td align="center">';
if ($userstatic->id > 0) {
print $userstatic->getLoginUrl(1);
print '<td class="tdoverflowmax200">';
if ($userstatic->id) {
print $userstatic->getNomUrl(-1);
} else {
print '&nbsp;';
}

View File

@@ -45,6 +45,10 @@ $socid = 0;
if ($user->socid) {
$socid = $user->socid;
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('ordernote'));
$result = restrictedArea($user, 'commande', $id, '');
@@ -61,7 +65,13 @@ $permissionnote = $user->rights->commande->creer; // Used by the include of acti
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
}
/*

View File

@@ -60,8 +60,7 @@ if ($user->socid > 0) {
$nowyear = strftime("%Y", dol_now());
$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear;
//$startyear=$year-2;
$startyear = $year - 1;
$startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
$endyear = $year;
// Load translation files required by the page
@@ -295,7 +294,8 @@ if ($mode == 'customer') {
if ($mode == 'supplier') {
$filter = 's.fournisseur = 1';
}
print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, '', 'style="width: 95%"');
print img_picto('', 'company', 'class="pictofixedwidth"');
print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, 'widthcentpercentminusx maxwidth300');
print '</td></tr>';
// ThirdParty Type
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>';
@@ -315,13 +315,15 @@ if ($mode == 'supplier') {
$cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier"));
}
print '<tr><td>'.$cat_label.'</td><td>';
print $formother->select_categories($cat_type, $categ_id, 'categ_id', true);
print img_picto('', 'category', 'class="pictofixedwidth"');
print $formother->select_categories($cat_type, $categ_id, 'categ_id', 0, 1, 'widthcentpercentminusx maxwidth300');
print '</td></tr>';
// User
print '<tr><td class="left">'.$langs->trans("CreatedBy").'</td><td class="left">';
print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print '<tr><td>'.$langs->trans("CreatedBy").'</td><td>';
print img_picto('', 'user', 'class="pictofixedwidth"');
print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
// Status
print '<tr><td class="left">'.$langs->trans("Status").'</td><td class="left">';
print '<tr><td>'.$langs->trans("Status").'</td><td>';
if ($mode == 'customer') {
$liststatus = array(
Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraft"),
@@ -347,7 +349,7 @@ if (!in_array($nowyear, $arrayyears)) {
arsort($arrayyears);
print $form->selectarray('year', $arrayyears, $year, 0);
print '</td></tr>';
print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>';
print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans("Refresh").'"></td></tr>';
print '</table>';
print '</form>';
print '<br><br>';
@@ -386,11 +388,11 @@ foreach ($data as $val) {
print '<tr class="oddeven" height="24">';
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$year.'</a></td>';
print '<td class="right">'.$val['nb'].'</td>';
print '<td class="right" style="'.(($val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['nb_diff']).'</td>';
print '<td class="right opacitylow" style="'.(($val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['nb_diff']).'%</td>';
print '<td class="right">'.price(price2num($val['total'], 'MT'), 1).'</td>';
print '<td class="right" style="'.(($val['total_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['total_diff']).'</td>';
print '<td class="right opacitylow" style="'.(($val['total_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['total_diff']).'%</td>';
print '<td class="right">'.price(price2num($val['avg'], 'MT'), 1).'</td>';
print '<td class="right" style="'.(($val['avg_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['avg_diff']).'</td>';
print '<td class="right opacitylow" style="'.(($val['avg_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['avg_diff']).'%</td>';
print '</tr>';
$oldyear = $year;
}

View File

@@ -47,7 +47,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
}
echo '<tr class="'.$trclass.'" >';
echo '<td class="linkedcol-element" >'.$langs->trans("CustomerOrder");
if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
if (!empty($showImportButton) && !empty($conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)) {
print '<a class="objectlinked_importbtn" href="'.$objectlink->getNomUrl(0, '', 0, 1).'&amp;action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a';
}
echo '</td>';