Rewrite code for supplier order and invoice to use shared code of
customer supplier and invoice. Work on extrafield for supplier order and invoice.
This commit is contained in:
parent
ef14e4e7ed
commit
8e26c71fa7
@ -435,12 +435,12 @@ if (empty($reshook))
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) {
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) {
|
||||||
$lines[$i]->fetch_optionals($lines[$i]->rowid);
|
$lines[$i]->fetch_optionals($lines[$i]->rowid);
|
||||||
$array_option = $lines[$i]->array_options;
|
$array_options = $lines[$i]->array_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tva_tx=get_default_tva($mysoc, $object->thirdparty);
|
$tva_tx=get_default_tva($mysoc, $object->thirdparty);
|
||||||
|
|
||||||
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $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, $date_start, $date_end, $array_option);
|
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $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, $date_start, $date_end, $array_options);
|
||||||
|
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$lineid = $result;
|
$lineid = $result;
|
||||||
@ -652,7 +652,7 @@ if (empty($reshook))
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||||
// Unset extrafield
|
// Unset extrafield
|
||||||
if (is_array($extralabelsline)) {
|
if (is_array($extralabelsline)) {
|
||||||
// Get extra fields
|
// Get extra fields
|
||||||
@ -812,7 +812,7 @@ if (empty($reshook))
|
|||||||
setEventMessage($mesg, 'errors');
|
setEventMessage($mesg, 'errors');
|
||||||
} else {
|
} else {
|
||||||
// Insert line
|
// Insert line
|
||||||
$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, $date_start, $date_end, $array_option);
|
$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, $date_start, $date_end, $array_options);
|
||||||
|
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$db->commit();
|
$db->commit();
|
||||||
@ -895,7 +895,7 @@ if (empty($reshook))
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||||
// Unset extrafield
|
// Unset extrafield
|
||||||
if (is_array($extralabelsline)) {
|
if (is_array($extralabelsline)) {
|
||||||
// Get extra fields
|
// Get extra fields
|
||||||
@ -940,7 +940,7 @@ if (empty($reshook))
|
|||||||
if (! $error) {
|
if (! $error) {
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$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, $date_start, $date_end, $array_option);
|
$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, $date_start, $date_end, $array_options);
|
||||||
|
|
||||||
if ($result >= 0) {
|
if ($result >= 0) {
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
|||||||
@ -314,12 +314,12 @@ class Propal extends CommonObject
|
|||||||
* @param string $label ???
|
* @param string $label ???
|
||||||
* @param int $date_start Start date of the line
|
* @param int $date_start Start date of the line
|
||||||
* @param int $date_end End date of the line
|
* @param int $date_end End date of the line
|
||||||
* @param array $array_option extrafields array
|
* @param array $array_options extrafields array
|
||||||
* @return int >0 if OK, <0 if KO
|
* @return int >0 if OK, <0 if KO
|
||||||
*
|
*
|
||||||
* @see add_product
|
* @see add_product
|
||||||
*/
|
*/
|
||||||
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_option=0)
|
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0)
|
||||||
{
|
{
|
||||||
global $mysoc;
|
global $mysoc;
|
||||||
|
|
||||||
@ -440,8 +440,8 @@ class Propal extends CommonObject
|
|||||||
$this->line->price=$price;
|
$this->line->price=$price;
|
||||||
$this->line->remise=$remise;
|
$this->line->remise=$remise;
|
||||||
|
|
||||||
if (is_array($array_option) && count($array_option)>0) {
|
if (is_array($array_options) && count($array_options)>0) {
|
||||||
$this->line->array_options=$array_option;
|
$this->line->array_options=$array_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=$this->line->insert();
|
$result=$this->line->insert();
|
||||||
@ -496,10 +496,10 @@ class Propal extends CommonObject
|
|||||||
* @param int $type 0/1=Product/service
|
* @param int $type 0/1=Product/service
|
||||||
* @param int $date_start Start date of the line
|
* @param int $date_start Start date of the line
|
||||||
* @param int $date_end End date of the line
|
* @param int $date_end End date of the line
|
||||||
* @param array $array_option extrafields array
|
* @param array $array_options extrafields array
|
||||||
* @return int 0 if OK, <0 if KO
|
* @return int 0 if OK, <0 if KO
|
||||||
*/
|
*/
|
||||||
function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_option=0)
|
function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_options=0)
|
||||||
{
|
{
|
||||||
global $mysoc;
|
global $mysoc;
|
||||||
|
|
||||||
@ -601,8 +601,8 @@ class Propal extends CommonObject
|
|||||||
$this->line->price=$price;
|
$this->line->price=$price;
|
||||||
$this->line->remise=$remise;
|
$this->line->remise=$remise;
|
||||||
|
|
||||||
if (is_array($array_option) && count($array_option)>0) {
|
if (is_array($array_options) && count($array_options)>0) {
|
||||||
$this->line->array_options=$array_option;
|
$this->line->array_options=$array_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=$this->line->update();
|
$result=$this->line->update();
|
||||||
|
|||||||
@ -343,10 +343,10 @@ if (empty($reshook))
|
|||||||
// trigger used
|
// trigger used
|
||||||
{
|
{
|
||||||
$lines[$i]->fetch_optionals($lines[$i]->rowid);
|
$lines[$i]->fetch_optionals($lines[$i]->rowid);
|
||||||
$array_option = $lines[$i]->array_options;
|
$array_options = $lines[$i]->array_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $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, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options);
|
||||||
|
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error ++;
|
||||||
@ -561,7 +561,7 @@ if (empty($reshook))
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||||
// Unset extrafield
|
// Unset extrafield
|
||||||
if (is_array($extralabelsline)) {
|
if (is_array($extralabelsline)) {
|
||||||
// Get extra fields
|
// Get extra fields
|
||||||
@ -734,7 +734,7 @@ if (empty($reshook))
|
|||||||
setEventMessage($mesg, 'errors');
|
setEventMessage($mesg, 'errors');
|
||||||
} else {
|
} else {
|
||||||
// Insert line
|
// Insert line
|
||||||
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option);
|
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options);
|
||||||
|
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$ret = $object->fetch($object->id); // Reload to get new records
|
$ret = $object->fetch($object->id); // Reload to get new records
|
||||||
@ -821,7 +821,7 @@ if (empty($reshook))
|
|||||||
// Extrafields Lines
|
// Extrafields Lines
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||||
// Unset extrafield POST Data
|
// Unset extrafield POST Data
|
||||||
if (is_array($extralabelsline)) {
|
if (is_array($extralabelsline)) {
|
||||||
foreach ($extralabelsline as $key => $value) {
|
foreach ($extralabelsline as $key => $value) {
|
||||||
@ -859,7 +859,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! $error) {
|
if (! $error) {
|
||||||
$result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option);
|
$result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_options);
|
||||||
|
|
||||||
if ($result >= 0) {
|
if ($result >= 0) {
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||||
@ -1687,9 +1687,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1);
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Confirmation to delete line
|
||||||
* Confirmation de la suppression d'une ligne produit
|
|
||||||
*/
|
|
||||||
if ($action == 'ask_deleteline')
|
if ($action == 'ask_deleteline')
|
||||||
{
|
{
|
||||||
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1);
|
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1);
|
||||||
|
|||||||
@ -1101,7 +1101,7 @@ class Commande extends CommonOrder
|
|||||||
* @param int $fk_fournprice Id supplier price
|
* @param int $fk_fournprice Id supplier price
|
||||||
* @param int $pa_ht Buying price (without tax)
|
* @param int $pa_ht Buying price (without tax)
|
||||||
* @param string $label Label
|
* @param string $label Label
|
||||||
* @param array $array_option extrafields array
|
* @param array $array_options extrafields array
|
||||||
* @return int >0 if OK, <0 if KO
|
* @return int >0 if OK, <0 if KO
|
||||||
*
|
*
|
||||||
* @see add_product
|
* @see add_product
|
||||||
@ -1111,7 +1111,7 @@ class Commande extends CommonOrder
|
|||||||
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
|
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
|
||||||
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
||||||
*/
|
*/
|
||||||
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_option=0)
|
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0)
|
||||||
{
|
{
|
||||||
global $mysoc, $conf, $langs;
|
global $mysoc, $conf, $langs;
|
||||||
|
|
||||||
@ -1250,8 +1250,8 @@ class Commande extends CommonOrder
|
|||||||
$this->line->price=$price;
|
$this->line->price=$price;
|
||||||
$this->line->remise=$remise;
|
$this->line->remise=$remise;
|
||||||
|
|
||||||
if (is_array($array_option) && count($array_option)>0) {
|
if (is_array($array_options) && count($array_options)>0) {
|
||||||
$this->line->array_options=$array_option;
|
$this->line->array_options=$array_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=$this->line->insert();
|
$result=$this->line->insert();
|
||||||
@ -2346,10 +2346,10 @@ class Commande extends CommonOrder
|
|||||||
* @param int $pa_ht Price (without tax) of product when it was bought
|
* @param int $pa_ht Price (without tax) of product when it was bought
|
||||||
* @param string $label Label
|
* @param string $label Label
|
||||||
* @param int $special_code Special code (also used by externals modules!)
|
* @param int $special_code Special code (also used by externals modules!)
|
||||||
* @param array $array_option extrafields array
|
* @param array $array_options extrafields array
|
||||||
* @return int < 0 if KO, > 0 if OK
|
* @return int < 0 if KO, > 0 if OK
|
||||||
*/
|
*/
|
||||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_option=0)
|
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0)
|
||||||
{
|
{
|
||||||
global $conf, $mysoc;
|
global $conf, $mysoc;
|
||||||
|
|
||||||
@ -2458,8 +2458,8 @@ class Commande extends CommonOrder
|
|||||||
$this->line->price=$price;
|
$this->line->price=$price;
|
||||||
$this->line->remise=$remise;
|
$this->line->remise=$remise;
|
||||||
|
|
||||||
if (is_array($array_option) && count($array_option)>0) {
|
if (is_array($array_options) && count($array_options)>0) {
|
||||||
$this->line->array_options=$array_option;
|
$this->line->array_options=$array_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=$this->line->update();
|
$result=$this->line->update();
|
||||||
@ -3516,7 +3516,7 @@ class OrderLine extends CommonOrderLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $notrigger)
|
if (! $error && ! $notrigger)
|
||||||
{
|
{
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result=$this->call_trigger('LINEORDER_INSERT',$user);
|
$result=$this->call_trigger('LINEORDER_INSERT',$user);
|
||||||
|
|||||||
@ -1061,10 +1061,10 @@ if (empty($reshook))
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) {
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) {
|
||||||
$lines[$i]->fetch_optionals($lines[$i]->rowid);
|
$lines[$i]->fetch_optionals($lines[$i]->rowid);
|
||||||
$array_option = $lines[$i]->array_options;
|
$array_options = $lines[$i]->array_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_option, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id);
|
$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, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id);
|
||||||
|
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$lineid = $result;
|
$lineid = $result;
|
||||||
@ -1196,7 +1196,7 @@ if (empty($reshook))
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||||
// Unset extrafield
|
// Unset extrafield
|
||||||
if (is_array($extralabelsline)) {
|
if (is_array($extralabelsline)) {
|
||||||
// Get extra fields
|
// Get extra fields
|
||||||
@ -1374,7 +1374,7 @@ if (empty($reshook))
|
|||||||
setEventMessage($mesg, 'errors');
|
setEventMessage($mesg, 'errors');
|
||||||
} else {
|
} else {
|
||||||
// Insert line
|
// Insert line
|
||||||
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option, $_POST['progress']);
|
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress']);
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
@ -1469,7 +1469,7 @@ if (empty($reshook))
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||||
// Unset extrafield
|
// Unset extrafield
|
||||||
if (is_array($extralabelsline)) {
|
if (is_array($extralabelsline)) {
|
||||||
// Get extra fields
|
// Get extra fields
|
||||||
@ -1528,7 +1528,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
// Update line
|
// Update line
|
||||||
if (! $error) {
|
if (! $error) {
|
||||||
$result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option, GETPOST('progress'));
|
$result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_options, GETPOST('progress'));
|
||||||
|
|
||||||
if ($result >= 0) {
|
if ($result >= 0) {
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||||
|
|||||||
@ -2034,12 +2034,12 @@ class Facture extends CommonInvoice
|
|||||||
* @param int $fk_fournprice Supplier price id (to calculate margin) or ''
|
* @param int $fk_fournprice Supplier price id (to calculate margin) or ''
|
||||||
* @param int $pa_ht Buying price of line (to calculate margin) or ''
|
* @param int $pa_ht Buying price of line (to calculate margin) or ''
|
||||||
* @param string $label Label of the line (deprecated, do not use)
|
* @param string $label Label of the line (deprecated, do not use)
|
||||||
* @param array $array_option extrafields array
|
* @param array $array_options extrafields array
|
||||||
* @param int $situation_percent Situation advance percentage
|
* @param int $situation_percent Situation advance percentage
|
||||||
* @param int $fk_prev_id Previous situation line id reference
|
* @param int $fk_prev_id Previous situation line id reference
|
||||||
* @return int <0 if KO, Id of line if OK
|
* @return int <0 if KO, Id of line if OK
|
||||||
*/
|
*/
|
||||||
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_option=0, $situation_percent=100, $fk_prev_id='')
|
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id='')
|
||||||
{
|
{
|
||||||
global $mysoc, $conf, $langs;
|
global $mysoc, $conf, $langs;
|
||||||
|
|
||||||
@ -2162,8 +2162,8 @@ class Facture extends CommonInvoice
|
|||||||
$this->line->fk_fournprice = $fk_fournprice;
|
$this->line->fk_fournprice = $fk_fournprice;
|
||||||
$this->line->pa_ht = $pa_ht;
|
$this->line->pa_ht = $pa_ht;
|
||||||
|
|
||||||
if (is_array($array_option) && count($array_option)>0) {
|
if (is_array($array_options) && count($array_options)>0) {
|
||||||
$this->line->array_options=$array_option;
|
$this->line->array_options=$array_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=$this->line->insert();
|
$result=$this->line->insert();
|
||||||
@ -2217,11 +2217,11 @@ class Facture extends CommonInvoice
|
|||||||
* @param int $pa_ht Price (without tax) of product when it was bought
|
* @param int $pa_ht Price (without tax) of product when it was bought
|
||||||
* @param string $label Label of the line (deprecated, do not use)
|
* @param string $label Label of the line (deprecated, do not use)
|
||||||
* @param int $special_code Special code (also used by externals modules!)
|
* @param int $special_code Special code (also used by externals modules!)
|
||||||
* @param array $array_option extrafields array
|
* @param array $array_options extrafields array
|
||||||
* @param int $situation_percent Situation advance percentage
|
* @param int $situation_percent Situation advance percentage
|
||||||
* @return int < 0 if KO, > 0 if OK
|
* @return int < 0 if KO, > 0 if OK
|
||||||
*/
|
*/
|
||||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_option=0, $situation_percent=0)
|
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0)
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||||
|
|
||||||
@ -2322,8 +2322,8 @@ class Facture extends CommonInvoice
|
|||||||
}
|
}
|
||||||
$this->line->pa_ht = $pa_ht;
|
$this->line->pa_ht = $pa_ht;
|
||||||
|
|
||||||
if (is_array($array_option) && count($array_option)>0) {
|
if (is_array($array_options) && count($array_options)>0) {
|
||||||
$this->line->array_options=$array_option;
|
$this->line->array_options=$array_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=$this->line->update();
|
$result=$this->line->update();
|
||||||
|
|||||||
@ -84,7 +84,7 @@ if ($id > 0 || ! empty($ref)) {
|
|||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
|
|
||||||
// fetch optionals attributes lines and labels
|
// fetch optionals attributes lines and labels
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||||
// Unset extrafield
|
// Unset extrafield
|
||||||
if (is_array($extralabelsline)) {
|
if (is_array($extralabelsline)) {
|
||||||
// Get extra fields
|
// Get extra fields
|
||||||
@ -538,7 +538,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
|
|||||||
$info_bits,
|
$info_bits,
|
||||||
$fk_fournprice,
|
$fk_fournprice,
|
||||||
$pa_ht,
|
$pa_ht,
|
||||||
$array_option
|
$array_options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -638,9 +638,9 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST(
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||||
$objectline->array_options=$array_option;
|
$objectline->array_options=$array_options;
|
||||||
|
|
||||||
// TODO verifier price_min si fk_product et multiprix
|
// TODO verifier price_min si fk_product et multiprix
|
||||||
|
|
||||||
$result=$objectline->update($user);
|
$result=$objectline->update($user);
|
||||||
@ -1416,8 +1416,8 @@ else
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Display lines extrafields
|
//Display lines extrafields
|
||||||
if (is_array($extralabelslines) && count($extralabelslines)>0) {
|
if (is_array($extralabelslines) && count($extralabelslines)>0) {
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
@ -1483,7 +1483,7 @@ else
|
|||||||
print '<br>'.$langs->trans("DateEndPlanned").' ';
|
print '<br>'.$langs->trans("DateEndPlanned").' ';
|
||||||
$form->select_date($db->jdate($objp->date_fin),"date_end_update",$usehm,$usehm,($db->jdate($objp->date_fin)>0?0:1),"update");
|
$form->select_date($db->jdate($objp->date_fin),"date_end_update",$usehm,$usehm,($db->jdate($objp->date_fin)>0?0:1),"update");
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
if (is_array($extralabelslines) && count($extralabelslines)>0) {
|
if (is_array($extralabelslines) && count($extralabelslines)>0) {
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
$line = new ContratLigne($db);
|
$line = new ContratLigne($db);
|
||||||
@ -1491,7 +1491,7 @@ else
|
|||||||
print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan));
|
print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan));
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1239,10 +1239,10 @@ class Contrat extends CommonObject
|
|||||||
* @param int $info_bits Bits de type de lignes
|
* @param int $info_bits Bits de type de lignes
|
||||||
* @param int $fk_fournprice Fourn price id
|
* @param int $fk_fournprice Fourn price id
|
||||||
* @param int $pa_ht Buying price HT
|
* @param int $pa_ht Buying price HT
|
||||||
* @param array $array_option extrafields array
|
* @param array $array_options extrafields array
|
||||||
* @return int <0 si erreur, >0 si ok
|
* @return int <0 si erreur, >0 si ok
|
||||||
*/
|
*/
|
||||||
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_option=0)
|
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0)
|
||||||
{
|
{
|
||||||
global $user, $langs, $conf, $mysoc;
|
global $user, $langs, $conf, $mysoc;
|
||||||
|
|
||||||
@ -1350,11 +1350,11 @@ class Contrat extends CommonObject
|
|||||||
$result=$this->update_statut($user);
|
$result=$this->update_statut($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_option) && count($array_option)>0) // For avoid conflicts if trigger used
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used
|
||||||
{
|
{
|
||||||
$contractline = new ContratLigne($this->db);
|
$contractline = new ContratLigne($this->db);
|
||||||
$contractline->array_options=$array_option;
|
$contractline->array_options=$array_options;
|
||||||
$contractline->id= $this->db->last_insert_id(MAIN_DB_PREFIX.$contractline->table_element);
|
$contractline->id= $this->db->last_insert_id(MAIN_DB_PREFIX.$contractline->table_element);
|
||||||
$result=$contractline->insertExtraFields();
|
$result=$contractline->insertExtraFields();
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
@ -1363,7 +1363,7 @@ class Contrat extends CommonObject
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($error)) {
|
if (empty($error)) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result=$this->call_trigger('LINECONTRACT_CREATE',$user);
|
$result=$this->call_trigger('LINECONTRACT_CREATE',$user);
|
||||||
@ -1373,7 +1373,7 @@ class Contrat extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1417,10 +1417,10 @@ class Contrat extends CommonObject
|
|||||||
* @param int $info_bits Bits de type de lignes
|
* @param int $info_bits Bits de type de lignes
|
||||||
* @param int $fk_fournprice Fourn price id
|
* @param int $fk_fournprice Fourn price id
|
||||||
* @param int $pa_ht Buying price HT
|
* @param int $pa_ht Buying price HT
|
||||||
* @param array $array_option extrafields array
|
* @param array $array_options extrafields array
|
||||||
* @return int < 0 si erreur, > 0 si ok
|
* @return int < 0 si erreur, > 0 si ok
|
||||||
*/
|
*/
|
||||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0.0, $localtax2tx=0.0, $date_debut_reel='', $date_fin_reel='', $price_base_type='HT', $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_option=0)
|
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0.0, $localtax2tx=0.0, $date_debut_reel='', $date_fin_reel='', $price_base_type='HT', $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0)
|
||||||
{
|
{
|
||||||
global $user, $conf, $langs, $mysoc;
|
global $user, $conf, $langs, $mysoc;
|
||||||
|
|
||||||
@ -1520,8 +1520,8 @@ class Contrat extends CommonObject
|
|||||||
$result=$this->update_statut($user);
|
$result=$this->update_statut($user);
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_option) && count($array_option)>0) // For avoid conflicts if trigger used
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used
|
||||||
{
|
{
|
||||||
$contractline = new ContratLigne($this->db);
|
$contractline = new ContratLigne($this->db);
|
||||||
$contractline->array_options=$array_option;
|
$contractline->array_options=$array_option;
|
||||||
@ -1533,7 +1533,7 @@ class Contrat extends CommonObject
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($error)) {
|
if (empty($error)) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result=$this->call_trigger('LINECONTRACT_UPDATE',$user);
|
$result=$this->call_trigger('LINECONTRACT_UPDATE',$user);
|
||||||
@ -1543,7 +1543,7 @@ class Contrat extends CommonObject
|
|||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1597,7 +1597,7 @@ class Contrat extends CommonObject
|
|||||||
$this->error="Error ".$this->db->lasterror();
|
$this->error="Error ".$this->db->lasterror();
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($error)) {
|
if (empty($error)) {
|
||||||
// Remove extrafields
|
// Remove extrafields
|
||||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||||
@ -2522,10 +2522,10 @@ class ContratLigne extends CommonObject
|
|||||||
$error++;
|
$error++;
|
||||||
//return -1;
|
//return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
|
||||||
{
|
{
|
||||||
|
|
||||||
$result=$this->insertExtraFields();
|
$result=$this->insertExtraFields();
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
73
htdocs/core/actions_lineupdown.inc.php
Normal file
73
htdocs/core/actions_lineupdown.inc.php
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* or see http://www.gnu.org/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/core/actions_lineupdown.inc.php
|
||||||
|
* \brief Code for actions on moving lines up or down onto object page
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// $action must be defined
|
||||||
|
// $permissiontoedit must be defined to permission to edit object
|
||||||
|
// $object must be defined
|
||||||
|
// $langs must be defined
|
||||||
|
// $hidedetails, $hidedesc, $hideref must de defined
|
||||||
|
|
||||||
|
if ($action == 'up' && $permissiontoedit)
|
||||||
|
{
|
||||||
|
$object->line_up(GETPOST('rowid'));
|
||||||
|
|
||||||
|
// Define output language
|
||||||
|
$outputlangs = $langs;
|
||||||
|
$newlang = '';
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||||
|
if (! empty($newlang)) {
|
||||||
|
$outputlangs = new Translate("", $conf);
|
||||||
|
$outputlangs->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();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'down' && $permissiontoedit)
|
||||||
|
{
|
||||||
|
$object->line_down(GETPOST('rowid'));
|
||||||
|
|
||||||
|
// Define output language
|
||||||
|
$outputlangs = $langs;
|
||||||
|
$newlang = '';
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||||
|
if (! empty($newlang)) {
|
||||||
|
$outputlangs = new Translate("", $conf);
|
||||||
|
$outputlangs->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();
|
||||||
|
}
|
||||||
|
|
||||||
@ -206,9 +206,9 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafields = new ExtraFields($db);
|
$extrafields = new ExtraFields($db);
|
||||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
$array_option = $extrafields->getOptionalsFromPost($extralabels);
|
$array_options = $extrafields->getOptionalsFromPost($extralabels);
|
||||||
|
|
||||||
$object->array_options = $array_option;
|
$object->array_options = $array_options;
|
||||||
|
|
||||||
$id = $object->create($user);
|
$id = $object->create($user);
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||||
|
|
||||||
|
|
||||||
$result = $object->addline(
|
$result = $object->addline(
|
||||||
@ -297,7 +297,7 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
|
|||||||
$desc,
|
$desc,
|
||||||
$date_intervention,
|
$date_intervention,
|
||||||
$duration,
|
$duration,
|
||||||
$array_option
|
$array_options
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
@ -327,9 +327,9 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafields = new ExtraFields($db);
|
$extrafields = new ExtraFields($db);
|
||||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
$array_option = $extrafields->getOptionalsFromPost($extralabels);
|
$array_options = $extrafields->getOptionalsFromPost($extralabels);
|
||||||
|
|
||||||
$object->array_options = $array_option;
|
$object->array_options = $array_options;
|
||||||
|
|
||||||
$result = $object->create($user);
|
$result = $object->create($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
@ -470,7 +470,7 @@ else if ($action == "addline" && $user->rights->ficheinter->creer)
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||||
|
|
||||||
$result=$object->addline(
|
$result=$object->addline(
|
||||||
$user,
|
$user,
|
||||||
@ -478,7 +478,7 @@ else if ($action == "addline" && $user->rights->ficheinter->creer)
|
|||||||
$desc,
|
$desc,
|
||||||
$date_intervention,
|
$date_intervention,
|
||||||
$duration,
|
$duration,
|
||||||
$array_option
|
$array_options
|
||||||
);
|
);
|
||||||
|
|
||||||
// Define output language
|
// Define output language
|
||||||
@ -568,8 +568,8 @@ else if ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST(
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||||
$objectline->array_options = $array_option;
|
$objectline->array_options = $array_options;
|
||||||
|
|
||||||
$result = $objectline->update($user);
|
$result = $objectline->update($user);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
|
|||||||
@ -889,10 +889,10 @@ class Fichinter extends CommonObject
|
|||||||
* @param string $desc Line description
|
* @param string $desc Line description
|
||||||
* @param date $date_intervention Intervention date
|
* @param date $date_intervention Intervention date
|
||||||
* @param int $duration Intervention duration
|
* @param int $duration Intervention duration
|
||||||
* @param array $array_option Array option
|
* @param array $array_options Array option
|
||||||
* @return int >0 if ok, <0 if ko
|
* @return int >0 if ok, <0 if ko
|
||||||
*/
|
*/
|
||||||
function addline($user,$fichinterid, $desc, $date_intervention, $duration, $array_option='')
|
function addline($user,$fichinterid, $desc, $date_intervention, $duration, $array_options='')
|
||||||
{
|
{
|
||||||
dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration");
|
dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration");
|
||||||
|
|
||||||
@ -908,8 +908,8 @@ class Fichinter extends CommonObject
|
|||||||
$line->datei = $date_intervention;
|
$line->datei = $date_intervention;
|
||||||
$line->duration = $duration;
|
$line->duration = $duration;
|
||||||
|
|
||||||
if (is_array($array_option) && count($array_option)>0) {
|
if (is_array($array_options) && count($array_options)>0) {
|
||||||
$line->array_options=$array_option;
|
$line->array_options=$array_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=$line->insert($user);
|
$result=$line->insert($user);
|
||||||
|
|||||||
@ -1122,10 +1122,10 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
* @param bool $notrigger Disable triggers
|
* @param bool $notrigger Disable triggers
|
||||||
* @param int $date_start Date start of service
|
* @param int $date_start Date start of service
|
||||||
* @param int $date_end Date end of service
|
* @param int $date_end Date end of service
|
||||||
* @param array $array_option extrafields array
|
* @param array $array_options extrafields array
|
||||||
* @return int <=0 if KO, >0 if OK
|
* @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, $array_option=0)
|
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_options=0)
|
||||||
{
|
{
|
||||||
global $langs,$mysoc;
|
global $langs,$mysoc;
|
||||||
|
|
||||||
@ -1260,7 +1260,19 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
{
|
{
|
||||||
$this->rowid = $this->db->last_insert_id(MAIN_DB_PREFIX.'commande_fournisseurdet');
|
$this->rowid = $this->db->last_insert_id(MAIN_DB_PREFIX.'commande_fournisseurdet');
|
||||||
|
|
||||||
if (! $notrigger)
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||||
|
{
|
||||||
|
$linetmp = new CommandeFournisseurLigne($this->db);
|
||||||
|
$linetmp->id=$this->rowid;
|
||||||
|
$linetmp->array_options = $array_options;
|
||||||
|
$result=$linetmp->insertExtraFields();
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error && ! $notrigger)
|
||||||
{
|
{
|
||||||
global $conf, $langs, $user;
|
global $conf, $langs, $user;
|
||||||
// Call trigger
|
// Call trigger
|
||||||
@ -1399,51 +1411,53 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
*
|
*
|
||||||
* @param int $idline Id of line to delete
|
* @param int $idline Id of line to delete
|
||||||
* @param int $notrigger 1=Disable call to triggers
|
* @param int $notrigger 1=Disable call to triggers
|
||||||
* @return >=0 if OK, <0 if KO
|
* @return <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function deleteline($idline, $notrigger=0)
|
function deleteline($idline, $notrigger=0)
|
||||||
{
|
{
|
||||||
global $user,$langs,$conf;
|
global $user,$langs,$conf;
|
||||||
if ($this->statut == 0)
|
|
||||||
|
if ($this->statut != 0)
|
||||||
{
|
{
|
||||||
$this->db->begin();
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (! $notrigger)
|
$this->db->begin();
|
||||||
|
|
||||||
|
if (! $notrigger)
|
||||||
|
{
|
||||||
|
// Call trigger
|
||||||
|
$result=$this->call_trigger('LINEORDER_SUPPLIER_DELETE',$user);
|
||||||
|
if ($result < 0) $error++;
|
||||||
|
// End call triggers
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid = ".$idline;
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::deleteline sql=".$sql);
|
||||||
|
if (! $resql)
|
||||||
{
|
{
|
||||||
// Call trigger
|
$this->error=$this->db->lasterror();
|
||||||
$result=$this->call_trigger('LINEORDER_SUPPLIER_DELETE',$user);
|
$error++;
|
||||||
if ($result < 0) $error++;
|
|
||||||
// End call triggers
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid = ".$idline;
|
$result=$this->update_price();
|
||||||
$resql=$this->db->query($sql);
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::deleteline sql=".$sql);
|
if (! $error)
|
||||||
if (! $resql)
|
{
|
||||||
{
|
$this->db->commit();
|
||||||
$this->error=$this->db->lasterror();
|
return 1;
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error)
|
|
||||||
{
|
|
||||||
$result=$this->update_price();
|
|
||||||
|
|
||||||
$this->db->commit();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->db->rollback();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1779,10 +1793,10 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
* @param int $notrigger Disable triggers
|
* @param int $notrigger Disable triggers
|
||||||
* @param timestamp $date_start Date start of service
|
* @param timestamp $date_start Date start of service
|
||||||
* @param timestamp $date_end Date end of service
|
* @param timestamp $date_end Date end of service
|
||||||
* @param array $array_option extrafields array
|
* @param array $array_options extrafields array
|
||||||
* @return int < 0 if error, > 0 if ok
|
* @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='', $array_option=0)
|
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_options=0)
|
||||||
{
|
{
|
||||||
global $mysoc;
|
global $mysoc;
|
||||||
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type");
|
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type");
|
||||||
|
|||||||
@ -1115,12 +1115,12 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
* @param int $type Type of line (0=product, 1=service)
|
* @param int $type Type of line (0=product, 1=service)
|
||||||
* @param int $rang Position of line
|
* @param int $rang Position of line
|
||||||
* @param int $notrigger Disable triggers
|
* @param int $notrigger Disable triggers
|
||||||
* @param array $array_option extrafields array
|
* @param array $array_options extrafields array
|
||||||
* @return int >0 if OK, <0 if KO
|
* @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.
|
* 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, $array_option=0)
|
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_options=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);
|
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';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||||
@ -1157,7 +1157,7 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
{
|
{
|
||||||
$idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det');
|
$idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det');
|
||||||
|
|
||||||
$result=$this->updateline($idligne, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product, $price_base_type, $info_bits, $type, $remise_percent, true);
|
$result=$this->updateline($idligne, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product, $price_base_type, $info_bits, $type, $remise_percent, true, '', '', $array_options);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$this->rowid = $idligne;
|
$this->rowid = $idligne;
|
||||||
@ -1211,10 +1211,10 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
* @param int $notrigger Disable triggers
|
* @param int $notrigger Disable triggers
|
||||||
* @param timestamp $date_start Date start of service
|
* @param timestamp $date_start Date start of service
|
||||||
* @param timestamp $date_end Date end of service
|
* @param timestamp $date_end Date end of service
|
||||||
* @param array $array_option extrafields array
|
* @param array $array_options extrafields array
|
||||||
* @return int <0 if KO, >0 if OK
|
* @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, $date_start='', $date_end='', $array_option=0)
|
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_options=0)
|
||||||
{
|
{
|
||||||
global $mysoc;
|
global $mysoc;
|
||||||
dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG);
|
dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG);
|
||||||
@ -1295,7 +1295,19 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
{
|
{
|
||||||
$this->rowid = $id;
|
$this->rowid = $id;
|
||||||
|
|
||||||
if (! $notrigger)
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||||
|
{
|
||||||
|
$linetmp = new FactureFournisseurLigne($this->db);
|
||||||
|
$linetmp->id=$this->rowid;
|
||||||
|
$linetmp->array_options = $array_options;
|
||||||
|
$result=$linetmp->insertExtraFields();
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error && ! $notrigger)
|
||||||
{
|
{
|
||||||
global $conf, $langs, $user;
|
global $conf, $langs, $user;
|
||||||
// Call trigger
|
// Call trigger
|
||||||
@ -1328,7 +1340,7 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
*
|
*
|
||||||
* @param int $rowid Id of line to delete
|
* @param int $rowid Id of line to delete
|
||||||
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
||||||
* @return void
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function deleteline($rowid, $notrigger=0)
|
function deleteline($rowid, $notrigger=0)
|
||||||
{
|
{
|
||||||
@ -1366,7 +1378,7 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
// Mise a jour prix facture
|
// Mise a jour prix facture
|
||||||
$this->update_price();
|
$result=$this->update_price();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
|
|||||||
@ -229,7 +229,7 @@ if (empty($reshook))
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||||
// Unset extrafield
|
// Unset extrafield
|
||||||
if (is_array($extralabelsline)) {
|
if (is_array($extralabelsline)) {
|
||||||
// Get extra fields
|
// Get extra fields
|
||||||
@ -442,7 +442,7 @@ if (empty($reshook))
|
|||||||
// Extrafields Lines
|
// Extrafields Lines
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||||
// Unset extrafield POST Data
|
// Unset extrafield POST Data
|
||||||
if (is_array($extralabelsline)) {
|
if (is_array($extralabelsline)) {
|
||||||
foreach ($extralabelsline as $key => $value) {
|
foreach ($extralabelsline as $key => $value) {
|
||||||
@ -507,37 +507,37 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'confirm_deleteproductline' && $confirm == 'yes' && $user->rights->fournisseur->commande->creer)
|
// Remove a product line
|
||||||
|
if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->commande->creer)
|
||||||
{
|
{
|
||||||
|
$result = $object->deleteline($lineid);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
// Define output language
|
||||||
|
$outputlangs = $langs;
|
||||||
|
$newlang = '';
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id'))
|
||||||
|
$newlang = GETPOST('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)) {
|
||||||
|
$ret = $object->fetch($object->id); // Reload to get new records
|
||||||
|
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
|
}
|
||||||
|
|
||||||
$result = $object->deleteline(GETPOST('lineid'));
|
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||||
if ($result >= 0)
|
exit;
|
||||||
{
|
}
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
else
|
||||||
{
|
{
|
||||||
$outputlangs = $langs;
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
$newlang = '';
|
/* Fix bug 1485 : Reset action to avoid asking again confirmation on failure */
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
|
$action='';
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
}
|
||||||
if (! empty($newlang)) {
|
|
||||||
$outputlangs = new Translate("", $conf);
|
|
||||||
$outputlangs->setDefaultLang($newlang);
|
|
||||||
}
|
|
||||||
$ret=$object->fetch($object->id); // Reload to get new records
|
|
||||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
setEventMessage($object->error, 'errors');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error)
|
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'confirm_valid' && $confirm == 'yes' &&
|
if ($action == 'confirm_valid' && $confirm == 'yes' &&
|
||||||
@ -1352,12 +1352,14 @@ elseif (! empty($object->id))
|
|||||||
dol_fiche_head($head, 'card', $title, 0, 'order');
|
dol_fiche_head($head, 'card', $title, 0, 'order');
|
||||||
|
|
||||||
|
|
||||||
|
$formconfirm='';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Confirmation de la suppression de la commande
|
* Confirmation de la suppression de la commande
|
||||||
*/
|
*/
|
||||||
if ($action == 'delete')
|
if ($action == 'delete')
|
||||||
{
|
{
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 2);
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1369,7 +1371,7 @@ elseif (! empty($object->id))
|
|||||||
//array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1)
|
//array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1)
|
||||||
);
|
);
|
||||||
// Paiement incomplet. On demande si motif = escompte ou autre
|
// Paiement incomplet. On demande si motif = escompte ou autre
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1);
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1400,7 +1402,7 @@ elseif (! empty($object->id))
|
|||||||
$text.=$notify->confirmMessage('ORDER_SUPPLIER_APPROVE', $object->socid);
|
$text.=$notify->confirmMessage('ORDER_SUPPLIER_APPROVE', $object->socid);
|
||||||
}
|
}
|
||||||
|
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_valid', '', 0, 1);
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_valid', '', 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1433,7 +1435,7 @@ elseif (! empty($object->id))
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ApproveThisOrder"),$langs->trans("ConfirmApproveThisOrder",$object->ref),"confirm_approve", $formquestion, 1, 1, 240);
|
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ApproveThisOrder"),$langs->trans("ConfirmApproveThisOrder",$object->ref),"confirm_approve", $formquestion, 1, 1, 240);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1442,7 +1444,7 @@ elseif (! empty($object->id))
|
|||||||
*/
|
*/
|
||||||
if ($action == 'refuse')
|
if ($action == 'refuse')
|
||||||
{
|
{
|
||||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("DenyingThisOrder"),$langs->trans("ConfirmDenyingThisOrder",$object->ref),"confirm_refuse", '', 0, 1);
|
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("DenyingThisOrder"),$langs->trans("ConfirmDenyingThisOrder",$object->ref),"confirm_refuse", '', 0, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1451,7 +1453,7 @@ elseif (! empty($object->id))
|
|||||||
*/
|
*/
|
||||||
if ($action == 'cancel')
|
if ($action == 'cancel')
|
||||||
{
|
{
|
||||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("Cancel"),$langs->trans("ConfirmCancelThisOrder",$object->ref),"confirm_cancel", '', 0, 1);
|
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("Cancel"),$langs->trans("ConfirmCancelThisOrder",$object->ref),"confirm_cancel", '', 0, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1461,19 +1463,24 @@ elseif (! empty($object->id))
|
|||||||
if ($action == 'commande')
|
if ($action == 'commande')
|
||||||
{
|
{
|
||||||
$date_com = dol_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
|
$date_com = dol_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
|
||||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"]."&comment=".urlencode($_POST["comment"]), $langs->trans("MakeOrder"),$langs->trans("ConfirmMakeOrder",dol_print_date($date_com,'day')),"confirm_commande",'',0,2);
|
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"]."&comment=".urlencode($_POST["comment"]), $langs->trans("MakeOrder"),$langs->trans("ConfirmMakeOrder",dol_print_date($date_com,'day')),"confirm_commande",'',0,2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Confirmation to delete line
|
||||||
* Confirmation de la suppression d'une ligne produit
|
if ($action == 'ask_deleteline')
|
||||||
*/
|
|
||||||
if ($action == 'delete_product_line')
|
|
||||||
{
|
{
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline','',0,2);
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$formconfirm) {
|
||||||
|
$parameters=array('lineid'=>$lineid);
|
||||||
|
$formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print form confirm
|
||||||
|
print $formconfirm;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Commande
|
* Commande
|
||||||
*/
|
*/
|
||||||
@ -1718,6 +1725,10 @@ elseif (! empty($object->id))
|
|||||||
|
|
||||||
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
||||||
|
|
||||||
|
// Add free products/services form
|
||||||
|
global $forceall, $senderissupplier, $dateSelector;
|
||||||
|
$forceall=1; $senderissupplier=1; $dateSelector=0;
|
||||||
|
|
||||||
// Show object lines
|
// Show object lines
|
||||||
$inputalsopricewithtax=1;
|
$inputalsopricewithtax=1;
|
||||||
if (! empty($object->lines))
|
if (! empty($object->lines))
|
||||||
@ -1904,19 +1915,18 @@ elseif (! empty($object->id))
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// Form to add new line
|
// Form to add new line
|
||||||
if ($object->statut == 0 && $user->rights->fournisseur->commande->creer && $action != 'editline')
|
if ($object->statut == 0 && $user->rights->fournisseur->commande->creer)
|
||||||
{
|
{
|
||||||
// Add free products/services form
|
if ($action != 'editline')
|
||||||
global $forceall, $senderissupplier, $dateSelector;
|
{
|
||||||
$forceall=1; $senderissupplier=1; $dateSelector=0;
|
$var = true;
|
||||||
|
|
||||||
$var = true;
|
// Add free products/services
|
||||||
|
$object->formAddObjectLine(1, $societe, $mysoc);
|
||||||
|
|
||||||
// Add free products/services
|
$parameters = array();
|
||||||
$object->formAddObjectLine(1, $societe, $mysoc);
|
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
|
}
|
||||||
$parameters = array();
|
|
||||||
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
||||||
}
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
@ -187,13 +187,29 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif ($action == 'confirm_delete_line' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer)
|
// Remove a product line
|
||||||
|
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer)
|
||||||
{
|
{
|
||||||
$object->fetch($id);
|
$result = $object->deleteline($lineid);
|
||||||
$ret = $object->deleteline(GETPOST('lineid'));
|
if ($result > 0)
|
||||||
if ($ret > 0)
|
|
||||||
{
|
{
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
// Define output language
|
||||||
|
$outputlangs = $langs;
|
||||||
|
$newlang = '';
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id'))
|
||||||
|
$newlang = GETPOST('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)) {
|
||||||
|
$ret = $object->fetch($object->id); // Reload to get new records
|
||||||
|
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -555,7 +571,7 @@ if (empty($reshook))
|
|||||||
// Extrafields Lines
|
// Extrafields Lines
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||||
// Unset extrafield POST Data
|
// Unset extrafield POST Data
|
||||||
if (is_array($extralabelsline)) {
|
if (is_array($extralabelsline)) {
|
||||||
foreach ($extralabelsline as $key => $value) {
|
foreach ($extralabelsline as $key => $value) {
|
||||||
@ -613,7 +629,7 @@ if (empty($reshook))
|
|||||||
// Extrafields
|
// Extrafields
|
||||||
$extrafieldsline = new ExtraFields($db);
|
$extrafieldsline = new ExtraFields($db);
|
||||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
|
||||||
// Unset extrafield
|
// Unset extrafield
|
||||||
if (is_array($extralabelsline)) {
|
if (is_array($extralabelsline)) {
|
||||||
// Get extra fields
|
// Get extra fields
|
||||||
@ -1589,12 +1605,6 @@ else
|
|||||||
|
|
||||||
dol_fiche_head($head, 'card', $titre, 0, 'bill');
|
dol_fiche_head($head, 'card', $titre, 0, 'bill');
|
||||||
|
|
||||||
// Confirmation de la suppression d'une ligne produit
|
|
||||||
if ($action == 'confirm_delete_line')
|
|
||||||
{
|
|
||||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_delete_line', '', 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clone confirmation
|
// Clone confirmation
|
||||||
if ($action == 'clone')
|
if ($action == 'clone')
|
||||||
{
|
{
|
||||||
@ -1678,7 +1688,13 @@ else
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$formconfirm) {
|
// Confirmation to delete line
|
||||||
|
if ($action == 'ask_deleteline')
|
||||||
|
{
|
||||||
|
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$formconfirm) {
|
||||||
$parameters=array('lineid'=>$lineid);
|
$parameters=array('lineid'=>$lineid);
|
||||||
$formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
$formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
}
|
}
|
||||||
@ -2026,6 +2042,9 @@ else
|
|||||||
|
|
||||||
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
||||||
|
|
||||||
|
global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
|
||||||
|
$forceall=1; $senderissupplier=1; $dateSelector=0; $inputalsopricewithtax=1;
|
||||||
|
|
||||||
// Show object lines
|
// Show object lines
|
||||||
if (! empty($object->lines))
|
if (! empty($object->lines))
|
||||||
$ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1, $user->rights->fournisseur->facture->creer);
|
$ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1, $user->rights->fournisseur->facture->creer);
|
||||||
@ -2215,22 +2234,17 @@ else
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// Form to add new line
|
// Form to add new line
|
||||||
if ($object->statut == 0 && $action != 'editline')
|
if ($object->statut == 0 && $user->rights->fournisseur->facture->creer)
|
||||||
{
|
{
|
||||||
global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
|
if ($action != 'editline')
|
||||||
$forceall=1; $senderissupplier=1; $dateSelector=0; $inputalsopricewithtax=1;
|
|
||||||
if ($object->statut == 0 && $user->rights->fournisseur->facture->creer)
|
|
||||||
{
|
{
|
||||||
if ($action != 'editline')
|
$var = true;
|
||||||
{
|
|
||||||
$var = true;
|
|
||||||
|
|
||||||
// Add free products/services
|
// Add free products/services
|
||||||
$object->formAddObjectLine(1, $societe, $mysoc);
|
$object->formAddObjectLine(1, $societe, $mysoc);
|
||||||
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user