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

Conflicts:
	htdocs/contrat/list.php
	htdocs/expedition/class/expedition.class.php
	htdocs/fourn/card.php
	htdocs/product/stock/class/productlot.class.php
	htdocs/theme/eldy/style.css.php
This commit is contained in:
Laurent Destailleur 2016-09-12 02:05:38 +02:00
commit 9ff1809f85
36 changed files with 424 additions and 555 deletions

View File

@ -10,6 +10,7 @@
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -362,6 +363,7 @@ if ($resql)
$param='&socid='.$socid.'&viewstatut='.$viewstatut; $param='&socid='.$socid.'&viewstatut='.$viewstatut;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($sall) $param.='&sall='.$sall;
if ($month) $param.='&month='.$month; if ($month) $param.='&month='.$month;
if ($year) $param.='&year='.$year; if ($year) $param.='&year='.$year;
if ($search_ref) $param.='&search_ref=' .$search_ref; if ($search_ref) $param.='&search_ref=' .$search_ref;

View File

@ -384,6 +384,7 @@ if ($resql)
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($sall) $param.='&sall='.$sall;
if ($socid > 0) $param.='&socid='.$socid; if ($socid > 0) $param.='&socid='.$socid;
if ($viewstatut != '') $param.='&viewstatut='.$viewstatut; if ($viewstatut != '') $param.='&viewstatut='.$viewstatut;
if ($orderday) $param.='&orderday='.$orderday; if ($orderday) $param.='&orderday='.$orderday;

View File

@ -66,7 +66,6 @@ if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
if (! empty($conf->margin->enabled)) if (! empty($conf->margin->enabled))
$langs->load('margins'); $langs->load('margins');
$sall = trim(GETPOST('sall'));
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
$id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
@ -3078,10 +3077,10 @@ else if ($id > 0 || ! empty($ref))
if ($action == 'editinvoicedate') { if ($action == 'editinvoicedate') {
$form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date, 'invoicedate'); $form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date, 'invoicedate');
} else { } else {
print dol_print_date($object->date, 'daytext'); print dol_print_date($object->date, 'day');
} }
} else { } else {
print dol_print_date($object->date, 'daytext'); print dol_print_date($object->date, 'day');
} }
print '</td>'; print '</td>';
@ -3419,7 +3418,7 @@ else if ($id > 0 || ! empty($ref))
if ($action == 'editdate_pointoftax') { if ($action == 'editdate_pointoftax') {
$form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date_pointoftax, 'date_pointoftax'); $form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date_pointoftax, 'date_pointoftax');
} else { } else {
print dol_print_date($object->date_pointoftax, 'daytext'); print dol_print_date($object->date_pointoftax, 'day');
} }
print '</td></tr>'; print '</td></tr>';
} }
@ -3459,7 +3458,7 @@ else if ($id > 0 || ! empty($ref))
if ($action == 'editpaymentterm') { if ($action == 'editpaymentterm') {
$form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date_lim_reglement, 'paymentterm'); $form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date_lim_reglement, 'paymentterm');
} else { } else {
print dol_print_date($object->date_lim_reglement, 'daytext'); print dol_print_date($object->date_lim_reglement, 'day');
if ($object->hasDelay()) { if ($object->hasDelay()) {
print img_warning($langs->trans('Late')); print img_warning($langs->trans('Late'));
} }

View File

@ -43,6 +43,7 @@ class FactureRec extends CommonInvoice
public $table_element_line='facturedet_rec'; public $table_element_line='facturedet_rec';
public $fk_element='fk_facture'; public $fk_element='fk_facture';
var $entity;
var $number; var $number;
var $date; var $date;
var $amount; var $amount;
@ -241,7 +242,7 @@ class FactureRec extends CommonInvoice
*/ */
function fetch($rowid, $ref='', $ref_ext='', $ref_int='') function fetch($rowid, $ref='', $ref_ext='', $ref_int='')
{ {
$sql = 'SELECT f.rowid, f.titre, f.fk_soc, f.amount, f.tva, f.total, f.total_ttc, f.remise_percent, f.remise_absolue, f.remise'; $sql = 'SELECT f.rowid, f.entity, f.titre, f.fk_soc, f.amount, f.tva, f.total, f.total_ttc, f.remise_percent, f.remise_absolue, f.remise';
$sql.= ', f.date_lim_reglement as dlr'; $sql.= ', f.date_lim_reglement as dlr';
$sql.= ', f.note_private, f.note_public, f.fk_user_author'; $sql.= ', f.note_private, f.note_public, f.fk_user_author';
$sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet'; $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet';
@ -269,6 +270,7 @@ class FactureRec extends CommonInvoice
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->entity = $obj->entity;
$this->titre = $obj->titre; $this->titre = $obj->titre;
$this->ref = $obj->titre; $this->ref = $obj->titre;
$this->ref_client = $obj->ref_client; $this->ref_client = $obj->ref_client;
@ -519,6 +521,7 @@ class FactureRec extends CommonInvoice
{ {
// Clean parameters // Clean parameters
$remise_percent=price2num($remise_percent); $remise_percent=price2num($remise_percent);
if (empty($remise_percent)) $remise_percent=0;
$qty=price2num($qty); $qty=price2num($qty);
if (! $qty) $qty=1; if (! $qty) $qty=1;
if (! $info_bits) $info_bits=0; if (! $info_bits) $info_bits=0;
@ -579,12 +582,12 @@ class FactureRec extends CommonInvoice
$sql.= ", ".price2num($txtva); $sql.= ", ".price2num($txtva);
$sql.= ", ".(! empty($fk_product)?"'".$fk_product."'":"null"); $sql.= ", ".(! empty($fk_product)?"'".$fk_product."'":"null");
$sql.= ", ".$product_type; $sql.= ", ".$product_type;
$sql.= ", '".price2num($remise_percent)."'"; $sql.= ", ".price2num($remise_percent);
$sql.= ", '".price2num($pu_ht)."'"; $sql.= ", ".price2num($pu_ht);
$sql.= ", null"; $sql.= ", null";
$sql.= ", '".price2num($total_ht)."'"; $sql.= ", ".price2num($total_ht);
$sql.= ", '".price2num($total_tva)."'"; $sql.= ", ".price2num($total_tva);
$sql.= ", '".price2num($total_ttc)."'"; $sql.= ", ".price2num($total_ttc);
$sql.= ", ".$rang; $sql.= ", ".$rang;
$sql.= ", ".$special_code; $sql.= ", ".$special_code;
$sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null").")"; $sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null").")";
@ -721,14 +724,16 @@ class FactureRec extends CommonInvoice
} }
/** /**
* Create all recurrents invoices. * Create all recurrents invoices (for all entities if multicompany is used).
* A result may also be provided into this->output * A result may also be provided into this->output.
*
* WARNING: This method change context $conf->entity to be in correct context for each recurring invoice found.
* *
* @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK)
*/ */
function createRecurringInvoices() function createRecurringInvoices()
{ {
global $langs, $db, $user; global $conf, $langs, $db, $user;
$langs->load("bills"); $langs->load("bills");
@ -743,6 +748,7 @@ class FactureRec extends CommonInvoice
$sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency $sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency
$sql.= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')"; $sql.= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')";
$sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; $sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)';
$sql.= $db->order('entity', 'ASC');
//print $sql;exit; //print $sql;exit;
$resql = $db->query($sql); $resql = $db->query($sql);
@ -754,7 +760,9 @@ class FactureRec extends CommonInvoice
if ($num) $this->output.=$langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; if ($num) $this->output.=$langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n";
else $this->output.=$langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); else $this->output.=$langs->trans("NoQualifiedRecurringInvoiceTemplateFound");
while ($i < $num) $saventity = $conf->entity;
while ($i < $num) // Loop on each template invoice
{ {
$line = $db->fetch_object($resql); $line = $db->fetch_object($resql);
@ -763,7 +771,10 @@ class FactureRec extends CommonInvoice
$facturerec = new FactureRec($db); $facturerec = new FactureRec($db);
$facturerec->fetch($line->rowid); $facturerec->fetch($line->rowid);
dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); // Set entity context
$conf->entity = $facturerec->entity;
dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity);
$error=0; $error=0;
@ -774,7 +785,7 @@ class FactureRec extends CommonInvoice
$facture->date = $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->date = $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later.
$facture->socid = $facturerec->socid; $facture->socid = $facturerec->socid;
$invoiceidgenerated = $facture->create($user); // This will also update fields of recurring invoice $invoiceidgenerated = $facture->create($user);
if ($invoiceidgenerated <= 0) if ($invoiceidgenerated <= 0)
{ {
$this->errors = $facture->errors; $this->errors = $facture->errors;
@ -794,18 +805,20 @@ class FactureRec extends CommonInvoice
if (! $error && $invoiceidgenerated >= 0) if (! $error && $invoiceidgenerated >= 0)
{ {
$db->commit(); $db->commit("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref);
dol_syslog("createRecurringInvoices Process invoice template ".$facturerec->ref." is finished with a success generation"); dol_syslog("createRecurringInvoices Process invoice template ".$facturerec->ref." is finished with a success generation");
$nb_create++; $nb_create++;
$this->output.=$langs->trans("InvoiceGeneratedFromTemplate", $facture->ref, $facturerec->ref)."\n"; $this->output.=$langs->trans("InvoiceGeneratedFromTemplate", $facture->ref, $facturerec->ref)."\n";
} }
else else
{ {
$db->rollback(); $db->rollback("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref);
} }
$i++; $i++;
} }
$conf->entity = $saventity; // Restore entity context
} }
else dol_print_error($db); else dol_print_error($db);
@ -1060,7 +1073,7 @@ class FactureRec extends CommonInvoice
return -1; return -1;
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= ' SET date_when = "'.$this->db->idate($date).'"'; $sql.= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null");
if ($increment_nb_gen_done>0) $sql.= ', nb_gen_done = nb_gen_done + 1'; if ($increment_nb_gen_done>0) $sql.= ', nb_gen_done = nb_gen_done + 1';
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;

