Merge remote-tracking branch 'origin/3.7' into develop
Conflicts: htdocs/compta/facture.php htdocs/fourn/class/fournisseur.product.class.php
This commit is contained in:
commit
ef14e4e7ed
@ -302,6 +302,7 @@ if (empty($reshook))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
// Check if we need to also synchronize user information
|
||||
$nosyncuser=0;
|
||||
@ -471,6 +472,7 @@ if (empty($reshook))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
// Check parameters
|
||||
if (empty($morphy) || $morphy == "-1") {
|
||||
|
||||
@ -89,6 +89,7 @@ if ($action == 'add' && $user->rights->adherent->configurer)
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$adht);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if ($adht->libelle)
|
||||
{
|
||||
@ -126,6 +127,7 @@ if ($action == 'update' && $user->rights->adherent->configurer)
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$adht);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
$adht->update($user);
|
||||
|
||||
|
||||
@ -127,6 +127,7 @@ if ($action == 'add' && $user->rights->categorie->creer)
|
||||
if ($parent != "-1") $object->fk_parent = $parent;
|
||||
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! $object->label)
|
||||
{
|
||||
|
||||
@ -90,7 +90,8 @@ if ($action == 'update' && $user->rights->categorie->creer)
|
||||
if (empty($categorie->error))
|
||||
{
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$categorie);
|
||||
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if ($categorie->update($user) > 0)
|
||||
{
|
||||
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$categorie->id.'&type='.$type);
|
||||
|
||||
@ -275,6 +275,7 @@ if ($action == 'add')
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
@ -430,6 +431,7 @@ if ($action == 'update')
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
|
||||
@ -1110,10 +1110,10 @@ if (empty($reshook))
|
||||
// Fill array 'array_options' with data from update form
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
|
||||
if ($ret < 0)
|
||||
$error ++;
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! $error) {
|
||||
if (! $error)
|
||||
{
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// FIXME le hook fait double emploi avec le trigger !!
|
||||
$hookmanager->initHooks(array('propaldao'));
|
||||
|
||||
@ -93,6 +93,8 @@ if ($id > 0 || ! empty($ref)) {
|
||||
$hookmanager->initHooks(array('ordercard','globalcard'));
|
||||
|
||||
$permissionnote = $user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php
|
||||
$permissionedit = $user->rights->commande->creer; // Used by the include of actions_lineupdown.inc.php
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -104,7 +106,11 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once
|
||||
if ($cancel) $action='';
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
|
||||
|
||||
// Action clone object
|
||||
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer)
|
||||
@ -281,8 +287,7 @@ if (empty($reshook))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||
if ($ret < 0)
|
||||
$error ++;
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
@ -375,10 +380,10 @@ if (empty($reshook))
|
||||
} else {
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||
if ($ret < 0)
|
||||
$error ++;
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! $error) {
|
||||
if (! $error)
|
||||
{
|
||||
$object_id = $object->create($user);
|
||||
|
||||
// If some invoice's lines already known
|
||||
@ -1046,56 +1051,7 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Ordonnancement des lignes
|
||||
*/
|
||||
|
||||
else if ($action == 'up' && $user->rights->commande->creer) {
|
||||
$object->line_up(GETPOST('rowid'));
|
||||
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid'));
|
||||
exit();
|
||||
}
|
||||
|
||||
else if ($action == 'down' && $user->rights->commande->creer) {
|
||||
$object->line_down(GETPOST('rowid'));
|
||||
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid'));
|
||||
exit();
|
||||
}
|
||||
|
||||
else if ($action == 'builddoc') // In get or post
|
||||
if ($action == 'builddoc') // In get or post
|
||||
{
|
||||
/*
|
||||
* Generate order document
|
||||
@ -1126,8 +1082,10 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Remove file in doc form
|
||||
else if ($action == 'remove_file') {
|
||||
if ($object->id > 0) {
|
||||
if ($action == 'remove_file')
|
||||
{
|
||||
if ($object->id > 0)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
|
||||
$langs->load("other");
|
||||
@ -1142,14 +1100,15 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == 'update_extras') {
|
||||
if ($action == 'update_extras')
|
||||
{
|
||||
// Fill array 'array_options' with data from update form
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
|
||||
if ($ret < 0)
|
||||
$error ++;
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! $error) {
|
||||
if (! $error)
|
||||
{
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// FIXME le hook fait double emploi avec le trigger !!
|
||||
$hookmanager->initHooks(array('orderdao'));
|
||||
|
||||
@ -1092,8 +1092,8 @@ class Commande extends CommonOrder
|
||||
* @param int $fk_remise_except Id remise
|
||||
* @param string $price_base_type HT or TTC
|
||||
* @param float $pu_ttc Prix unitaire TTC
|
||||
* @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
||||
* @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
||||
* @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
||||
* @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
||||
* @param int $type Type of line (0=product, 1=service)
|
||||
* @param int $rang Position of line
|
||||
* @param int $special_code Special code (also used by externals modules!)
|
||||
|
||||
@ -646,7 +646,7 @@ if (empty($reshook))
|
||||
// Fill array 'array_options' with data from add form
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||
if ($ret < 0) $error ++;
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
// Replacement invoice
|
||||
if ($_POST['type'] == Facture::TYPE_REPLACEMENT)
|
||||
@ -1788,8 +1788,7 @@ if (empty($reshook))
|
||||
// Fill array 'array_options' with data from add form
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
|
||||
if ($ret < 0)
|
||||
$error ++;
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! $error) {
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
|
||||
@ -200,6 +200,7 @@ if (empty($reshook))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! GETPOST("lastname"))
|
||||
{
|
||||
@ -303,6 +304,7 @@ if (empty($reshook))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
$result = $object->update($contactid, $user);
|
||||
|
||||
|
||||
@ -359,6 +359,7 @@ if ($action == 'add' && $user->rights->contrat->creer)
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
$result = $object->create($user);
|
||||
if ($result > 0)
|
||||
@ -725,19 +726,20 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra
|
||||
// Fill array 'array_options' with data from update form
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
|
||||
if ($ret < 0)
|
||||
$error ++;
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! $error) {
|
||||
if (! $error)
|
||||
{
|
||||
$result = $object->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else if ($reshook < 0) $error++;
|
||||
|
||||
$result = $object->insertExtraFields();
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
}
|
||||
} else if ($reshook < 0)
|
||||
$error ++;
|
||||
|
||||
if ($error) {
|
||||
if ($error)
|
||||
{
|
||||
$action = 'edit_extras';
|
||||
setEventMessage($object->error,'errors');
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
|
||||
// $action must be defined
|
||||
// $permission must be defined to permission to edit object
|
||||
// $permissionnote must be defined to permission to edit object
|
||||
// $object must be defined (object is loaded in this file with fetch)
|
||||
// $id must be defined (object is loaded in this file with fetch)
|
||||
|
||||
|
||||
@ -2568,9 +2568,10 @@ abstract class CommonObject
|
||||
* @param string $buyer Object of buyer third party
|
||||
* @param string $selected Object line selected
|
||||
* @param int $dateSelector 1=Show also date range input fields
|
||||
* @param int $permtoedit Permission to edit line
|
||||
* @return void
|
||||
*/
|
||||
function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0)
|
||||
function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0, $permtoedit=0)
|
||||
{
|
||||
global $conf, $hookmanager, $inputalsopricewithtax, $usermargins, $langs, $user;
|
||||
|
||||
@ -2659,7 +2660,7 @@ abstract class CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline);
|
||||
$this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline,$permtoedit);
|
||||
}
|
||||
|
||||
$i++;
|
||||
@ -2680,9 +2681,10 @@ abstract class CommonObject
|
||||
* @param string $buyer Object of buyer third party
|
||||
* @param string $selected Object line selected
|
||||
* @param object $extrafieldsline Object of extrafield line attribute
|
||||
* @param int $permtoedit Permission to edit
|
||||
* @return void
|
||||
*/
|
||||
function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0)
|
||||
function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0,$permtoedit=0)
|
||||
{
|
||||
global $conf,$langs,$user,$object,$hookmanager;
|
||||
global $form,$bc,$bcdd;
|
||||
@ -3502,7 +3504,8 @@ abstract class CommonObject
|
||||
|
||||
/**
|
||||
* Add/Update all extra fields values for the current object.
|
||||
* All data to describe values to insert are stored into $this->array_options=array('keyextrafield'=>'valueextrafieldtoadd')
|
||||
* Data to describe values to insert/update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
|
||||
* This function delte record with all extrafields and insert them again from the array $this->array_options.
|
||||
*
|
||||
* @return int -1=error, O=did nothing, 1=OK
|
||||
*/
|
||||
|
||||
@ -1264,7 +1264,7 @@ class ExtraFields
|
||||
* @param array $extralabels $array of extrafields
|
||||
* @param object $object Object
|
||||
* @param string $onlykey Only following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must must set this to avoid to have other extrafields being reset.
|
||||
* @return int 1 if array_options set / 0 if no value
|
||||
* @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example)
|
||||
*/
|
||||
function setOptionalsFromPost($extralabels,&$object,$onlykey='')
|
||||
{
|
||||
|
||||
@ -25,6 +25,8 @@
|
||||
* $langs
|
||||
* $dateSelector
|
||||
* $forceall (0 by default, 1 for supplier invoices/orders)
|
||||
* $element (used to test $user->rights->$element->creer)
|
||||
* $permtoedit (used to replace test $user->rights->$element->creer)
|
||||
* $senderissupplier (0 by default, 1 for supplier invoices/orders)
|
||||
* $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
|
||||
* $usemargins (0 to disable all margins columns, 1 to show according to margin setup)
|
||||
@ -167,7 +169,7 @@ if (empty($usemargins)) $usemargins=0;
|
||||
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo price($line->total_ht); ?></td>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->statut == 0 && $user->rights->$element->creer) { ?>
|
||||
<?php if ($this->statut == 0 && ($user->rights->$element->creer || $permtoedit)) { ?>
|
||||
<td align="center"><?php $coldisplay++; ?>
|
||||
<?php if (($line->info_bits & 2) == 2) { ?>
|
||||
<?php } else { ?>
|
||||
|
||||
@ -214,13 +214,13 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql.= " l.qty,";
|
||||
$sql.= " l.tva_tx, l.remise_percent, l.subprice,";
|
||||
$sql.= " l.localtax1_tx, l. localtax2_tx, l.total_localtax1, l.total_localtax2,";
|
||||
$sql.= " l.total_ht, l.total_tva, l.total_ttc,";
|
||||
$sql.= " l.total_ht, l.total_tva, l.total_ttc, l.special_code, l.fk_parent_line, l.rang,";
|
||||
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,";
|
||||
$sql.= " l.date_start, l.date_end";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||
$sql.= " WHERE l.fk_commande = ".$this->id;
|
||||
$sql.= " ORDER BY l.rowid";
|
||||
$sql.= " ORDER BY l.rang, l.rowid";
|
||||
//print $sql;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch get lines", LOG_DEBUG);
|
||||
@ -267,6 +267,11 @@ class CommandeFournisseur extends CommonOrder
|
||||
$line->date_start = $this->db->jdate($objp->date_start);
|
||||
$line->date_end = $this->db->jdate($objp->date_end);
|
||||
|
||||
$this->special_line = $objp->special_line;
|
||||
$this->fk_parent_line = $objp->fk_parent_line;
|
||||
|
||||
$this->rang = $objp->rang;
|
||||
|
||||
$this->lines[$i] = $line;
|
||||
|
||||
$i++;
|
||||
@ -1117,9 +1122,10 @@ class CommandeFournisseur extends CommonOrder
|
||||
* @param bool $notrigger Disable triggers
|
||||
* @param int $date_start Date start of service
|
||||
* @param int $date_end Date end of service
|
||||
* @param array $array_option extrafields array
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null)
|
||||
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_option=0)
|
||||
{
|
||||
global $langs,$mysoc;
|
||||
|
||||
@ -1759,23 +1765,24 @@ class CommandeFournisseur extends CommonOrder
|
||||
/**
|
||||
* Update line
|
||||
*
|
||||
* @param int $rowid Id de la ligne de facture
|
||||
* @param string $desc Description de la ligne
|
||||
* @param double $pu Prix unitaire
|
||||
* @param double $qty Quantity
|
||||
* @param double $remise_percent Pourcentage de remise de la ligne
|
||||
* @param double $txtva Taux TVA
|
||||
* @param double $txlocaltax1 Localtax1 tax
|
||||
* @param double $txlocaltax2 Localtax2 tax
|
||||
* @param double $price_base_type Type of price base
|
||||
* @param int $info_bits Miscellaneous informations
|
||||
* @param int $type Type of line (0=product, 1=service)
|
||||
* @param int $notrigger Disable triggers
|
||||
* @param timestamp $date_start Date start of service
|
||||
* @param timestamp $date_end Date end of service
|
||||
* @return int < 0 if error, > 0 if ok
|
||||
* @param int $rowid Id de la ligne de facture
|
||||
* @param string $desc Description de la ligne
|
||||
* @param double $pu Prix unitaire
|
||||
* @param double $qty Quantity
|
||||
* @param double $remise_percent Pourcentage de remise de la ligne
|
||||
* @param double $txtva Taux TVA
|
||||
* @param double $txlocaltax1 Localtax1 tax
|
||||
* @param double $txlocaltax2 Localtax2 tax
|
||||
* @param double $price_base_type Type of price base
|
||||
* @param int $info_bits Miscellaneous informations
|
||||
* @param int $type Type of line (0=product, 1=service)
|
||||
* @param int $notrigger Disable triggers
|
||||
* @param timestamp $date_start Date start of service
|
||||
* @param timestamp $date_end Date end of service
|
||||
* @param array $array_option extrafields array
|
||||
* @return int < 0 if error, > 0 if ok
|
||||
*/
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='')
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_option=0)
|
||||
{
|
||||
global $mysoc;
|
||||
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type");
|
||||
@ -2167,6 +2174,14 @@ class CommandeFournisseur extends CommonOrder
|
||||
*/
|
||||
class CommandeFournisseurLigne extends CommonOrderLine
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
|
||||
public $element='commande_fournisseurdet';
|
||||
public $table_element='commande_fournisseurdet';
|
||||
|
||||
var $oldline;
|
||||
|
||||
// From llx_commandedet
|
||||
var $qty;
|
||||
var $tva_tx;
|
||||
|
||||
@ -450,7 +450,7 @@ class FactureFournisseur extends CommonInvoice
|
||||
$result=$this->fetch_lines();
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error=$this->db->lasterror();
|
||||
return -3;
|
||||
}
|
||||
|
||||
@ -482,11 +482,12 @@ class FactureFournisseur extends CommonInvoice
|
||||
{
|
||||
$sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx, f.tva';
|
||||
$sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 ';
|
||||
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits';
|
||||
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line';
|
||||
$sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid';
|
||||
$sql.= ' WHERE fk_facture_fourn='.$this->id;
|
||||
$sql.= ' ORDER BY f.rang, f.rowid';
|
||||
|
||||
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
|
||||
$resql_rows = $this->db->query($sql);
|
||||
@ -500,7 +501,9 @@ class FactureFournisseur extends CommonInvoice
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql_rows);
|
||||
|
||||
$this->lines[$i] = new stdClass();
|
||||
$this->lines[$i] = new FactureFournisseurLigne($this->db);
|
||||
|
||||
$this->lines[$i]->id = $obj->rowid;
|
||||
$this->lines[$i]->rowid = $obj->rowid;
|
||||
$this->lines[$i]->description = $obj->description;
|
||||
$this->lines[$i]->product_ref = $obj->product_ref; // Internal reference
|
||||
@ -523,7 +526,10 @@ class FactureFournisseur extends CommonInvoice
|
||||
$this->lines[$i]->total_ttc = $obj->total_ttc;
|
||||
$this->lines[$i]->fk_product = $obj->fk_product;
|
||||
$this->lines[$i]->product_type = $obj->product_type;
|
||||
$this->lines[$i]->info_bits = $obj->info_bits;
|
||||
$this->lines[$i]->info_bits = $obj->info_bits;
|
||||
$this->lines[$i]->fk_parent_line = $obj->fk_parent_line;
|
||||
$this->lines[$i]->special_code = $obj->special_code;
|
||||
$this->lines[$i]->rang = $obj->rang;
|
||||
|
||||
$i++;
|
||||
}
|
||||
@ -1109,11 +1115,12 @@ class FactureFournisseur extends CommonInvoice
|
||||
* @param int $type Type of line (0=product, 1=service)
|
||||
* @param int $rang Position of line
|
||||
* @param int $notrigger Disable triggers
|
||||
* @param array $array_option extrafields array
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*
|
||||
* FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order.
|
||||
*/
|
||||
function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false)
|
||||
function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_option=0)
|
||||
{
|
||||
dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type", LOG_DEBUG);
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
@ -1189,22 +1196,25 @@ class FactureFournisseur extends CommonInvoice
|
||||
/**
|
||||
* Update a line detail into database
|
||||
*
|
||||
* @param int $id Id of line invoice
|
||||
* @param string $desc Description of line
|
||||
* @param double $pu Prix unitaire (HT ou TTC selon price_base_type)
|
||||
* @param double $vatrate VAT Rate
|
||||
* @param double $txlocaltax1 LocalTax1 Rate
|
||||
* @param double $txlocaltax2 LocalTax2 Rate
|
||||
* @param double $qty Quantity
|
||||
* @param int $idproduct Id produit
|
||||
* @param double $price_base_type HT or TTC
|
||||
* @param int $info_bits Miscellaneous informations of line
|
||||
* @param int $type Type of line (0=product, 1=service)
|
||||
* @param double $remise_percent Pourcentage de remise de la ligne
|
||||
* @param int $notrigger Disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param int $id Id of line invoice
|
||||
* @param string $desc Description of line
|
||||
* @param double $pu Prix unitaire (HT ou TTC selon price_base_type)
|
||||
* @param double $vatrate VAT Rate
|
||||
* @param double $txlocaltax1 LocalTax1 Rate
|
||||
* @param double $txlocaltax2 LocalTax2 Rate
|
||||
* @param double $qty Quantity
|
||||
* @param int $idproduct Id produit
|
||||
* @param double $price_base_type HT or TTC
|
||||
* @param int $info_bits Miscellaneous informations of line
|
||||
* @param int $type Type of line (0=product, 1=service)
|
||||
* @param double $remise_percent Pourcentage de remise de la ligne
|
||||
* @param int $notrigger Disable triggers
|
||||
* @param timestamp $date_start Date start of service
|
||||
* @param timestamp $date_end Date end of service
|
||||
* @param array $array_option extrafields array
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false)
|
||||
function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_option=0)
|
||||
{
|
||||
global $mysoc;
|
||||
dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG);
|
||||
@ -1820,8 +1830,25 @@ class FactureFournisseur extends CommonInvoice
|
||||
/**
|
||||
* Class to manage line invoices
|
||||
*/
|
||||
class FactureFournisseurLigne extends CommonInvoiceLine
|
||||
class FactureFournisseurLigne extends CommonInvoice
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
|
||||
public $element='facture_fourn_det';
|
||||
public $table_element='facture_fourn_det';
|
||||
|
||||
var $oldline;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db= $db;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -485,14 +485,20 @@ class ProductFournisseur extends Product
|
||||
/**
|
||||
* Load properties for minimum price
|
||||
*
|
||||
* @param int $prodid Product id
|
||||
* @param int $qty Minimum quantity
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param int $prodid Product id
|
||||
* @param int $qty Minimum quantity
|
||||
* @return int <0 if KO, 0=Not found of no product id provided, >0 if OK
|
||||
*/
|
||||
function find_min_price_product_fournisseur($prodid, $qty=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if (empty($prodid))
|
||||
{
|
||||
dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->product_fourn_price_id = '';
|
||||
$this->product_fourn_id = '';
|
||||
$this->fourn_ref = '';
|
||||
@ -582,7 +588,7 @@ class ProductFournisseur extends Product
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -219,3 +219,11 @@ create table llx_facture_fourn_det_extrafields
|
||||
|
||||
ALTER TABLE llx_facture_fourn_det_extrafields ADD INDEX idx_facture_fourn_det_extrafields (fk_object);
|
||||
|
||||
ALTER TABLE llx_facture_fourn_det ADD COLUMN special_code integer DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn_det ADD COLUMN rang integer DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn_det ADD COLUMN fk_parent_line integer NULL after fk_facture_fourn;
|
||||
|
||||
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN special_code integer DEFAULT 0;
|
||||
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN rang integer DEFAULT 0;
|
||||
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN fk_parent_line integer NULL after fk_commande;
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ create table llx_commande_fournisseurdet
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_commande integer NOT NULL,
|
||||
fk_parent_line integer NULL,
|
||||
fk_product integer,
|
||||
ref varchar(50), -- supplier product ref
|
||||
label varchar(255), -- product label
|
||||
@ -44,5 +45,7 @@ create table llx_commande_fournisseurdet
|
||||
date_start datetime DEFAULT NULL, -- date debut si service
|
||||
date_end datetime DEFAULT NULL, -- date fin si service
|
||||
info_bits integer DEFAULT 0, -- TVA NPR ou non
|
||||
special_code integer DEFAULT 0, -- code pour les lignes speciales
|
||||
rang integer DEFAULT 0,
|
||||
import_key varchar(14)
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -22,9 +22,9 @@
|
||||
create table llx_commandedet
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_commande integer NOT NULL,
|
||||
fk_parent_line integer NULL,
|
||||
fk_product integer NULL,
|
||||
fk_commande integer NOT NULL,
|
||||
fk_parent_line integer NULL,
|
||||
fk_product integer NULL,
|
||||
label varchar(255) DEFAULT NULL,
|
||||
description text,
|
||||
tva_tx double(6,3), -- vat rate
|
||||
@ -51,7 +51,7 @@ create table llx_commandedet
|
||||
buy_price_ht double(24,8) DEFAULT 0, -- buying price
|
||||
fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created)
|
||||
|
||||
special_code integer UNSIGNED DEFAULT 0, -- code pour les lignes speciales
|
||||
special_code integer DEFAULT 0, -- code pour les lignes speciales
|
||||
rang integer DEFAULT 0,
|
||||
import_key varchar(14)
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -22,6 +22,7 @@ create table llx_facture_fourn_det
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_facture_fourn integer NOT NULL,
|
||||
fk_parent_line integer NULL,
|
||||
fk_product integer NULL,
|
||||
ref varchar(50), -- supplier product ref
|
||||
label varchar(255), -- product label
|
||||
@ -45,5 +46,7 @@ create table llx_facture_fourn_det
|
||||
date_end datetime DEFAULT NULL, -- date fin si service
|
||||
info_bits integer DEFAULT 0, -- TVA NPR ou non
|
||||
fk_code_ventilation integer DEFAULT 0 NOT NULL,
|
||||
special_code integer DEFAULT 0, -- code pour les lignes speciales
|
||||
rang integer DEFAULT 0,
|
||||
import_key varchar(14)
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -262,8 +262,12 @@ if (empty($reshook))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
$id = $object->create($user);
|
||||
if (! $error)
|
||||
{
|
||||
$id = $object->create($user);
|
||||
}
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
@ -339,8 +343,9 @@ if (empty($reshook))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if ($object->check())
|
||||
if (! $error && $object->check())
|
||||
{
|
||||
if ($object->update($object->id, $user) > 0)
|
||||
{
|
||||
|
||||
@ -148,6 +148,7 @@ if (empty($reshook))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
$result = $object->create($user);
|
||||
if ($result > 0)
|
||||
@ -224,10 +225,7 @@ if (empty($reshook))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
if ($ret < 0) $error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
|
||||
@ -91,12 +91,15 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
$result=$object->update($user);
|
||||
|
||||
if ($result < 0)
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessages($object->error,$object->errors,'errors');
|
||||
$result=$object->update($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($object->error,$object->errors,'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -250,6 +250,7 @@ if ($action == 'add')
|
||||
// Fill array 'array_options' with data from add form
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($adh->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$adh);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
$result=$adh->create($user);
|
||||
if ($result > 0)
|
||||
|
||||
@ -193,7 +193,7 @@ if (empty($reshook))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (GETPOST('deletephoto')) $object->logo = '';
|
||||
else if (! empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
|
||||
@ -211,6 +211,7 @@ if ($action == 'add' && $canadduser)
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
// Set entity of new user
|
||||
$entity=GETPOST('entity','int');
|
||||
@ -361,6 +362,7 @@ if ($action == 'update' && ! $_POST["cancel"])
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
@ -385,20 +387,22 @@ if ($action == 'update' && ! $_POST["cancel"])
|
||||
if (GETPOST('deletephoto')) $object->photo='';
|
||||
if (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
|
||||
$ret=$object->update($user);
|
||||
|
||||
if ($ret < 0)
|
||||
if (! $error)
|
||||
{
|
||||
$error++;
|
||||
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessage($langs->trans("ErrorLoginAlreadyExists",$object->login), 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($object->error, 'errors');
|
||||
}
|
||||
$ret=$object->update($user);
|
||||
if ($ret < 0)
|
||||
{
|
||||
$error++;
|
||||
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessage($langs->trans("ErrorLoginAlreadyExists",$object->login), 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($object->error, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error && isset($_POST['contactid']))
|
||||
|
||||
@ -101,6 +101,7 @@ if ($action == 'add')
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $object->entity = 0;
|
||||
else $object->entity = $_POST["entity"];
|
||||
@ -183,6 +184,7 @@ if ($action == 'update')
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $object->entity = 0;
|
||||
else $object->entity = $_POST["entity"];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user