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:
commit
9ff1809f85
@ -10,6 +10,7 @@
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -362,6 +363,7 @@ if ($resql)
|
||||
$param='&socid='.$socid.'&viewstatut='.$viewstatut;
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($sall) $param.='&sall='.$sall;
|
||||
if ($month) $param.='&month='.$month;
|
||||
if ($year) $param.='&year='.$year;
|
||||
if ($search_ref) $param.='&search_ref=' .$search_ref;
|
||||
|
||||
@ -384,6 +384,7 @@ if ($resql)
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($sall) $param.='&sall='.$sall;
|
||||
if ($socid > 0) $param.='&socid='.$socid;
|
||||
if ($viewstatut != '') $param.='&viewstatut='.$viewstatut;
|
||||
if ($orderday) $param.='&orderday='.$orderday;
|
||||
|
||||
@ -66,7 +66,6 @@ if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
|
||||
if (! empty($conf->margin->enabled))
|
||||
$langs->load('margins');
|
||||
|
||||
$sall = trim(GETPOST('sall'));
|
||||
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
|
||||
|
||||
$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') {
|
||||
$form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date, 'invoicedate');
|
||||
} else {
|
||||
print dol_print_date($object->date, 'daytext');
|
||||
print dol_print_date($object->date, 'day');
|
||||
}
|
||||
} else {
|
||||
print dol_print_date($object->date, 'daytext');
|
||||
print dol_print_date($object->date, 'day');
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
@ -3419,7 +3418,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
if ($action == 'editdate_pointoftax') {
|
||||
$form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date_pointoftax, 'date_pointoftax');
|
||||
} else {
|
||||
print dol_print_date($object->date_pointoftax, 'daytext');
|
||||
print dol_print_date($object->date_pointoftax, 'day');
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
@ -3459,7 +3458,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
if ($action == 'editpaymentterm') {
|
||||
$form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date_lim_reglement, 'paymentterm');
|
||||
} else {
|
||||
print dol_print_date($object->date_lim_reglement, 'daytext');
|
||||
print dol_print_date($object->date_lim_reglement, 'day');
|
||||
if ($object->hasDelay()) {
|
||||
print img_warning($langs->trans('Late'));
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@ class FactureRec extends CommonInvoice
|
||||
public $table_element_line='facturedet_rec';
|
||||
public $fk_element='fk_facture';
|
||||
|
||||
var $entity;
|
||||
var $number;
|
||||
var $date;
|
||||
var $amount;
|
||||
@ -241,7 +242,7 @@ class FactureRec extends CommonInvoice
|
||||
*/
|
||||
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.note_private, f.note_public, f.fk_user_author';
|
||||
$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);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->entity = $obj->entity;
|
||||
$this->titre = $obj->titre;
|
||||
$this->ref = $obj->titre;
|
||||
$this->ref_client = $obj->ref_client;
|
||||
@ -519,6 +521,7 @@ class FactureRec extends CommonInvoice
|
||||
{
|
||||
// Clean parameters
|
||||
$remise_percent=price2num($remise_percent);
|
||||
if (empty($remise_percent)) $remise_percent=0;
|
||||
$qty=price2num($qty);
|
||||
if (! $qty) $qty=1;
|
||||
if (! $info_bits) $info_bits=0;
|
||||
@ -579,12 +582,12 @@ class FactureRec extends CommonInvoice
|
||||
$sql.= ", ".price2num($txtva);
|
||||
$sql.= ", ".(! empty($fk_product)?"'".$fk_product."'":"null");
|
||||
$sql.= ", ".$product_type;
|
||||
$sql.= ", '".price2num($remise_percent)."'";
|
||||
$sql.= ", '".price2num($pu_ht)."'";
|
||||
$sql.= ", ".price2num($remise_percent);
|
||||
$sql.= ", ".price2num($pu_ht);
|
||||
$sql.= ", null";
|
||||
$sql.= ", '".price2num($total_ht)."'";
|
||||
$sql.= ", '".price2num($total_tva)."'";
|
||||
$sql.= ", '".price2num($total_ttc)."'";
|
||||
$sql.= ", ".price2num($total_ht);
|
||||
$sql.= ", ".price2num($total_tva);
|
||||
$sql.= ", ".price2num($total_ttc);
|
||||
$sql.= ", ".$rang;
|
||||
$sql.= ", ".$special_code;
|
||||
$sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null").")";
|
||||
@ -721,14 +724,16 @@ class FactureRec extends CommonInvoice
|
||||
}
|
||||
|
||||
/**
|
||||
* Create all recurrents invoices.
|
||||
* A result may also be provided into this->output
|
||||
* Create all recurrents invoices (for all entities if multicompany is used).
|
||||
* 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)
|
||||
*/
|
||||
function createRecurringInvoices()
|
||||
{
|
||||
global $langs, $db, $user;
|
||||
global $conf, $langs, $db, $user;
|
||||
|
||||
$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.= " 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.= $db->order('entity', 'ASC');
|
||||
//print $sql;exit;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
@ -754,7 +760,9 @@ class FactureRec extends CommonInvoice
|
||||
if ($num) $this->output.=$langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n";
|
||||
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);
|
||||
|
||||
@ -763,7 +771,10 @@ class FactureRec extends CommonInvoice
|
||||
$facturerec = new FactureRec($db);
|
||||
$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;
|
||||
|
||||
@ -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->socid = $facturerec->socid;
|
||||
|
||||
$invoiceidgenerated = $facture->create($user); // This will also update fields of recurring invoice
|
||||
$invoiceidgenerated = $facture->create($user);
|
||||
if ($invoiceidgenerated <= 0)
|
||||
{
|
||||
$this->errors = $facture->errors;
|
||||
@ -794,18 +805,20 @@ class FactureRec extends CommonInvoice
|
||||
|
||||
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");
|
||||
$nb_create++;
|
||||
$this->output.=$langs->trans("InvoiceGeneratedFromTemplate", $facture->ref, $facturerec->ref)."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$db->rollback("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref);
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$conf->entity = $saventity; // Restore entity context
|
||||
}
|
||||
else dol_print_error($db);
|
||||
|
||||
@ -1060,7 +1073,7 @@ class FactureRec extends CommonInvoice
|
||||
return -1;
|
||||
}
|
||||
$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';
|
||||
$sql.= ' WHERE rowid = '.$this->id;
|
||||
|
||||
|
||||
@ -241,7 +241,8 @@ class Facture extends CommonInvoice
|
||||
if (! $this->cond_reglement_id) $this->cond_reglement_id = 0;
|
||||
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
|
||||
$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)
|
||||
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code);
|
||||
else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
|
||||
@ -281,8 +282,9 @@ class Facture extends CommonInvoice
|
||||
$_facrec = new FactureRec($this->db);
|
||||
$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
|
||||
$this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project;
|
||||
$this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public;
|
||||
@ -311,13 +313,15 @@ class Facture extends CommonInvoice
|
||||
|
||||
$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)
|
||||
{
|
||||
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
|
||||
$_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->setNextDate($next_date,1);
|
||||
$result = $_facrec->setNextDate($next_date,1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -352,7 +356,7 @@ class Facture extends CommonInvoice
|
||||
$sql.= ")";
|
||||
$sql.= " VALUES (";
|
||||
$sql.= "'(PROV)'";
|
||||
$sql.= ", ".$conf->entity;
|
||||
$sql.= ", ".$this->entity;
|
||||
$sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null");
|
||||
$sql.= ", '".$this->db->escape($this->type)."'";
|
||||
$sql.= ", '".$socid."'";
|
||||
|
||||
@ -410,6 +410,7 @@ if ($resql)
|
||||
$param='&socid='.$socid;
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($sall) $param.='&sall='.$sall;
|
||||
if ($day) $param.='&day='.urlencode($day);
|
||||
if ($month) $param.='&month='.urlencode($month);
|
||||
if ($year) $param.='&year=' .urlencode($year);
|
||||
|
||||
@ -380,6 +380,7 @@ if ($result)
|
||||
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_supplier)) $param.='&search_categ_supplier='.urlencode($search_categ_supplier);
|
||||
if ($sall != '') $param.='&sall='.urlencode($sall);
|
||||
if ($search_lastname != '') $param.='&search_lastname='.urlencode($search_lastname);
|
||||
if ($search_firstname != '') $param.='&search_firstname='.urlencode($search_firstname);
|
||||
if ($search_societe != '') $param.='&search_societe='.urlencode($search_societe);
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -307,12 +308,13 @@ if ($resql)
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($search_contract) $param.='&search_contract='.$search_contract;
|
||||
if ($search_name) $param.='&search_name='.$search_name;
|
||||
if ($search_ref_supplier) $param.='&search_ref_supplier='.$search_ref_supplier;
|
||||
if ($search_sale) $param.='&search_sale=' .$search_sale;
|
||||
if ($show_files) $param.='&show_files=' .$show_files;
|
||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||
if ($sall != '') $param.='&sall='.$sall;
|
||||
if ($search_contract != '') $param.='&search_contract='.$search_contract;
|
||||
if ($search_name != '') $param.='&search_name='.$search_name;
|
||||
if ($search_ref_supplier != '') $param.='&search_ref_supplier='.$search_ref_supplier;
|
||||
if ($search_sale != '') $param.='&search_sale=' .$search_sale;
|
||||
if ($show_files) $param.='&show_files=' .$show_files;
|
||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||
// Add $param from extra fields
|
||||
foreach ($search_array_options as $key => $val)
|
||||
{
|
||||
@ -330,9 +332,6 @@ if ($resql)
|
||||
if ($massaction == 'presend') $arrayofmassactions=array();
|
||||
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
|
||||
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
|
||||
@ -2067,9 +2067,10 @@ class Form
|
||||
* @param string $filtre For a SQL filter
|
||||
* @param array $ajaxoptions Options for ajax_autocompleter
|
||||
* @param int $hidelabel Hide label (0=no, 1=yes)
|
||||
* @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices
|
||||
* @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 $price_level, $status, $finished;
|
||||
@ -2091,7 +2092,7 @@ class Form
|
||||
print '<input type="hidden" id="idprod" name="idprod" value="0" />';
|
||||
}
|
||||
// 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 ($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 '<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 $outputmode 0=HTML select string, 1=Array
|
||||
* @param int $limit Limit of line number
|
||||
* @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices
|
||||
* @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;
|
||||
|
||||
@ -2174,7 +2176,7 @@ class Form
|
||||
$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="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
$out.='<select class="flat maxwidthonsmartphone" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
if (! $selected) $out.='<option value="0" selected> </option>';
|
||||
else $out.='<option value="0"> </option>';
|
||||
|
||||
@ -2183,7 +2185,9 @@ class Form
|
||||
{
|
||||
$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;
|
||||
$outval='';
|
||||
$outqty=1;
|
||||
@ -2192,9 +2196,9 @@ class Form
|
||||
$outdurationvalue=$outtype == Product::TYPE_SERVICE?substr($objp->duration,0,dol_strlen($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 (empty($objp->idprodfournprice)) $opt.=' disabled';
|
||||
if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt.=' disabled';
|
||||
$opt.= '>';
|
||||
|
||||
$objRef = $objp->ref;
|
||||
@ -2273,18 +2277,25 @@ class Form
|
||||
}
|
||||
if ($objp->supplier_reputation)
|
||||
{
|
||||
//TODO dictionnary
|
||||
$reputations=array(''=>$langs->trans('Standard'),'FAVORITE'=>$langs->trans('Favorite'),'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier'));
|
||||
//TODO dictionnary
|
||||
$reputations=array(''=>$langs->trans('Standard'),'FAVORITE'=>$langs->trans('Favorite'),'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier'));
|
||||
|
||||
$opt .= " - ".$reputations[$objp->supplier_reputation];
|
||||
$outval.=" - ".$reputations[$objp->supplier_reputation];
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$opt.= $langs->trans("NoPriceDefinedForThisSupplier");
|
||||
$outval.=$langs->transnoentities("NoPriceDefinedForThisSupplier");
|
||||
if (empty($alsoproductwithnosupplierprice)) // No supplier price defined for couple product/supplier
|
||||
{
|
||||
$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";
|
||||
|
||||
|
||||
@ -838,7 +838,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
||||
if (! empty($conf->commande->enabled))
|
||||
{
|
||||
$langs->load("orders");
|
||||
if (! empty($conf->facture->enabled)) $newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=-3", $langs->trans("MenuOrdersToBill2"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders');
|
||||
if (! empty($conf->facture->enabled)) $newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=-3&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);
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($ob
|
||||
$usemargins=1;
|
||||
}
|
||||
|
||||
global $forceall, $senderissupplier, $inputalsopricewithtax;
|
||||
global $dateSelector, $forceall, $senderissupplier, $inputalsopricewithtax;
|
||||
if (empty($dateSelector)) $dateSelector=0;
|
||||
if (empty($forceall)) $forceall=0;
|
||||
if (empty($senderissupplier)) $senderissupplier=0;
|
||||
@ -187,12 +187,21 @@ else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$ajaxoptions=array(
|
||||
'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
|
||||
'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error'
|
||||
);
|
||||
$form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1);
|
||||
if ($senderissupplier != 2)
|
||||
{
|
||||
$ajaxoptions=array(
|
||||
'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
|
||||
'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>';
|
||||
}
|
||||
@ -230,7 +239,7 @@ else {
|
||||
</td>
|
||||
|
||||
<?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 } ?>
|
||||
|
||||
<td class="nobottom linecolvat" align="right"><?php
|
||||
|
||||
@ -368,6 +368,7 @@ class Cronjob extends CommonObject
|
||||
|
||||
$sql = "SELECT";
|
||||
$sql.= " t.rowid,";
|
||||
$sql.= " t.entity,";
|
||||
$sql.= " t.tms,";
|
||||
$sql.= " t.datec,";
|
||||
$sql.= " t.jobtype,";
|
||||
@ -439,6 +440,7 @@ class Cronjob extends CommonObject
|
||||
$line->id = $obj->rowid;
|
||||
$line->ref = $obj->rowid;
|
||||
|
||||
$line->entity = $obj->entity;
|
||||
$line->tms = $this->db->jdate($obj->tms);
|
||||
$line->datec = $this->db->jdate($obj->datec);
|
||||
$line->label = $obj->label;
|
||||
@ -893,6 +895,7 @@ class Cronjob extends CommonObject
|
||||
|
||||
// Update last run date start (to track running jobs)
|
||||
$this->datelastrun=$now;
|
||||
$this->datelastresult=null;
|
||||
$this->lastoutput='';
|
||||
$this->lastresult='';
|
||||
$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 now we update job to track it is finished (with success or error)");
|
||||
|
||||
$this->datelastresult=dol_now();
|
||||
$result = $this->update($user); // This include begin/commit
|
||||
if ($result < 0)
|
||||
|
||||
@ -364,13 +364,14 @@ class Expedition extends CommonObject
|
||||
* @param int $entrepot_id Id of warehouse
|
||||
* @param int $origin_line_id Id of source line
|
||||
* @param int $qty Quantity
|
||||
* @param array $array_options extrafields array
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param array $array_options extrafields array
|
||||
* @return int <0 if KO, line_id if OK
|
||||
*/
|
||||
function create_line($entrepot_id, $origin_line_id, $qty,$array_options=0)
|
||||
{
|
||||
global $conf;
|
||||
$error = 0;
|
||||
$line_id = 0;
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (";
|
||||
$sql.= "fk_expedition";
|
||||
@ -385,12 +386,17 @@ class Expedition extends CommonObject
|
||||
$sql.= ")";
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
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->array_options=$array_options;
|
||||
@ -403,7 +409,7 @@ class Expedition extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error) return 1;
|
||||
if (! $error) return $line_id;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
@ -432,14 +438,13 @@ class Expedition extends CommonObject
|
||||
// create shipment lines
|
||||
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++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// create shipment batch lines for stockLocation
|
||||
$line_id= $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet");
|
||||
foreach ($tab as $detbatch)
|
||||
{
|
||||
if ($detbatch->entrepot_id == $stockLocation){
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -258,6 +259,7 @@ if ($resql)
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($sall) $param.= "&sall=".$sall;
|
||||
if ($search_ref_exp) $param.= "&search_ref_exp=".$search_ref_exp;
|
||||
if ($search_ref_liv) $param.= "&search_ref_liv=".$search_ref_liv;
|
||||
if ($search_company) $param.= "&search_company=".$search_company;
|
||||
|
||||
@ -293,6 +293,7 @@ if ($resql)
|
||||
$param="";
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
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_user) $param.="&search_user=".$search_user;
|
||||
if ($search_amount_ht) $param.="&search_amount_ht=".$search_amount_ht;
|
||||
|
||||
@ -215,6 +215,7 @@ if ($result)
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($sall) $urlparam.="&sall=".$sall;
|
||||
if ($socid) $param.="&socid=".$socid;
|
||||
if ($search_ref) $param.="&search_ref=".urlencode($search_ref);
|
||||
if ($search_company) $param.="&search_company=".urlencode($search_company);
|
||||
@ -276,7 +277,7 @@ if ($result)
|
||||
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.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 "</tr>\n";
|
||||
|
||||
|
||||
@ -298,22 +298,23 @@ if ($object->id > 0)
|
||||
$langs->load("products");
|
||||
print '<table class="noborder" width="100%">';
|
||||
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></td></tr>';
|
||||
|
||||
//Query from product/liste.php
|
||||
$sql = 'SELECT p.rowid, p.ref, p.label, pfp.tms,';
|
||||
$sql.= ' p.fk_product_type, p.entity';
|
||||
$sql = 'SELECT p.rowid, p.ref, p.label, 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.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pfp.fk_product";
|
||||
$sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')';
|
||||
$sql.= ' AND pfp.fk_soc = '.$object->id;
|
||||
$sql .= $db->order('pfp.tms', 'desc');
|
||||
$sql.= $db->plimit($MAXLIST);
|
||||
|
||||
|
||||
$query = $db->query($sql);
|
||||
|
||||
if (! $query) dol_print_error($db);
|
||||
|
||||
$return = array();
|
||||
|
||||
if ($db->num_rows($query)) {
|
||||
@ -335,12 +336,24 @@ if ($object->id > 0)
|
||||
print $productstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $productstatic->ref;
|
||||
print $objp->supplier_ref;
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<td class="maxwidthonsmartphone">';
|
||||
print dol_trunc(dol_htmlentities($objp->label), 30);
|
||||
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>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1297,7 +1297,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
* @param float $txtva Taux tva
|
||||
* @param float $txlocaltax1 Localtax1 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 string $fourn_ref Supplier reference
|
||||
* @param float $remise_percent Remise
|
||||
|
||||
@ -272,9 +272,7 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a line into product
|
||||
*/
|
||||
// Add a product line
|
||||
if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
$langs->load('errors');
|
||||
@ -426,8 +424,8 @@ if (empty($reshook))
|
||||
$tva_tx = price2num($tva_tx); // When vat is text input field
|
||||
|
||||
// Local Taxes
|
||||
$localtax1_tx= get_localtax($tva_tx, 1,$mysoc,$object->thirdparty);
|
||||
$localtax2_tx= get_localtax($tva_tx, 2,$mysoc,$object->thirdparty);
|
||||
$localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
|
||||
$localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
|
||||
|
||||
if (GETPOST('price_ht')!=='')
|
||||
{
|
||||
@ -2080,184 +2078,6 @@ elseif (! empty($object->id))
|
||||
|
||||
$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"> </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> </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.'&action=editline&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.'&action='.$actiondelete.'&lineid='.$line->id.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td><td> </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
|
||||
if ($object->statut == 0 && $user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* 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
|
||||
* 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 (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($sall) $param.="&search_all=".$sall;
|
||||
if ($orderday) $param.='&orderday='.$orderday;
|
||||
if ($ordermonth) $param.='&ordermonth='.$ordermonth;
|
||||
if ($orderyear) $param.='&orderyear='.$orderyear;
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
/**
|
||||
* \file htdocs/fourn/product/list.php
|
||||
* \ingroup produit
|
||||
* \brief Page liste des produits ou services
|
||||
* \brief Page to list supplier products and services
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
@ -482,7 +482,7 @@ class CommentParser
|
||||
$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['type'] = 'array';
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ UrlGenerationParameters=Parameters to secure URLs
|
||||
SecurityTokenIsUnique=Use a unique securekey parameter for each URL
|
||||
EnterRefToBuildUrl=Enter reference for object %s
|
||||
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
|
||||
NewVATRates=New VAT rate
|
||||
PriceBaseTypeToChange=Modify on prices with base reference value defined on
|
||||
|
||||
@ -49,6 +49,8 @@ $action = GETPOST('action', 'alpha');
|
||||
$id = GETPOST('id', 'int');
|
||||
$price_by_qty_rowid = GETPOST('pbq', 'int');
|
||||
$finished = GETPOST('finished', 'int');
|
||||
$alsoproductwithnosupplierprice = GETPOST('alsoproductwithnosupplierprice', 'int');
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -157,7 +159,9 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
|
||||
}
|
||||
|
||||
echo json_encode($outjson);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
|
||||
|
||||
$langs->load("products");
|
||||
@ -181,9 +185,9 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
|
||||
|
||||
$form = new Form($db);
|
||||
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
|
||||
$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();
|
||||
|
||||
@ -1316,16 +1316,17 @@ class Product extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* Read price used by a provider
|
||||
* We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref
|
||||
* Read price used by a provider.
|
||||
* 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 double $qty Quantity asked
|
||||
* @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...)
|
||||
*/
|
||||
function get_buyprice($prodfournprice,$qty,$product_id=0,$fourn_ref=0)
|
||||
function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='')
|
||||
{
|
||||
global $conf;
|
||||
$result = 0;
|
||||
@ -1335,8 +1336,9 @@ class Product extends CommonObject
|
||||
$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.= " 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);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -1369,13 +1371,13 @@ class Product extends CommonObject
|
||||
}
|
||||
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.= " 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.= " WHERE pfp.ref_fourn = '".$fourn_ref."'";
|
||||
$sql.= " AND pfp.fk_product = ".$product_id;
|
||||
$sql.= " AND pfp.quantity <= ".$qty;
|
||||
$sql.= " WHERE pfp.fk_product = ".$product_id;
|
||||
if ($fourn_ref != 'none') $sql.= " AND pfp.ref_fourn = '".$fourn_ref."'";
|
||||
if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty;
|
||||
$sql.= " ORDER BY pfp.quantity DESC";
|
||||
$sql.= " LIMIT 1";
|
||||
|
||||
@ -1412,7 +1414,7 @@ class Product extends CommonObject
|
||||
}
|
||||
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
|
||||
|
||||
@ -248,8 +248,13 @@ if ($resql)
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
||||
$param="&tosell=$tosell&tobuy=$tobuy".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref";
|
||||
$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;
|
||||
|
||||
$formProduct = new FormProduct($db);
|
||||
$formProduct->loadWarehouses();
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -237,9 +238,18 @@ if ($resql)
|
||||
print $hookmanager->resPrint;
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
||||
$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":"").'">';
|
||||
|
||||
@ -257,8 +267,8 @@ if ($resql)
|
||||
// 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('');
|
||||
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("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 "</tr>\n";
|
||||
|
||||
// Lignes des champs de filtre
|
||||
|
||||
@ -185,11 +185,12 @@ class Productlot extends CommonObject
|
||||
* Load object in memory from the database
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public function fetch($id, $ref = null)
|
||||
public function fetch($id = 0, $product_id = null, $batch = null)
|
||||
{
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
@ -209,8 +210,8 @@ class Productlot extends CommonObject
|
||||
|
||||
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||
if (null !== $ref) {
|
||||
$sql .= ' WHERE t.ref = ' . '\'' . $ref . '\'';
|
||||
if ((null !== $product_id) && (null !== $batch)) {
|
||||
$sql .= ' WHERE t.batch = ' . '\'' . $batch . '\' AND t.fk_product = ' . $product_id;
|
||||
} else {
|
||||
$sql .= ' WHERE t.rowid = ' . $id;
|
||||
}
|
||||
@ -307,7 +308,8 @@ class Productlot extends CommonObject
|
||||
if ($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->id = $obj->rowid;
|
||||
@ -524,101 +526,6 @@ class Productlot extends CommonObject
|
||||
return - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -640,8 +547,6 @@ class Productlot extends CommonObject
|
||||
$this->fk_user_creat = '';
|
||||
$this->fk_user_modif = '';
|
||||
$this->import_key = '';
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* 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) 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
|
||||
@ -110,6 +125,10 @@ if ($result)
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
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 '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
@ -126,7 +145,7 @@ if ($result)
|
||||
}
|
||||
|
||||
$moreforfilter='';
|
||||
|
||||
|
||||
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
|
||||
|
||||
print "<tr class=\"liste_titre\">";
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -453,6 +454,7 @@ llxHeader('',$langs->trans("ThirdParty"),$help_url);
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($search_all != '') $param = "&sall=".urlencode($search_all);
|
||||
if ($sall != '') $param .= "&sall=".urlencode($sall);
|
||||
if ($search_categ > 0) $param.='&search_categ='.urlencode($search_categ);
|
||||
if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale);
|
||||
|
||||
@ -25,6 +25,12 @@
|
||||
* 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_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.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'));
|
||||
|
||||
$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
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) {
|
||||
$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) {
|
||||
$lineid = $result;
|
||||
@ -501,22 +509,28 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
// Add line
|
||||
else if ($action == 'addline' && $user->rights->supplier_proposal->creer) {
|
||||
// Add a product line
|
||||
if ($action == 'addline' && $user->rights->supplier_proposal->creer)
|
||||
{
|
||||
$langs->load('errors');
|
||||
$error = 0;
|
||||
|
||||
// Set if we used free entry or predefined product
|
||||
$predef='';
|
||||
$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')
|
||||
{
|
||||
$idprod=0;
|
||||
$price_ht = GETPOST('price_ht');
|
||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$idprod=GETPOST('idprod', 'int');
|
||||
$price_ht = '';
|
||||
$tva_tx = '';
|
||||
}
|
||||
|
||||
@ -526,7 +540,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline)) {
|
||||
// Get extra fields
|
||||
@ -549,8 +563,7 @@ if (empty($reshook))
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors');
|
||||
$error ++;
|
||||
}
|
||||
|
||||
if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) {
|
||||
if (! $error && ($qty >= 0)) {
|
||||
$pu_ht = 0;
|
||||
$pu_ttc = 0;
|
||||
$price_min = 0;
|
||||
@ -561,150 +574,140 @@ if (empty($reshook))
|
||||
// Ecrase $pu par celui du produit
|
||||
// Ecrase $desc par celui du produit
|
||||
// Ecrase $txtva par celui du produit
|
||||
if (! empty($idprod)) {
|
||||
$prod = new Product($db);
|
||||
$prod->fetch($idprod);
|
||||
if ((GETPOST('prod_entry_mode') != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
|
||||
{
|
||||
$productsupplier = new ProductFournisseur($db);
|
||||
|
||||
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 ($idprod > 0)
|
||||
{
|
||||
$res=$productsupplier->fetch($idprod);
|
||||
|
||||
$label = $productsupplier->label;
|
||||
|
||||
$desc = $productsupplier->description;
|
||||
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
|
||||
|
||||
$type = $productsupplier->type;
|
||||
|
||||
$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=$object->addline(
|
||||
$desc,
|
||||
$productsupplier->fourn_pu,
|
||||
$qty,
|
||||
$tva_tx,
|
||||
$localtax1_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');
|
||||
|
||||
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
|
||||
|
||||
// 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
|
||||
//$pu_ht = $prod->price;
|
||||
$pu_ht = price2num($price_ht, 'MU');
|
||||
//$pu_ttc = $prod->price_ttc;
|
||||
$pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU');
|
||||
|
||||
$price_min = $prod->price_min;
|
||||
$price_base_type = $prod->price_base_type;
|
||||
|
||||
// On defini prix unitaire
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level)
|
||||
{
|
||||
$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);
|
||||
|
||||
$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id);
|
||||
|
||||
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$pu_ht = price($prodcustprice->lines [0]->price);
|
||||
$pu_ttc = price($prodcustprice->lines [0]->price_ttc);
|
||||
$price_base_type = $prodcustprice->lines [0]->price_base_type;
|
||||
$prod->tva_tx = $prodcustprice->lines [0]->tva_tx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if price ht is forced (ie: calculated by margin rate and cost price)
|
||||
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
|
||||
// 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 = '';
|
||||
|
||||
// Define output language
|
||||
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if (empty($newlang) && GETPOST('lang_id'))
|
||||
$newlang = GETPOST('lang_id');
|
||||
if (empty($newlang))
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
$desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description;
|
||||
} else {
|
||||
$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');
|
||||
$fk_unit= GETPOST('units', 'alpha');
|
||||
|
||||
$tva_tx = price2num($tva_tx); // When vat is text input field
|
||||
|
||||
// Local Taxes
|
||||
$localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
|
||||
$localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
|
||||
|
||||
if (GETPOST('price_ht')!=='')
|
||||
{
|
||||
$price_base_type = 'HT';
|
||||
$ht = price2num(GETPOST('price_ht'));
|
||||
$ttc = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ttc = price2num(GETPOST('price_ttc'));
|
||||
$ht = $ttc / (1 + ($tva_tx / 100));
|
||||
$price_base_type = 'HT';
|
||||
}
|
||||
|
||||
$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);
|
||||
//$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);
|
||||
}
|
||||
|
||||
// Margin
|
||||
$fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : '');
|
||||
$buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : '');
|
||||
|
||||
// Local Taxes
|
||||
$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) {
|
||||
if (! $error && $result > 0)
|
||||
{
|
||||
$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;
|
||||
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);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model=$object->modelpdf;
|
||||
$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']);
|
||||
@ -712,18 +715,23 @@ if (empty($reshook))
|
||||
unset($_POST['qty']);
|
||||
unset($_POST['type']);
|
||||
unset($_POST['remise_percent']);
|
||||
unset($_POST['pu']);
|
||||
unset($_POST['price_ht']);
|
||||
unset($_POST['multicurrency_price_ht']);
|
||||
unset($_POST['price_ttc']);
|
||||
unset($_POST['tva_tx']);
|
||||
unset($_POST['label']);
|
||||
unset($_POST['product_ref']);
|
||||
unset($_POST['product_label']);
|
||||
unset($_POST['product_desc']);
|
||||
unset($_POST['fournprice']);
|
||||
unset($_POST['buying_price']);
|
||||
unset($localtax1_tx);
|
||||
unset($localtax2_tx);
|
||||
unset($_POST['np_marginRate']);
|
||||
unset($_POST['np_markRate']);
|
||||
unset($_POST['dp_desc']);
|
||||
unset($_POST['idprodfournprice']);
|
||||
unset($_POST['idprod']);
|
||||
|
||||
unset($_POST['date_starthour']);
|
||||
@ -738,12 +746,14 @@ if (empty($reshook))
|
||||
unset($_POST['date_endday']);
|
||||
unset($_POST['date_endmonth']);
|
||||
unset($_POST['date_endyear']);
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -771,7 +781,7 @@ if (empty($reshook))
|
||||
// Extrafields
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline)) {
|
||||
// Get extra fields
|
||||
@ -816,7 +826,7 @@ if (empty($reshook))
|
||||
if (! $error) {
|
||||
$db->begin();
|
||||
$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) {
|
||||
$db->commit();
|
||||
@ -1618,6 +1628,10 @@ if ($action == 'create')
|
||||
|
||||
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))
|
||||
$ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1);
|
||||
|
||||
|
||||
@ -9,7 +9,8 @@
|
||||
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
@ -281,6 +282,7 @@ if ($result)
|
||||
$param='&socid='.$socid.'&viewstatut='.$viewstatut;
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($sall) $param.='&sall='.$sall;
|
||||
if ($month) $param.='&month='.$month;
|
||||
if ($year) $param.='&year='.$year;
|
||||
if ($search_ref) $param.='&search_ref=' .$search_ref;
|
||||
|
||||
@ -92,6 +92,16 @@ if ($id > 0 || ! empty($ref))
|
||||
print "<tr><td>".$langs->trans("Supplier")."</td>";
|
||||
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 dol_print_date($object->date_livraison,'daytext');
|
||||
print '</td>';
|
||||
|
||||
@ -546,8 +546,8 @@ div.myavailability {
|
||||
}
|
||||
.checkallactions {
|
||||
vertical-align: top;
|
||||
margin-top: 6px;
|
||||
margin-left: 4px;
|
||||
margin-top: 6px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.selectlimit {
|
||||
margin-right: 10px !important;
|
||||
@ -945,7 +945,7 @@ $minwidthtmenu=66; /* minimum width for one top menu entry */
|
||||
$heightmenu=46; /* height of top menu, part with image */
|
||||
$heightmenu2=48; /* height of top menu, part with login */
|
||||
$disableimages = 0;
|
||||
$maxwidthloginblock = 110;
|
||||
$maxwidthloginblock = 130;
|
||||
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 {
|
||||
display: inline-block;
|
||||
min-width: 120px;
|
||||
}
|
||||
div.login_block_other {
|
||||
display: inline-block;
|
||||
@ -1406,7 +1407,7 @@ div.login_block_other { padding-top: 3px; text-align: right; }
|
||||
.login_block_elem {
|
||||
float: right;
|
||||
vertical-align: top;
|
||||
padding: 0px 0px 0px 4px !important;
|
||||
padding: 0px 3px 0px 4px !important;
|
||||
height: 16px;
|
||||
}
|
||||
.atoplogin, .atoplogin:hover {
|
||||
@ -2224,7 +2225,7 @@ a.butAction:link, a.butAction:visited, a.butAction:hover, a.butAction:active {
|
||||
}
|
||||
End bootstrap */
|
||||
|
||||
<?php if (! empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { ?>
|
||||
<?php if (! empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (! $user->admin)) { ?>
|
||||
.butActionRefused {
|
||||
display: none;
|
||||
}
|
||||
@ -4512,6 +4513,9 @@ img.demothumb {
|
||||
padding-<?php echo $right; ?>: 78px;
|
||||
<?php } ?>
|
||||
}
|
||||
div.login_block_user {
|
||||
min-width: 0;
|
||||
}
|
||||
div.login_block {
|
||||
top: 2px;
|
||||
<?php if ($disableimages) { ?>
|
||||
@ -4520,6 +4524,9 @@ img.demothumb {
|
||||
max-width: 82px;
|
||||
<?php } ?>
|
||||
}
|
||||
.login_block_elem {
|
||||
padding: 0 !important;
|
||||
}
|
||||
li.tmenu, li.tmenusel {
|
||||
min-width: 32px;
|
||||
}
|
||||
|
||||
@ -263,10 +263,7 @@ if (empty($reshook)) {
|
||||
{
|
||||
$langs->load("errors");
|
||||
$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
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,8 +109,8 @@ else
|
||||
{
|
||||
if (empty($user->id))
|
||||
{
|
||||
echo "User user login: ".$userlogin." does not exists";
|
||||
dol_syslog("User user login:".$userlogin." does not exists", LOG_ERR);
|
||||
echo "User login: ".$userlogin." does not exists";
|
||||
dol_syslog("User login:".$userlogin." does not exists", LOG_ERR);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
@ -124,8 +124,7 @@ if (isset($argv[3]) || $argv[3])
|
||||
$object = new Cronjob($db);
|
||||
|
||||
$filter=array();
|
||||
if (empty($id)) {
|
||||
$filter=array();
|
||||
if (! empty($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 (($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);
|
||||
$result=$cronjob->fetch($line->id);
|
||||
if ($result<0)
|
||||
{
|
||||
echo "Error:".$cronjob->error;
|
||||
dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR);
|
||||
echo "Error cronjob->fetch: ".$cronjob->error;
|
||||
dol_syslog("cron_run_jobs.php::fetch Error ".$cronjob->error, LOG_ERR);
|
||||
exit(-1);
|
||||
}
|
||||
// Execute job
|
||||
$result=$cronjob->run_jobs($userlogin);
|
||||
if ($result<0)
|
||||
{
|
||||
echo "Error:".$cronjob->error;
|
||||
dol_syslog("cron_run_jobs.php:: run_jobs Error".$cronjob->error, LOG_ERR);
|
||||
echo "Error cronjob->run_job: ".$cronjob->error;
|
||||
dol_syslog("cron_run_jobs.php::run_jobs Error ".$cronjob->error, LOG_ERR);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -175,12 +174,16 @@ if(is_array($object->lines) && (count($object->lines)>0))
|
||||
$result=$cronjob->reprogram_jobs($userlogin, $now);
|
||||
if ($result<0)
|
||||
{
|
||||
echo "Error:".$cronjob->error;
|
||||
dol_syslog("cron_run_jobs.php:: reprogram_jobs Error".$cronjob->error, LOG_ERR);
|
||||
echo "Error cronjob->reprogram_job: ".$cronjob->error;
|
||||
dol_syslog("cron_run_jobs.php::reprogram_jobs Error ".$cronjob->error, LOG_ERR);
|
||||
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'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user