View File

@ -241,6 +241,7 @@ class Facture extends CommonInvoice
if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; if (! $this->cond_reglement_id) $this->cond_reglement_id = 0;
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
$this->brouillon = 1; $this->brouillon = 1;
if (empty($this->entity)) $this->entity = $conf->entity;
// Multicurrency (test on $this->multicurrency_tx because we sould take the default rate only if not using origin rate) // Multicurrency (test on $this->multicurrency_tx because we sould take the default rate only if not using origin rate)
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code);
@ -281,7 +282,8 @@ class Facture extends CommonInvoice
$_facrec = new FactureRec($this->db); $_facrec = new FactureRec($this->db);
$result=$_facrec->fetch($this->fac_rec); $result=$_facrec->fetch($this->fac_rec);
$this->socid = $_facrec->socid; $this->socid = $_facrec->socid; // Invoice created on same thirdparty than template
$this->entity = $_facrec->entity; // Invoice created in same entity than template
// Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI
$this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project; $this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project;
@ -311,13 +313,15 @@ class Facture extends CommonInvoice
$forceduedate = $this->calculate_date_lim_reglement(); $forceduedate = $this->calculate_date_lim_reglement();
// For recurrn invoices, update date and number of last generation of recurring template invoice, before inserting new invoice // For recurring invoices, update date and number of last generation of recurring template invoice, before inserting new invoice
if ($_facrec->frequency > 0) if ($_facrec->frequency > 0)
{ {
dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when");
if (empty($_facrec->date_when)) $_facrec->date_when = $now;
$next_date = $_facrec->getNextDate(); // Calculate next date $next_date = $_facrec->getNextDate(); // Calculate next date
$_facrec->setValueFrom('date_last_gen', $now, '', null, 'date'); $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date');
//$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1.
$_facrec->setNextDate($next_date,1); $result = $_facrec->setNextDate($next_date,1);
} }
} }
@ -352,7 +356,7 @@ class Facture extends CommonInvoice
$sql.= ")"; $sql.= ")";
$sql.= " VALUES ("; $sql.= " VALUES (";
$sql.= "'(PROV)'"; $sql.= "'(PROV)'";
$sql.= ", ".$conf->entity; $sql.= ", ".$this->entity;
$sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null"); $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null");
$sql.= ", '".$this->db->escape($this->type)."'"; $sql.= ", '".$this->db->escape($this->type)."'";
$sql.= ", '".$socid."'"; $sql.= ", '".$socid."'";

View File

@ -410,6 +410,7 @@ if ($resql)
$param='&socid='.$socid; $param='&socid='.$socid;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($sall) $param.='&sall='.$sall;
if ($day) $param.='&day='.urlencode($day); if ($day) $param.='&day='.urlencode($day);
if ($month) $param.='&month='.urlencode($month); if ($month) $param.='&month='.urlencode($month);
if ($year) $param.='&year=' .urlencode($year); if ($year) $param.='&year=' .urlencode($year);

View File

@ -380,6 +380,7 @@ if ($result)
if (!empty($search_categ)) $param.='&search_categ='.urlencode($search_categ); if (!empty($search_categ)) $param.='&search_categ='.urlencode($search_categ);
if (!empty($search_categ_thirdparty)) $param.='&search_categ_thirdparty='.urlencode($search_categ_thirdparty); if (!empty($search_categ_thirdparty)) $param.='&search_categ_thirdparty='.urlencode($search_categ_thirdparty);
if (!empty($search_categ_supplier)) $param.='&search_categ_supplier='.urlencode($search_categ_supplier); if (!empty($search_categ_supplier)) $param.='&search_categ_supplier='.urlencode($search_categ_supplier);
if ($sall != '') $param.='&amp;sall='.urlencode($sall);
if ($search_lastname != '') $param.='&amp;search_lastname='.urlencode($search_lastname); if ($search_lastname != '') $param.='&amp;search_lastname='.urlencode($search_lastname);
if ($search_firstname != '') $param.='&amp;search_firstname='.urlencode($search_firstname); if ($search_firstname != '') $param.='&amp;search_firstname='.urlencode($search_firstname);
if ($search_societe != '') $param.='&amp;search_societe='.urlencode($search_societe); if ($search_societe != '') $param.='&amp;search_societe='.urlencode($search_societe);

View File

@ -6,6 +6,7 @@
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop> * Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -307,12 +308,13 @@ if ($resql)
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_contract) $param.='&search_contract='.$search_contract; if ($sall != '') $param.='&sall='.$sall;
if ($search_name) $param.='&search_name='.$search_name; if ($search_contract != '') $param.='&search_contract='.$search_contract;
if ($search_ref_supplier) $param.='&search_ref_supplier='.$search_ref_supplier; if ($search_name != '') $param.='&search_name='.$search_name;
if ($search_sale) $param.='&search_sale=' .$search_sale; if ($search_ref_supplier != '') $param.='&search_ref_supplier='.$search_ref_supplier;
if ($show_files) $param.='&show_files=' .$show_files; if ($search_sale != '') $param.='&search_sale=' .$search_sale;
if ($optioncss != '') $param.='&optioncss='.$optioncss; if ($show_files) $param.='&show_files=' .$show_files;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
// Add $param from extra fields // Add $param from extra fields
foreach ($search_array_options as $key => $val) foreach ($search_array_options as $key => $val)
{ {
@ -330,9 +332,6 @@ if ($resql)
if ($massaction == 'presend') $arrayofmassactions=array(); if ($massaction == 'presend') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">'; print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';

View File

@ -2067,9 +2067,10 @@ class Form
* @param string $filtre For a SQL filter * @param string $filtre For a SQL filter
* @param array $ajaxoptions Options for ajax_autocompleter * @param array $ajaxoptions Options for ajax_autocompleter
* @param int $hidelabel Hide label (0=no, 1=yes) * @param int $hidelabel Hide label (0=no, 1=yes)
* @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices
* @return void * @return void
*/ */
function select_produits_fournisseurs($socid, $selected='', $htmlname='productid', $filtertype='', $filtre='', $ajaxoptions=array(), $hidelabel=0) function select_produits_fournisseurs($socid, $selected='', $htmlname='productid', $filtertype='', $filtre='', $ajaxoptions=array(), $hidelabel=0, $alsoproductwithnosupplierprice=0)
{ {
global $langs,$conf; global $langs,$conf;
global $price_level, $status, $finished; global $price_level, $status, $finished;
@ -2091,7 +2092,7 @@ class Form
print '<input type="hidden" id="idprod" name="idprod" value="0" />'; print '<input type="hidden" id="idprod" name="idprod" value="0" />';
} }
// mode=2 means suppliers products // mode=2 means suppliers products
$urloption=($socid > 0?'socid='.$socid.'&':'').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished; $urloption=($socid > 0?'socid='.$socid.'&':'').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice;
print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
print ($hidelabel?'':$langs->trans("RefOrLabel").' : ').'<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'">'; print ($hidelabel?'':$langs->trans("RefOrLabel").' : ').'<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'">';
} }
@ -2102,7 +2103,7 @@ class Form
print '<input type="hidden" id="idprod" name="idprod" value="0" />'; print '<input type="hidden" id="idprod" name="idprod" value="0" />';
print '<script type="text/javascript">$("#'.$htmlname.'").change(function() { $("#idprod").val($(this).val());});</script>'; print '<script type="text/javascript">$("#'.$htmlname.'").change(function() { $("#idprod").val($(this).val());});</script>';
} }
print $this->select_produits_fournisseurs_list($socid,$selected,$htmlname,$filtertype,$filtre,'',-1,0); print $this->select_produits_fournisseurs_list($socid,$selected,$htmlname,$filtertype,$filtre,'',-1,0,0,$alsoproductwithnosupplierprice);
} }
} }
@ -2118,9 +2119,10 @@ class Form
* @param int $statut -1=Return all products, 0=Products not on sell, 1=Products on sell (not used here, a filter on tobuy is already hard coded in request) * @param int $statut -1=Return all products, 0=Products not on sell, 1=Products on sell (not used here, a filter on tobuy is already hard coded in request)
* @param int $outputmode 0=HTML select string, 1=Array * @param int $outputmode 0=HTML select string, 1=Array
* @param int $limit Limit of line number * @param int $limit Limit of line number
* @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices
* @return array Array of keys for json * @return array Array of keys for json
*/ */
function select_produits_fournisseurs_list($socid,$selected='',$htmlname='productid',$filtertype='',$filtre='',$filterkey='',$statut=-1,$outputmode=0,$limit=100) function select_produits_fournisseurs_list($socid,$selected='',$htmlname='productid',$filtertype='',$filtre='',$filterkey='',$statut=-1,$outputmode=0,$limit=100,$alsoproductwithnosupplierprice=0)
{ {
global $langs,$conf,$db; global $langs,$conf,$db;
@ -2174,7 +2176,7 @@ class Form
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
//$out.='<select class="flat" id="select'.$htmlname.'" name="'.$htmlname.'">'; // remove select to have id same with combo and ajax //$out.='<select class="flat" id="select'.$htmlname.'" name="'.$htmlname.'">'; // remove select to have id same with combo and ajax
$out.='<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">'; $out.='<select class="flat maxwidthonsmartphone" id="'.$htmlname.'" name="'.$htmlname.'">';
if (! $selected) $out.='<option value="0" selected>&nbsp;</option>'; if (! $selected) $out.='<option value="0" selected>&nbsp;</option>';
else $out.='<option value="0">&nbsp;</option>'; else $out.='<option value="0">&nbsp;</option>';
@ -2183,7 +2185,9 @@ class Form
{ {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$outkey=$objp->idprodfournprice; $outkey=$objp->idprodfournprice; // id in table of price
if (! $outkey && $alsoproductwithnosupplierprice) $outkey='idprod_'.$objp->rowid; // id of product
$outref=$objp->ref; $outref=$objp->ref;
$outval=''; $outval='';
$outqty=1; $outqty=1;
@ -2192,9 +2196,9 @@ class Form
$outdurationvalue=$outtype == Product::TYPE_SERVICE?substr($objp->duration,0,dol_strlen($objp->duration)-1):''; $outdurationvalue=$outtype == Product::TYPE_SERVICE?substr($objp->duration,0,dol_strlen($objp->duration)-1):'';
$outdurationunit=$outtype == Product::TYPE_SERVICE?substr($objp->duration,-1):''; $outdurationunit=$outtype == Product::TYPE_SERVICE?substr($objp->duration,-1):'';
$opt = '<option value="'.$objp->idprodfournprice.'"'; $opt = '<option value="'.$outkey.'"';
if ($selected && $selected == $objp->idprodfournprice) $opt.= ' selected'; if ($selected && $selected == $objp->idprodfournprice) $opt.= ' selected';
if (empty($objp->idprodfournprice)) $opt.=' disabled'; if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt.=' disabled';
$opt.= '>'; $opt.= '>';
$objRef = $objp->ref; $objRef = $objp->ref;
@ -2273,18 +2277,25 @@ class Form
} }
if ($objp->supplier_reputation) if ($objp->supplier_reputation)
{ {
//TODO dictionnary //TODO dictionnary
$reputations=array(''=>$langs->trans('Standard'),'FAVORITE'=>$langs->trans('Favorite'),'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); $reputations=array(''=>$langs->trans('Standard'),'FAVORITE'=>$langs->trans('Favorite'),'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier'));
$opt .= " - ".$reputations[$objp->supplier_reputation]; $opt .= " - ".$reputations[$objp->supplier_reputation];
$outval.=" - ".$reputations[$objp->supplier_reputation]; $outval.=" - ".$reputations[$objp->supplier_reputation];
} }
} }
else else
{ {
$opt.= $langs->trans("NoPriceDefinedForThisSupplier"); if (empty($alsoproductwithnosupplierprice)) // No supplier price defined for couple product/supplier
$outval.=$langs->transnoentities("NoPriceDefinedForThisSupplier"); {
$opt.= $langs->trans("NoPriceDefinedForThisSupplier");
$outval.=$langs->transnoentities("NoPriceDefinedForThisSupplier");
}
else // No supplier price defined for product, even on other suppliers
{
$opt.= $langs->trans("NoPriceDefinedForThisSupplier");
$outval.=$langs->transnoentities("NoPriceDefinedForThisSupplier");
}
} }
$opt .= "</option>\n"; $opt .= "</option>\n";

View File

@ -838,7 +838,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
if (! empty($conf->commande->enabled)) if (! empty($conf->commande->enabled))
{ {
$langs->load("orders"); $langs->load("orders");
if (! empty($conf->facture->enabled)) $newmenu->add("/commande/list.php?leftmenu=orders&amp;viewstatut=-3", $langs->trans("MenuOrdersToBill2"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders'); if (! empty($conf->facture->enabled)) $newmenu->add("/commande/list.php?leftmenu=orders&amp;viewstatut=-3&amp;billed=0", $langs->trans("MenuOrdersToBill2"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders');
// if (empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->rights->commande->lire); // if (empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->rights->commande->lire);
} }

View File

@ -37,7 +37,7 @@ if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($ob
$usemargins=1; $usemargins=1;
} }
global $forceall, $senderissupplier, $inputalsopricewithtax; global $dateSelector, $forceall, $senderissupplier, $inputalsopricewithtax;
if (empty($dateSelector)) $dateSelector=0; if (empty($dateSelector)) $dateSelector=0;
if (empty($forceall)) $forceall=0; if (empty($forceall)) $forceall=0;
if (empty($senderissupplier)) $senderissupplier=0; if (empty($senderissupplier)) $senderissupplier=0;
@ -187,12 +187,21 @@ else {
} }
else else
{ {
$ajaxoptions=array( if ($senderissupplier != 2)
'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key {
'option_disabled' => 'addPredefinedProductButton', // html id to disable once select is done $ajaxoptions=array(
'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error' 'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key
); 'option_disabled' => 'addPredefinedProductButton', // html id to disable once select is done
$form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1); 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error'
);
$alsoproductwithnosupplierprice=0;
}
else
{
$ajaxoptions = array();
$alsoproductwithnosupplierprice=1;
}
$form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice);
} }
echo '</span>'; echo '</span>';
} }
@ -230,7 +239,7 @@ else {
</td> </td>
<?php if ($object->element == 'supplier_proposal') { ?> <?php if ($object->element == 'supplier_proposal') { ?>
<td class="nobottom linecolresupplier" align="right"><input id="fourn_ref" name="fourn_ref" class="flat" value="" size="12"></td> <td class="nobottom linecolresupplier" align="right"><input id="fourn_ref" name="fourn_ref" class="flat" size="10" value=""></td>
<?php } ?> <?php } ?>
<td class="nobottom linecolvat" align="right"><?php <td class="nobottom linecolvat" align="right"><?php

View File

@ -368,6 +368,7 @@ class Cronjob extends CommonObject
$sql = "SELECT"; $sql = "SELECT";
$sql.= " t.rowid,"; $sql.= " t.rowid,";
$sql.= " t.entity,";
$sql.= " t.tms,"; $sql.= " t.tms,";
$sql.= " t.datec,"; $sql.= " t.datec,";
$sql.= " t.jobtype,"; $sql.= " t.jobtype,";
@ -439,6 +440,7 @@ class Cronjob extends CommonObject
$line->id = $obj->rowid; $line->id = $obj->rowid;
$line->ref = $obj->rowid; $line->ref = $obj->rowid;
$line->entity = $obj->entity;
$line->tms = $this->db->jdate($obj->tms); $line->tms = $this->db->jdate($obj->tms);
$line->datec = $this->db->jdate($obj->datec); $line->datec = $this->db->jdate($obj->datec);
$line->label = $obj->label; $line->label = $obj->label;
@ -893,6 +895,7 @@ class Cronjob extends CommonObject
// Update last run date start (to track running jobs) // Update last run date start (to track running jobs)
$this->datelastrun=$now; $this->datelastrun=$now;
$this->datelastresult=null;
$this->lastoutput=''; $this->lastoutput='';
$this->lastresult=''; $this->lastresult='';
$this->nbrun=$this->nbrun + 1; $this->nbrun=$this->nbrun + 1;
@ -1093,6 +1096,8 @@ class Cronjob extends CommonObject
dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true)." lastoutput=".$this->lastoutput." lastresult=".$this->lastresult, LOG_DEBUG); dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true)." lastoutput=".$this->lastoutput." lastresult=".$this->lastresult, LOG_DEBUG);
} }
dol_syslog(get_class($this)."::run_jobs now we update job to track it is finished (with success or error)");
$this->datelastresult=dol_now(); $this->datelastresult=dol_now();
$result = $this->update($user); // This include begin/commit $result = $this->update($user); // This include begin/commit
if ($result < 0) if ($result < 0)

View File

@ -364,13 +364,14 @@ class Expedition extends CommonObject
* @param int $entrepot_id Id of warehouse * @param int $entrepot_id Id of warehouse
* @param int $origin_line_id Id of source line * @param int $origin_line_id Id of source line
* @param int $qty Quantity * @param int $qty Quantity
* @param array $array_options extrafields array * @param array $array_options extrafields array
* @return int <0 if KO, >0 if OK * @return int <0 if KO, line_id if OK
*/ */
function create_line($entrepot_id, $origin_line_id, $qty,$array_options=0) function create_line($entrepot_id, $origin_line_id, $qty,$array_options=0)
{ {
global $conf; global $conf;
$error = 0; $error = 0;
$line_id = 0;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (";
$sql.= "fk_expedition"; $sql.= "fk_expedition";
@ -385,12 +386,17 @@ class Expedition extends CommonObject
$sql.= ")"; $sql.= ")";
dol_syslog(get_class($this)."::create_line", LOG_DEBUG); dol_syslog(get_class($this)."::create_line", LOG_DEBUG);
if (! $this->db->query($sql)) $resql = $this->db->query($sql);
if ($resql)
{
$line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet");
}
else
{ {
$error++; $error++;
} }
if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used
{ {
$expeditionline = new ExpeditionLigne($this->db); $expeditionline = new ExpeditionLigne($this->db);
$expeditionline->array_options=$array_options; $expeditionline->array_options=$array_options;
@ -403,7 +409,7 @@ class Expedition extends CommonObject
} }
} }
if (! $error) return 1; if (! $error) return $line_id;
else return -1; else return -1;
} }
@ -432,14 +438,13 @@ class Expedition extends CommonObject
// create shipment lines // create shipment lines
foreach ($stockLocationQty as $stockLocation => $qty) foreach ($stockLocationQty as $stockLocation => $qty)
{ {
if ($this->create_line($stockLocation,$line_ext->origin_line_id,$qty,$array_options) < 0) if (($line_id = $this->create_line($stockLocation,$line_ext->origin_line_id,$qty,$array_options)) < 0)
{ {
$error++; $error++;
} }
else else
{ {
// create shipment batch lines for stockLocation // create shipment batch lines for stockLocation
$line_id= $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet");
foreach ($tab as $detbatch) foreach ($tab as $detbatch)
{ {
if ($detbatch->entrepot_id == $stockLocation){ if ($detbatch->entrepot_id == $stockLocation){

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -258,6 +259,7 @@ if ($resql)
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($sall) $param.= "&amp;sall=".$sall;
if ($search_ref_exp) $param.= "&amp;search_ref_exp=".$search_ref_exp; if ($search_ref_exp) $param.= "&amp;search_ref_exp=".$search_ref_exp;
if ($search_ref_liv) $param.= "&amp;search_ref_liv=".$search_ref_liv; if ($search_ref_liv) $param.= "&amp;search_ref_liv=".$search_ref_liv;
if ($search_company) $param.= "&amp;search_company=".$search_company; if ($search_company) $param.= "&amp;search_company=".$search_company;

View File

@ -293,6 +293,7 @@ if ($resql)
$param=""; $param="";
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($sall) $param.="&sall=".$sall;
if ($search_ref) $param.="&search_ref=".$search_ref; if ($search_ref) $param.="&search_ref=".$search_ref;
if ($search_user) $param.="&search_user=".$search_user; if ($search_user) $param.="&search_user=".$search_user;
if ($search_amount_ht) $param.="&search_amount_ht=".$search_amount_ht; if ($search_amount_ht) $param.="&search_amount_ht=".$search_amount_ht;

View File

@ -215,6 +215,7 @@ if ($result)
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($sall) $urlparam.="&sall=".$sall;
if ($socid) $param.="&socid=".$socid; if ($socid) $param.="&socid=".$socid;
if ($search_ref) $param.="&search_ref=".urlencode($search_ref); if ($search_ref) $param.="&search_ref=".urlencode($search_ref);
if ($search_company) $param.="&search_company=".urlencode($search_company); if ($search_company) $param.="&search_company=".urlencode($search_company);
@ -276,7 +277,7 @@ if ($result)
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.fk_statut","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";

View File

@ -298,13 +298,13 @@ if ($object->id > 0)
$langs->load("products"); $langs->load("products");
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("ProductsAndServices").'</td><td align="right">'; print '<td colspan="3">'.$langs->trans("ProductsAndServices").'</td><td align="right">';
print '<a href="'.DOL_URL_ROOT.'/fourn/product/list.php?fourn_id='.$object->id.'">'.$langs->trans("All").' <span class="badge">'.$object->nbOfProductRefs().'</span>'; print '<a href="'.DOL_URL_ROOT.'/fourn/product/list.php?fourn_id='.$object->id.'">'.$langs->trans("All").' <span class="badge">'.$object->nbOfProductRefs().'</span>';
print '</a></td></tr>'; print '</a></td></tr>';
//Query from product/liste.php //Query from product/liste.php
$sql = 'SELECT p.rowid, p.ref, p.label, pfp.tms,'; $sql = 'SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity,';
$sql.= ' p.fk_product_type, p.entity'; $sql.= ' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
$sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp';
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pfp.fk_product"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pfp.fk_product";
$sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')';
@ -313,6 +313,7 @@ if ($object->id > 0)
$sql.= $db->plimit($MAXLIST); $sql.= $db->plimit($MAXLIST);
$query = $db->query($sql); $query = $db->query($sql);
if (! $query) dol_print_error($db);
$return = array(); $return = array();
@ -335,12 +336,24 @@ if ($object->id > 0)
print $productstatic->getNomUrl(1); print $productstatic->getNomUrl(1);
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print $productstatic->ref; print $objp->supplier_ref;
print '</td>'; print '</td>';
print '<td>'; print '<td class="maxwidthonsmartphone">';
print dol_trunc(dol_htmlentities($objp->label), 30); print dol_trunc(dol_htmlentities($objp->label), 30);
print '</td>'; print '</td>';
print '<td align="right" class="nowrap">'.dol_print_date($objp->tms).'</td>'; //print '<td align="right" class="nowrap">'.dol_print_date($objp->tms, 'day').'</td>';
print '<td align="right">';
//print (isset($objp->unitprice) ? price($objp->unitprice) : '');
if (isset($objp->price))
{
print price($objp->price);
if ($objp->quantity > 1)
{
print ' / ';
print $objp->quantity;
}
}
print '</td>';
print '</tr>'; print '</tr>';
} }
} }

View File

@ -1297,7 +1297,7 @@ class CommandeFournisseur extends CommonOrder
* @param float $txtva Taux tva * @param float $txtva Taux tva
* @param float $txlocaltax1 Localtax1 tax * @param float $txlocaltax1 Localtax1 tax
* @param float $txlocaltax2 Localtax2 tax * @param float $txlocaltax2 Localtax2 tax
* @param int $fk_product Id produit * @param int $fk_product Id product
* @param int $fk_prod_fourn_price Id supplier price * @param int $fk_prod_fourn_price Id supplier price
* @param string $fourn_ref Supplier reference * @param string $fourn_ref Supplier reference
* @param float $remise_percent Remise * @param float $remise_percent Remise

View File

@ -272,9 +272,7 @@ if (empty($reshook))
} }
} }
/* // Add a product line
* Add a line into product
*/
if ($action == 'addline' && $user->rights->fournisseur->commande->creer) if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
{ {
$langs->load('errors'); $langs->load('errors');
@ -426,8 +424,8 @@ if (empty($reshook))
$tva_tx = price2num($tva_tx); // When vat is text input field $tva_tx = price2num($tva_tx); // When vat is text input field
// Local Taxes // Local Taxes
$localtax1_tx= get_localtax($tva_tx, 1,$mysoc,$object->thirdparty); $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
$localtax2_tx= get_localtax($tva_tx, 2,$mysoc,$object->thirdparty); $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
if (GETPOST('price_ht')!=='') if (GETPOST('price_ht')!=='')
{ {
@ -2080,184 +2078,6 @@ elseif (! empty($object->id))
$num = count($object->lines); $num = count($object->lines);
/*
$i = 0; $total = 0;
if ($num)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Label').'</td>';
print '<td align="right" width="50">'.$langs->trans('VAT').'</td>';
print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
print '<td align="right" width="50">'.$langs->trans('ReductionShort').'</td>';
print '<td align="right" width="50">'.$langs->trans('TotalHTShort').'</td>';
print '<td width="48" colspan="3">&nbsp;</td>';
print "</tr>\n";
}
$var=true;
while ($i < $num)
{
$line = $object->lines[$i];
$var=!$var;
// Show product and description
$type=(! empty($line->product_type)?$line->product_type:(! empty($line->fk_product_type)?$line->fk_product_type:0));
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
$date_start='';
$date_end='';
if (! empty($line->date_start))
{
$date_start=$line->date_start;
$type=1;
}
if (! empty($line->date_end))
{
$date_end=$line->date_end;
$type=1;
}
// Edit line
if ($action != 'editline' || $_GET['rowid'] != $line->id)
{
print '<tr id="row-'.$line->id.'" '.$bc[$var].'>';
// Show product and description
print '<td>';
if ($line->fk_product > 0)
{
print '<a name="'.$line->id.'"></a>'; // ancre pour retourner sur la ligne
$product_static=new ProductFournisseur($db);
$product_static->fetch($line->fk_product);
$text=$product_static->getNomUrl(1,'supplier');
$text.= ' - '.$product_static->libelle;
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description));
print $form->textwithtooltip($text,$description,3,'','',$i);
// Show range
print_date_range($date_start,$date_end);
// Add description in form
if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) print ($line->description && $line->description!=$product_static->libelle)?'<br>'.dol_htmlentitiesbr($line->description):'';
}
// Description - Editor wysiwyg
if (! $line->fk_product)
{
if ($type==1) $text = img_object($langs->trans('Service'),'service');
else $text = img_object($langs->trans('Product'),'product');
print $text.' '.nl2br($line->description);
// Show range
print_date_range($date_start,$date_end);
}
print '</td>';
print '<td align="right" class="nowrap">'.vatrate($line->tva_tx).'%</td>';
print '<td align="right" class="nowrap">'.price($line->subprice)."</td>\n";
print '<td align="right" class="nowrap">'.$line->qty.'</td>';
if ($line->remise_percent > 0)
{
print '<td align="right" class="nowrap">'.dol_print_reduction($line->remise_percent,$langs)."</td>\n";
}
else
{
print '<td>&nbsp;</td>';
}
print '<td align="right" class="nowrap">'.price($line->total_ht).'</td>';
if (is_object($hookmanager))
{
$parameters=array('line'=>$line,'num'=>$num,'i'=>$i);
$reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$object,$action);
}
if ($object->statut == 0 && $user->rights->fournisseur->commande->creer)
{
print '<td align="center" width="16"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=editline&amp;rowid='.$line->id.'#'.$line->id.'">';
print img_edit();
print '</a></td>';
$actiondelete='delete_product_line';
print '<td align="center" width="16"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action='.$actiondelete.'&amp;lineid='.$line->id.'">';
print img_delete();
print '</a></td>';
}
else
{
print '<td>&nbsp;</td><td>&nbsp;</td>';
}
print "</tr>";
}
// Edit line
if ($action == 'editline' && $user->rights->fournisseur->commande->creer && ($_GET["rowid"] == $line->id))
{
print "\n";
print '<tr '.$bc[$var].'>';
print '<td>';
print '<input type="hidden" name="elrowid" value="'.$_GET['rowid'].'">';
print '<a name="'.$line->id.'"></a>'; // ancre pour retourner sur la ligne
if ((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && $line->fk_product > 0)
{
$product_static=new ProductFournisseur($db);
$product_static->fetch($line->fk_product);
$text=$product_static->getNomUrl(1,'supplier');
$text.= ' - '.$product_static->libelle;
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description));
print $form->textwithtooltip($text,$description,3,'','',$i);
// Show range
print_date_range($date_start,$date_end);
print '<br>';
}
else
{
$forceall=1; // For suppliers, we always show all types
print $form->select_type_of_lines($line->product_type,'type',1,0,$forceall);
if ($forceall || (! empty($conf->product->enabled) && ! empty($conf->service->enabled))
|| (empty($conf->product->enabled) && empty($conf->service->enabled))) print '<br>';
}
if (is_object($hookmanager))
{
$parameters=array('fk_parent_line'=>$line->fk_parent_line, 'line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i);
$reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$object,$action);
}
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
$doleditor=new DolEditor('eldesc',$line->description,'',200,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
$doleditor->Create();
print '<br>';
print $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
print $form->select_date($date_start,'date_start'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,'',1,0,1);
print ' '.$langs->trans('to').' ';
print $form->select_date($date_end,'date_end'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,'',1,0,1);
print '</td>';
print '<td>';
print $form->load_tva('tva_tx',$line->tva_tx,$object->thirdparty,$mysoc);
print '</td>';
print '<td align="right"><input size="5" type="text" name="pu" value="'.price($line->subprice).'"></td>';
print '<td align="right"><input size="2" type="text" name="qty" value="'.$line->qty.'"></td>';
print '<td align="right" class="nowrap"><input size="1" type="text" name="remise_percent" value="'.$line->remise_percent.'"><span class="hideonsmartphone">%</span></td>';
print '<td align="center" colspan="4"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td>';
print '</tr>' . "\n";
}
$i++;
}
*/
// Form to add new line // Form to add new line
if ($object->statut == 0 && $user->rights->fournisseur->commande->creer) if ($object->statut == 0 && $user->rights->fournisseur->commande->creer)
{ {

View File

@ -5,6 +5,7 @@
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -399,6 +400,7 @@ if ($resql)
if ($socid > 0) $param.='&socid='.$socid; if ($socid > 0) $param.='&socid='.$socid;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($sall) $param.="&search_all=".$sall;
if ($orderday) $param.='&orderday='.$orderday; if ($orderday) $param.='&orderday='.$orderday;
if ($ordermonth) $param.='&ordermonth='.$ordermonth; if ($ordermonth) $param.='&ordermonth='.$ordermonth;
if ($orderyear) $param.='&orderyear='.$orderyear; if ($orderyear) $param.='&orderyear='.$orderyear;

View File

@ -23,7 +23,7 @@
/** /**
* \file htdocs/fourn/product/list.php * \file htdocs/fourn/product/list.php
* \ingroup produit * \ingroup produit
* \brief Page liste des produits ou services * \brief Page to list supplier products and services
*/ */
require '../../main.inc.php'; require '../../main.inc.php';

View File

@ -482,7 +482,7 @@ class CommentParser
$r['name'] = substr($data, 1); $r['name'] = substr($data, 1);
} }
} }
if (isset($r['type']) && Text::endsWith($r['type'], '[]')) { if (isset($r['type']) && is_string($r['type']) && Text::endsWith($r['type'], '[]')) {
$r[static::$embeddedDataName]['type'] = substr($r['type'], 0, -2); $r[static::$embeddedDataName]['type'] = substr($r['type'], 0, -2);
$r['type'] = 'array'; $r['type'] = 'array';
} }

View File

@ -331,7 +331,7 @@ UrlGenerationParameters=Parameters to secure URLs
SecurityTokenIsUnique=Use a unique securekey parameter for each URL SecurityTokenIsUnique=Use a unique securekey parameter for each URL
EnterRefToBuildUrl=Enter reference for object %s EnterRefToBuildUrl=Enter reference for object %s
GetSecuredUrl=Get calculated URL GetSecuredUrl=Get calculated URL
ButtonHideUnauthorized=Hide buttons for unauthorized actions instead of showing disabled buttons ButtonHideUnauthorized=Hide buttons to non admin users for unauthorized actions instead of showing greyed disabled buttons
OldVATRates=Old VAT rate OldVATRates=Old VAT rate
NewVATRates=New VAT rate NewVATRates=New VAT rate
PriceBaseTypeToChange=Modify on prices with base reference value defined on PriceBaseTypeToChange=Modify on prices with base reference value defined on

View File

@ -49,6 +49,8 @@ $action = GETPOST('action', 'alpha');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$price_by_qty_rowid = GETPOST('pbq', 'int'); $price_by_qty_rowid = GETPOST('pbq', 'int');
$finished = GETPOST('finished', 'int'); $finished = GETPOST('finished', 'int');
$alsoproductwithnosupplierprice = GETPOST('alsoproductwithnosupplierprice', 'int');
/* /*
* View * View
@ -157,7 +159,9 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
} }
echo json_encode($outjson); echo json_encode($outjson);
} else { }
else
{
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
$langs->load("products"); $langs->load("products");
@ -181,9 +185,9 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
$form = new Form($db); $form = new Form($db);
if (empty($mode) || $mode == 1) { // mode=1: customer if (empty($mode) || $mode == 1) { // mode=1: customer
$arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, $finished, $outjson, $socid); $arrayresult = $form->select_produits_list("", $htmlname, $type, 0, $price_level, $searchkey, $status, $finished, $outjson, $socid);
} elseif ($mode == 2) { // mode=2: supplier } elseif ($mode == 2) { // mode=2: supplier
$arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson); $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, 0, $alsoproductwithnosupplierprice);
} }
$db->close(); $db->close();

View File

@ -1316,16 +1316,17 @@ class Product extends CommonObject
/** /**
* Read price used by a provider * Read price used by a provider.
* We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref.
* This also set some properties on product like ->buyprice, ->fourn_pu, ...
* *
* @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price
* @param double $qty Quantity asked * @param double $qty Quantity asked
* @param int $product_id Filter on a particular product id * @param int $product_id Filter on a particular product id
* @param string $fourn_ref Filter on a supplier ref * @param string $fourn_ref Filter on a supplier ref. 'none' to exclude ref in search.
* @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...)
*/ */
function get_buyprice($prodfournprice,$qty,$product_id=0,$fourn_ref=0) function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='')
{ {
global $conf; global $conf;
$result = 0; $result = 0;
@ -1335,7 +1336,8 @@ class Product extends CommonObject
$sql.= " pfp.fk_product, pfp.ref_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression"; $sql.= " pfp.fk_product, pfp.ref_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE pfp.rowid = ".$prodfournprice; $sql.= " WHERE pfp.rowid = ".$prodfournprice;
if ($qty) $sql.= " AND pfp.quantity <= ".$qty; if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty;
$sql.= " ORDER BY pfp.quantity DESC";
dol_syslog(get_class($this)."::get_buyprice first search by prodfournprice/qty", LOG_DEBUG); dol_syslog(get_class($this)."::get_buyprice first search by prodfournprice/qty", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1369,13 +1371,13 @@ class Product extends CommonObject
} }
else // If not found else // If not found
{ {
// We do a second search by doing a select again but searching with qty, ref and id product // We do a second search by doing a select again but searching with qty and id product
$sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,"; $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,";
$sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression"; $sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE pfp.ref_fourn = '".$fourn_ref."'"; $sql.= " WHERE pfp.fk_product = ".$product_id;
$sql.= " AND pfp.fk_product = ".$product_id; if ($fourn_ref != 'none') $sql.= " AND pfp.ref_fourn = '".$fourn_ref."'";
$sql.= " AND pfp.quantity <= ".$qty; if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty;
$sql.= " ORDER BY pfp.quantity DESC"; $sql.= " ORDER BY pfp.quantity DESC";
$sql.= " LIMIT 1"; $sql.= " LIMIT 1";
@ -1412,7 +1414,7 @@ class Product extends CommonObject
} }
else else
{ {
return -1; // Ce produit n'existe pas avec cette ref fournisseur ou existe mais qte insuffisante return -1; // Ce produit n'existe pas avec cet id tarif fournisseur ou existe mais qte insuffisante, ni pour le couple produit/ref fournisseur dans la quantité.
} }
} }
else else

View File

@ -248,8 +248,13 @@ if ($resql)
print '</div>'; print '</div>';
} }
$param='';
$param="&tosell=$tosell&tobuy=$tobuy".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref"; if ($tosell) $param.="&tosell=".$tosell;
if ($tobuy) $param.="&tobuy=".$tobuy;
if ($type) $param.="&type=".$type;
if ($fourn_id) $param.="&fourn_id=".$fourn_id;
if ($snom) $param.="&snom=".$snom;
if ($sref) $param.="&sref=".$sref;
$formProduct = new FormProduct($db); $formProduct = new FormProduct($db);
$formProduct->loadWarehouses(); $formProduct->loadWarehouses();

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -239,7 +240,16 @@ if ($resql)
} }
$param="&tosell=$tosell&tobuy=$tobuy".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref&batch=$batch&eatby=$eatby&sellby=$sellby"; $param='';
if ($tosell) $param.="&tosell=".$tosell;
if ($tobuy) $param.="&tobuy=".$tobuy;
if ($type) $param.="&type=".$type;
if ($fourn_id) $param.="&fourn_id=".$fourn_id;
if ($snom) $param.="&snom=".$snom;
if ($sref) $param.="&sref=".$sref;
if ($search_batch) $param.="&search_batch=".$search_batch;
/*if ($eatby) $param.="&eatby=".$eatby;
if ($sellby) $param.="&sellby=".$sellby;*/
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'; print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">';
@ -257,8 +267,8 @@ if ($resql)
// TODO Add info of running suppliers/customers orders // TODO Add info of running suppliers/customers orders
//print_liste_field_titre($langs->trans("TheoreticalStock"),$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder); //print_liste_field_titre($langs->trans("TheoreticalStock"),$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder);
print_liste_field_titre(''); print_liste_field_titre('');
print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy","",$param,'align="right"',$sortfield,$sortorder);
print "</tr>\n"; print "</tr>\n";
// Lignes des champs de filtre // Lignes des champs de filtre

View File

@ -185,11 +185,12 @@ class Productlot extends CommonObject
* Load object in memory from the database * Load object in memory from the database
* *
* @param int $id Id object * @param int $id Id object
* @param string $ref Ref * @param int $product_id Id of product, batch number parameter required
* @param string $batch batch number
* *
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function fetch($id, $ref = null) public function fetch($id = 0, $product_id = null, $batch = null)
{ {
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -209,8 +210,8 @@ class Productlot extends CommonObject
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
if (null !== $ref) { if ((null !== $product_id) && (null !== $batch)) {
$sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; $sql .= ' WHERE t.batch = ' . '\'' . $batch . '\' AND t.fk_product = ' . $product_id;
} else { } else {
$sql .= ' WHERE t.rowid = ' . $id; $sql .= ' WHERE t.rowid = ' . $id;
} }
@ -307,7 +308,8 @@ class Productlot extends CommonObject
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql))
{
$line = new ProductlotLine(); $line = new ProductlotLine();
$line->id = $obj->rowid; $line->id = $obj->rowid;
@ -525,101 +527,6 @@ class Productlot extends CommonObject
} }
} }
/**
* Return a link to the user card (with optionaly the picto)
* Use this->id,this->lastname, this->firstname
*
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param string $option On what the link point to
* @param integer $notooltip 1=Disable tooltip
* @param int $maxlen Max length of visible user name
* @param string $morecss Add more css on link
* @return string String with URL
*/
function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
{
global $langs, $conf, $db;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
$result = '';
$companylink = '';
$label = '<u>' . $langs->trans("LotSerial") . '</u>';
$label.= '<div width="100%">';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
$link = '<a href="'.DOL_URL_ROOT.'/stock/card.php?id='.$this->id.'"';
$link.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
$link.= '>';
$linkend='</a>';
if ($withpicto)
{
$result.=($link.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
if ($withpicto != 2) $result.=' ';
}
$result.= $link . $this->ref . $linkend;
return $result;
}
/**
* Retourne le libelle du status d'un user (actif, inactif)
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label of status
*/
function getLibStatut($mode=0)
{
return $this->LibStatut($this->status,$mode);
}
/**
* Renvoi le libelle d'un status donne
*
* @param int $status Id status
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label of status
*/
function LibStatut($status,$mode=0)
{
global $langs;
if ($mode == 0)
{
$prefix='';
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
}
if ($mode == 1)
{
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
}
if ($mode == 2)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
if ($mode == 3)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
}
if ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
if ($mode == 5)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
}
}
/** /**
* Initialise object with example values * Initialise object with example values
* Id must be 0 if object instance is a specimen * Id must be 0 if object instance is a specimen
@ -640,8 +547,6 @@ class Productlot extends CommonObject
$this->fk_user_creat = ''; $this->fk_user_creat = '';
$this->fk_user_modif = ''; $this->fk_user_modif = '';
$this->import_key = ''; $this->import_key = '';
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* *
@ -59,6 +59,21 @@ $fieldstosearchall = array(
); );
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
$search_ref="";
$sall="";
$search_label="";
$search_status="";
$search_array_options=array();
}
/* /*
* View * View
@ -110,6 +125,10 @@ if ($result)
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_ref) $param.="&search_ref=".$search_ref;
if ($search_label) $param.="&search_label=".$search_label;
if ($search_status) $param.="&search_status=".$search_status;
if ($sall) $param.="&sall=".$sall;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';

View File

@ -6,6 +6,7 @@
* Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2016 Josep Lluis Amador <joseplluis@lliuretic.cat> * Copyright (C) 2016 Josep Lluis Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -453,6 +454,7 @@ llxHeader('',$langs->trans("ThirdParty"),$help_url);
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_all != '') $param = "&amp;sall=".urlencode($search_all);
if ($sall != '') $param .= "&amp;sall=".urlencode($sall); if ($sall != '') $param .= "&amp;sall=".urlencode($sall);
if ($search_categ > 0) $param.='&amp;search_categ='.urlencode($search_categ); if ($search_categ > 0) $param.='&amp;search_categ='.urlencode($search_categ);
if ($search_sale > 0) $param.='&amp;search_sale='.urlencode($search_sale); if ($search_sale > 0) $param.='&amp;search_sale='.urlencode($search_sale);

View File

@ -25,6 +25,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/**
* \file htdocs/supplier_proposal/card.php
* \ingroup supplier_proposal
* \brief Card supplier proposal
*/
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
@ -96,6 +102,8 @@ if ($id > 0 || ! empty($ref)) {
$hookmanager->initHooks(array('supplier_proposalcard','globalcard')); $hookmanager->initHooks(array('supplier_proposalcard','globalcard'));
$permissionnote = $user->rights->supplier_proposal->creer; // Used by the include of actions_setnotes.inc.php $permissionnote = $user->rights->supplier_proposal->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->supplier_proposal->creer; // Used by the include of actions_dellink.inc.php
$permissiontoedit=$user->rights->supplier_proposal->creer; // Used by the include of actions_lineupdown.inc.php
/* /*
@ -344,10 +352,10 @@ if (empty($reshook))
// Extrafields // Extrafields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) {
$lines[$i]->fetch_optionals($lines[$i]->rowid); $lines[$i]->fetch_optionals($lines[$i]->rowid);
$array_option = $lines[$i]->array_options; $array_options = $lines[$i]->array_options;
} }
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_option); $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options);
if ($result > 0) { if ($result > 0) {
$lineid = $result; $lineid = $result;
@ -501,22 +509,28 @@ if (empty($reshook))
} }
} }
// Add line // Add a product line
else if ($action == 'addline' && $user->rights->supplier_proposal->creer) { if ($action == 'addline' && $user->rights->supplier_proposal->creer)
{
$langs->load('errors');
$error = 0;
// Set if we used free entry or predefined product // Set if we used free entry or predefined product
$predef=''; $predef='';
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
$price_ht = GETPOST('price_ht'); $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'));
if (GETPOST('prod_entry_mode') == 'free') if (GETPOST('prod_entry_mode') == 'free')
{ {
$idprod=0; $idprod=0;
$price_ht = GETPOST('price_ht');
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} }
else else
{ {
$idprod=GETPOST('idprod', 'int'); $idprod=GETPOST('idprod', 'int');
$price_ht = '';
$tva_tx = ''; $tva_tx = '';
} }
@ -526,7 +540,7 @@ if (empty($reshook))
// Extrafields // Extrafields
$extrafieldsline = new ExtraFields($db); $extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
// Unset extrafield // Unset extrafield
if (is_array($extralabelsline)) { if (is_array($extralabelsline)) {
// Get extra fields // Get extra fields
@ -549,8 +563,7 @@ if (empty($reshook))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors');
$error ++; $error ++;
} }
if (! $error && ($qty >= 0)) {
if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) {
$pu_ht = 0; $pu_ht = 0;
$pu_ttc = 0; $pu_ttc = 0;
$price_min = 0; $price_min = 0;
@ -561,150 +574,140 @@ if (empty($reshook))
// Ecrase $pu par celui du produit // Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit // Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit // Ecrase $txtva par celui du produit
if (! empty($idprod)) { if ((GETPOST('prod_entry_mode') != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
$prod = new Product($db); {
$prod->fetch($idprod); $productsupplier = new ProductFournisseur($db);
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED))
{
$idprod=0;
if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)
}
if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg))
{
$idprod=$reg[1];
// Call to init properties of $productsupplier
// So if a supplier price already exists for another thirdparty (first one found), we use it as reference price
$productsupplier->get_buyprice(0, -1, $idprod, 'none'); // We force qty to -1 to be sure to find if a supplier price exist
}
elseif (GETPOST('idprodfournprice') > 0)
{
//$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat.
$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), -1); // We force qty to -1 to be sure to find if a supplier price exist
}
// If prices fields are update
$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
if (empty($tva_tx)) $tva_npr=0;
//On garde le prix indiqué dans l'input pour la demande de prix fournisseur if ($idprod > 0)
//$pu_ht = $prod->price; {
$pu_ht = price2num($price_ht, 'MU'); $res=$productsupplier->fetch($idprod);
//$pu_ttc = $prod->price_ttc;
$pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU');
$price_min = $prod->price_min; $label = $productsupplier->label;
$price_base_type = $prod->price_base_type;
// On defini prix unitaire $desc = $productsupplier->description;
if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level) if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
{
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
}
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
{
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
$prodcustprice = new Productcustomerprice($db); $type = $productsupplier->type;
$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
$tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
if (empty($tva_tx)) $tva_npr=0;
$localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
$localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result=$object->addline(
if ($result) { $desc,
if (count($prodcustprice->lines) > 0) { $productsupplier->fourn_pu,
$pu_ht = price($prodcustprice->lines [0]->price); $qty,
$pu_ttc = price($prodcustprice->lines [0]->price_ttc); $tva_tx,
$price_base_type = $prodcustprice->lines [0]->price_base_type; $localtax1_tx,
$prod->tva_tx = $prodcustprice->lines [0]->tva_tx; $localtax2_tx,
} $productsupplier->id,
} $remise_percent,
} $type,
$productsupplier->price_ttc,
$tva_npr,
$type,
-1,
0,
GETPOST('fk_parent_line'),
$fournprice,
$buyingprice,
$label,
$array_options,
$ref_fourn
);
}
if ($idprod == -99 || $idprod == 0)
{
// Product not selected
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), null, 'errors');
}
if ($idprod == -1)
{
// Quantity too low
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors');
}
}
else if((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) // Free product
{
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
$tva_tx = str_replace('*', '', $tva_tx);
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc;
$type = GETPOST('type');
// if price ht is forced (ie: calculated by margin rate and cost price) $fk_unit= GETPOST('units', 'alpha');
if (! empty($price_ht)) {
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU');
}
// On reevalue prix selon taux tva car taux tva transaction peut etre different $tva_tx = price2num($tva_tx); // When vat is text input field
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
elseif ($tva_tx != $prod->tva_tx) {
if ($price_base_type != 'HT') {
$pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU');
} else {
$pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU');
}
}
$desc = ''; // Local Taxes
$localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
$localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
// Define output language if (GETPOST('price_ht')!=='')
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { {
$outputlangs = $langs; $price_base_type = 'HT';
$newlang = ''; $ht = price2num(GETPOST('price_ht'));
if (empty($newlang) && GETPOST('lang_id')) $ttc = 0;
$newlang = GETPOST('lang_id'); }
if (empty($newlang)) else
$newlang = $object->thirdparty->default_lang; {
if (! empty($newlang)) { $ttc = price2num(GETPOST('price_ttc'));
$outputlangs = new Translate("", $conf); $ht = $ttc / (1 + ($tva_tx / 100));
$outputlangs->setDefaultLang($newlang); $price_base_type = 'HT';
} }
$desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; $result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_fourn);
} else { //$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit);
$desc = $prod->description;
}
$desc = dol_concatdesc($desc, $product_desc);
// Add custom code and origin country into description
if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) {
$tmptxt = '(';
if (! empty($prod->customcode))
$tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
if (! empty($prod->customcode) && ! empty($prod->country_code))
$tmptxt .= ' - ';
if (! empty($prod->country_code))
$tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
$tmptxt .= ')';
$desc = dol_concatdesc($desc, $tmptxt);
}
$type = $prod->type;
} else {
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
$tva_tx = str_replace('*', '', $tva_tx);
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc;
$type = GETPOST('type');
} }
// Margin
$fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : '');
$buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : '');
// Local Taxes if (! $error && $result > 0)
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); {
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty);
$info_bits = 0;
if ($tva_npr)
$info_bits |= 0x01;
if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) {
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
setEventMessages($mesg, null, 'errors');
} else {
// Insert line
$ref_fourn = GETPOST('fourn_ref');
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option, $ref_fourn);
if ($result > 0) {
$db->commit(); $db->commit();
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language
// Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs; $outputlangs = $langs;
if (! empty($conf->global->MAIN_MULTILANGS)) { $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records $ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result);
} }
unset($_POST['prod_entry_mode']); unset($_POST['prod_entry_mode']);
@ -712,18 +715,23 @@ if (empty($reshook))
unset($_POST['qty']); unset($_POST['qty']);
unset($_POST['type']); unset($_POST['type']);
unset($_POST['remise_percent']); unset($_POST['remise_percent']);
unset($_POST['pu']);
unset($_POST['price_ht']); unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']); unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']); unset($_POST['price_ttc']);
unset($_POST['tva_tx']); unset($_POST['tva_tx']);
unset($_POST['label']);
unset($_POST['product_ref']); unset($_POST['product_ref']);
unset($_POST['product_label']); unset($_POST['product_label']);
unset($_POST['product_desc']); unset($_POST['product_desc']);
unset($_POST['fournprice']); unset($_POST['fournprice']);
unset($_POST['buying_price']); unset($_POST['buying_price']);
unset($localtax1_tx);
unset($localtax2_tx);
unset($_POST['np_marginRate']); unset($_POST['np_marginRate']);
unset($_POST['np_markRate']); unset($_POST['np_markRate']);
unset($_POST['dp_desc']); unset($_POST['dp_desc']);
unset($_POST['idprodfournprice']);
unset($_POST['idprod']); unset($_POST['idprod']);
unset($_POST['date_starthour']); unset($_POST['date_starthour']);
@ -738,12 +746,14 @@ if (empty($reshook))
unset($_POST['date_endday']); unset($_POST['date_endday']);
unset($_POST['date_endmonth']); unset($_POST['date_endmonth']);
unset($_POST['date_endyear']); unset($_POST['date_endyear']);
} else {
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
} }
else
{
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
//}
} }
} }
@ -771,7 +781,7 @@ if (empty($reshook))
// Extrafields // Extrafields
$extrafieldsline = new ExtraFields($db); $extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
// Unset extrafield // Unset extrafield
if (is_array($extralabelsline)) { if (is_array($extralabelsline)) {
// Get extra fields // Get extra fields
@ -816,7 +826,7 @@ if (empty($reshook))
if (! $error) { if (! $error) {
$db->begin(); $db->begin();
$ref_fourn = GETPOST('fourn_ref'); $ref_fourn = GETPOST('fourn_ref');
$result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('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, $array_option, $ref_fourn); $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('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, $array_options, $ref_fourn);
if ($result >= 0) { if ($result >= 0) {
$db->commit(); $db->commit();
@ -1618,6 +1628,10 @@ if ($action == 'create')
print '<table id="tablelines" class="noborder noshadow" width="100%">'; print '<table id="tablelines" class="noborder noshadow" width="100%">';
// Add free products/services form
global $forceall, $senderissupplier, $dateSelector;
$forceall=1; $senderissupplier=2; $dateSelector=0; // $senderissupplier=2 is same than 1 but disable test on minimum qty.
if (! empty($object->lines)) if (! empty($object->lines))
$ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1);

View File

@ -9,7 +9,8 @@
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
@ -281,6 +282,7 @@ if ($result)
$param='&socid='.$socid.'&viewstatut='.$viewstatut; $param='&socid='.$socid.'&viewstatut='.$viewstatut;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($sall) $param.='&sall='.$sall;
if ($month) $param.='&month='.$month; if ($month) $param.='&month='.$month;
if ($year) $param.='&year='.$year; if ($year) $param.='&year='.$year;
if ($search_ref) $param.='&search_ref=' .$search_ref; if ($search_ref) $param.='&search_ref=' .$search_ref;

View File

@ -92,6 +92,16 @@ if ($id > 0 || ! empty($ref))
print "<tr><td>".$langs->trans("Supplier")."</td>"; print "<tr><td>".$langs->trans("Supplier")."</td>";
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>'; print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
// Payment term
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditionsShort');
print '</td>';
print '</tr></table>';
print '</td><td colspan="3">';
$form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'none', 1);
print '</td>';
print '</tr>';
print '<tr><td>'.$langs->trans('SupplierProposalDate').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('SupplierProposalDate').'</td><td colspan="3">';
print dol_print_date($object->date_livraison,'daytext'); print dol_print_date($object->date_livraison,'daytext');
print '</td>'; print '</td>';

View File

@ -945,7 +945,7 @@ $minwidthtmenu=66; /* minimum width for one top menu entry */
$heightmenu=46; /* height of top menu, part with image */ $heightmenu=46; /* height of top menu, part with image */
$heightmenu2=48; /* height of top menu, part with login */ $heightmenu2=48; /* height of top menu, part with login */
$disableimages = 0; $disableimages = 0;
$maxwidthloginblock = 110; $maxwidthloginblock = 130;
if (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { $disableimages = 1; $maxwidthloginblock = 180; $minwidthtmenu=0; } if (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { $disableimages = 1; $maxwidthloginblock = 180; $minwidthtmenu=0; }
?> ?>
@ -1397,6 +1397,7 @@ div.login a:hover {
} }
div.login_block_user { div.login_block_user {
display: inline-block; display: inline-block;
min-width: 120px;
} }
div.login_block_other { div.login_block_other {
display: inline-block; display: inline-block;
@ -1406,7 +1407,7 @@ div.login_block_other { padding-top: 3px; text-align: right; }
.login_block_elem { .login_block_elem {
float: right; float: right;
vertical-align: top; vertical-align: top;
padding: 0px 0px 0px 4px !important; padding: 0px 3px 0px 4px !important;
height: 16px; height: 16px;
} }
.atoplogin, .atoplogin:hover { .atoplogin, .atoplogin:hover {
@ -2224,7 +2225,7 @@ a.butAction:link, a.butAction:visited, a.butAction:hover, a.butAction:active {
} }
End bootstrap */ End bootstrap */
<?php if (! empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { ?> <?php if (! empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (! $user->admin)) { ?>
.butActionRefused { .butActionRefused {
display: none; display: none;
} }
@ -4512,6 +4513,9 @@ img.demothumb {
padding-<?php echo $right; ?>: 78px; padding-<?php echo $right; ?>: 78px;
<?php } ?> <?php } ?>
} }
div.login_block_user {
min-width: 0;
}
div.login_block { div.login_block {
top: 2px; top: 2px;
<?php if ($disableimages) { ?> <?php if ($disableimages) { ?>
@ -4520,6 +4524,9 @@ img.demothumb {
max-width: 82px; max-width: 82px;
<?php } ?> <?php } ?>
} }
.login_block_elem {
padding: 0 !important;
}
li.tmenu, li.tmenusel { li.tmenu, li.tmenusel {
min-width: 32px; min-width: 32px;
} }

View File

@ -263,10 +263,7 @@ if (empty($reshook)) {
{ {
$langs->load("errors"); $langs->load("errors");
$db->rollback(); $db->rollback();
if (is_array($object->errors) && count($object->errors)) setEventMessages($object->error, $object->errors, 'errors');
{
setEventMessages($object->error, $object->errors, 'errors');
}
$action = "create"; // Go back to create page $action = "create"; // Go back to create page
} }
} }

View File

@ -109,8 +109,8 @@ else
{ {
if (empty($user->id)) if (empty($user->id))
{ {
echo "User user login: ".$userlogin." does not exists"; echo "User login: ".$userlogin." does not exists";
dol_syslog("User user login:".$userlogin." does not exists", LOG_ERR); dol_syslog("User login:".$userlogin." does not exists", LOG_ERR);
exit(-1); exit(-1);
} }
} }
@ -124,8 +124,7 @@ if (isset($argv[3]) || $argv[3])
$object = new Cronjob($db); $object = new Cronjob($db);
$filter=array(); $filter=array();
if (empty($id)) { if (! empty($id)) {
$filter=array();
$filter['t.rowid']=$id; $filter['t.rowid']=$id;
} }
@ -152,22 +151,22 @@ if(is_array($object->lines) && (count($object->lines)>0))
//If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database
if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now))
{ {
dol_syslog("cron_run_jobs.php:: torun line->datenextrun:".dol_print_date($line->datenextrun,'dayhourtext')." line->dateend:".dol_print_date($line->dateend,'dayhourtext')." now:".dol_print_date($now,'dayhourtext')); dol_syslog("cron_run_jobs.php:: to run line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc'));
$cronjob=new Cronjob($db); $cronjob=new Cronjob($db);
$result=$cronjob->fetch($line->id); $result=$cronjob->fetch($line->id);
if ($result<0) if ($result<0)
{ {
echo "Error:".$cronjob->error; echo "Error cronjob->fetch: ".$cronjob->error;
dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR); dol_syslog("cron_run_jobs.php::fetch Error ".$cronjob->error, LOG_ERR);
exit(-1); exit(-1);
} }
// Execute job // Execute job
$result=$cronjob->run_jobs($userlogin); $result=$cronjob->run_jobs($userlogin);
if ($result<0) if ($result<0)
{ {
echo "Error:".$cronjob->error; echo "Error cronjob->run_job: ".$cronjob->error;
dol_syslog("cron_run_jobs.php:: run_jobs Error".$cronjob->error, LOG_ERR); dol_syslog("cron_run_jobs.php::run_jobs Error ".$cronjob->error, LOG_ERR);
exit(-1); exit(-1);
} }
@ -175,12 +174,16 @@ if(is_array($object->lines) && (count($object->lines)>0))
$result=$cronjob->reprogram_jobs($userlogin, $now); $result=$cronjob->reprogram_jobs($userlogin, $now);
if ($result<0) if ($result<0)
{ {
echo "Error:".$cronjob->error; echo "Error cronjob->reprogram_job: ".$cronjob->error;
dol_syslog("cron_run_jobs.php:: reprogram_jobs Error".$cronjob->error, LOG_ERR); dol_syslog("cron_run_jobs.php::reprogram_jobs Error ".$cronjob->error, LOG_ERR);
exit(-1); exit(-1);
} }
} }
else
{
dol_syslog("cron_run_jobs.php:: job not qualified line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc'));
}
} }
} }