diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index aa6c2729745..52fdaa6eceb 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -460,7 +460,7 @@ if ($id > 0)
}
else
{
- print $langs->trans("ThirdpartyNotLinkedToMember");
+ print ''.$langs->trans("ThirdpartyNotLinkedToMember").'';
}
print '';
print "\n";
diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php
index cf93c87dabb..2be1981c5ae 100644
--- a/htdocs/comm/remise.php
+++ b/htdocs/comm/remise.php
@@ -107,7 +107,7 @@ if ($socid > 0)
print '';
print '';
- dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"),0,'company');
+ dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"), 0, 'company');
dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
@@ -119,7 +119,6 @@ if ($socid > 0)
// Discount
print '
';
print '';
- print '| '.$langs->trans("Date").' | '; // Need 120+ for format with AM/PM
- print ''.$langs->trans("ReasonDiscount").' | ';
+ print ''.$langs->trans("Date").' | '; // Need 120+ for format with AM/PM
+ print ''.$langs->trans("ReasonDiscount").' | ';
print ''.$langs->trans("ConsumedBy").' | ';
print ''.$langs->trans("AmountHT").' | ';
print ''.$langs->trans("VATRate").' | ';
@@ -354,73 +355,79 @@ if ($socid > 0)
$showconfirminfo=array();
- $var = true;
$i = 0;
$num = $db->num_rows($resql);
- while ($i < $num)
+ if ($num > 0)
{
- $obj = $db->fetch_object($resql);
- $var = !$var;
- print "
";
- print '| '.dol_print_date($db->jdate($obj->dc),'dayhour').' | ';
- if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
- {
- print '';
- $facturestatic->id=$obj->fk_facture_source;
- $facturestatic->ref=$obj->ref;
- $facturestatic->type=$obj->type;
- print preg_replace('/\(CREDIT_NOTE\)/',$langs->trans("CreditNote"),$obj->description).' '.$facturestatic->getNomURl(1);
- print ' | ';
- }
- elseif (preg_match('/\(DEPOSIT\)/',$obj->description))
- {
- print '';
- $facturestatic->id=$obj->fk_facture_source;
- $facturestatic->ref=$obj->ref;
- $facturestatic->type=$obj->type;
- print preg_replace('/\(DEPOSIT\)/',$langs->trans("InvoiceDeposit"),$obj->description).' '.$facturestatic->getNomURl(1);
- print ' | ';
- }
- elseif (preg_match('/\(EXCESS RECEIVED\)/',$obj->description))
- {
- print '';
- $facturestatic->id=$obj->fk_facture_source;
- $facturestatic->ref=$obj->ref;
- $facturestatic->type=$obj->type;
- print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("Invoice"),$obj->description).' '.$facturestatic->getNomURl(1);
- print ' | ';
- }
- else
- {
- print '';
- print $obj->description;
- print ' | ';
- }
- print ''.$langs->trans("NotConsumed").' | ';
- print ''.price($obj->amount_ht).' | ';
- print ''.price2num($obj->tva_tx,'MU').'% | ';
- print ''.price($obj->amount_ttc).' | ';
- print '';
- print ''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'';
- print ' | ';
- if ($user->rights->societe->creer || $user->rights->facture->creer)
- {
- print '';
- print 'id.'&action=split&remid='.$obj->rowid.'">'.img_picto($langs->trans("SplitDiscount"),'split').'';
- print ' ';
- print 'id.'&action=remove&remid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveDiscount")).'';
- print ' | ';
- }
- else print ' | ';
- print '
';
-
- if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid)
- {
- $showconfirminfo['rowid']=$obj->rowid;
- $showconfirminfo['amount_ttc']=$obj->amount_ttc;
- }
- $i++;
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+
+ print '';
+ print '| '.dol_print_date($db->jdate($obj->dc),'dayhour').' | ';
+ if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
+ {
+ print '';
+ $facturestatic->id=$obj->fk_facture_source;
+ $facturestatic->ref=$obj->ref;
+ $facturestatic->type=$obj->type;
+ print preg_replace('/\(CREDIT_NOTE\)/',$langs->trans("CreditNote"),$obj->description).' '.$facturestatic->getNomURl(1);
+ print ' | ';
+ }
+ elseif (preg_match('/\(DEPOSIT\)/',$obj->description))
+ {
+ print '';
+ $facturestatic->id=$obj->fk_facture_source;
+ $facturestatic->ref=$obj->ref;
+ $facturestatic->type=$obj->type;
+ print preg_replace('/\(DEPOSIT\)/',$langs->trans("InvoiceDeposit"),$obj->description).' '.$facturestatic->getNomURl(1);
+ print ' | ';
+ }
+ elseif (preg_match('/\(EXCESS RECEIVED\)/',$obj->description))
+ {
+ print '';
+ $facturestatic->id=$obj->fk_facture_source;
+ $facturestatic->ref=$obj->ref;
+ $facturestatic->type=$obj->type;
+ print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("Invoice"),$obj->description).' '.$facturestatic->getNomURl(1);
+ print ' | ';
+ }
+ else
+ {
+ print '';
+ print $obj->description;
+ print ' | ';
+ }
+ print ''.$langs->trans("NotConsumed").' | ';
+ print ''.price($obj->amount_ht).' | ';
+ print ''.price2num($obj->tva_tx,'MU').'% | ';
+ print ''.price($obj->amount_ttc).' | ';
+ print '';
+ print ''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'';
+ print ' | ';
+ if ($user->rights->societe->creer || $user->rights->facture->creer)
+ {
+ print '';
+ print 'id.'&action=split&remid='.$obj->rowid.'">'.img_split($langs->trans("SplitDiscount")).'';
+ print ' ';
+ print 'id.'&action=remove&remid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveDiscount")).'';
+ print ' | ';
+ }
+ else print ' | ';
+ print '
';
+
+ if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid)
+ {
+ $showconfirminfo['rowid']=$obj->rowid;
+ $showconfirminfo['amount_ttc']=$obj->amount_ttc;
+ }
+ $i++;
+ }
}
+ else
+ {
+ print '| '.$langs->trans("None").' |
';
+ }
$db->free($resql);
print "
";
@@ -491,8 +498,8 @@ if ($socid > 0)
print load_fiche_titre($langs->trans("DiscountAlreadyCounted"));
print '';
print '';
- print '| '.$langs->trans("Date").' | '; // Need 120+ for format with AM/PM
- print ''.$langs->trans("ReasonDiscount").' | ';
+ print ''.$langs->trans("Date").' | '; // Need 120+ for format with AM/PM
+ print ''.$langs->trans("ReasonDiscount").' | ';
print ''.$langs->trans("ConsumedBy").' | ';
print ''.$langs->trans("AmountHT").' | ';
print ''.$langs->trans("VATRate").' | ';
@@ -501,15 +508,17 @@ if ($socid > 0)
print ' | ';
print '
';
- $var = true;
$tab_sqlobj=array();
$tab_sqlobjOrder=array();
$num = $db->num_rows($resql);
- for ($i = 0;$i < $num;$i++)
+ if ($num > 0)
{
- $sqlobj = $db->fetch_object($resql);
- $tab_sqlobj[] = $sqlobj;
- $tab_sqlobjOrder[]=$db->jdate($sqlobj->dc);
+ for ($i = 0;$i < $num; $i++)
+ {
+ $sqlobj = $db->fetch_object($resql);
+ $tab_sqlobj[] = $sqlobj;
+ $tab_sqlobjOrder[]=$db->jdate($sqlobj->dc);
+ }
}
$db->free($resql);
@@ -524,57 +533,64 @@ if ($socid > 0)
array_multisort($tab_sqlobjOrder,SORT_DESC,$tab_sqlobj);
$num = count($tab_sqlobj);
- $i = 0 ;
- while ($i < $num )
+ if ($num > 0)
{
- $obj = array_shift($tab_sqlobj);
- $var = !$var;
- print "";
- print '| '.dol_print_date($db->jdate($obj->dc),'dayhour').' | ';
- if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
- {
- print '';
- $facturestatic->id=$obj->fk_facture_source;
- $facturestatic->ref=$obj->ref;
- $facturestatic->type=$obj->type;
- print preg_replace('/\(CREDIT_NOTE\)/',$langs->trans("CreditNote"),$obj->description).' '.$facturestatic->getNomURl(1);
- print ' | ';
- }
- elseif (preg_match('/\(DEPOSIT\)/',$obj->description))
- {
- print '';
- $facturestatic->id=$obj->fk_facture_source;
- $facturestatic->ref=$obj->ref;
- $facturestatic->type=$obj->type;
- print preg_replace('/\(DEPOSIT\)/',$langs->trans("InvoiceDeposit"),$obj->description).' '.$facturestatic->getNomURl(1);
- print ' | ';
- }
- elseif (preg_match('/\(EXCESS RECEIVED\)/',$obj->description))
- {
- print '';
- $facturestatic->id=$obj->fk_facture_source;
- $facturestatic->ref=$obj->ref;
- $facturestatic->type=$obj->type;
- print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("Invoice"),$obj->description).' '.$facturestatic->getNomURl(1);
- print ' | ';
- }
- else
- {
- print '';
- print $obj->description;
- print ' | ';
- }
- print ''.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.' | ';
- print ''.price($obj->amount_ht).' | ';
- print ''.price2num($obj->tva_tx,'MU').'% | ';
- print ''.price($obj->amount_ttc).' | ';
- print '';
- print ''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'';
- print ' | ';
- print ' | ';
- print '
';
- $i++;
+ $i = 0 ;
+ while ($i < $num )
+ {
+ $obj = array_shift($tab_sqlobj);
+ print '';
+ print '| '.dol_print_date($db->jdate($obj->dc),'dayhour').' | ';
+ if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
+ {
+ print '';
+ $facturestatic->id=$obj->fk_facture_source;
+ $facturestatic->ref=$obj->ref;
+ $facturestatic->type=$obj->type;
+ print preg_replace('/\(CREDIT_NOTE\)/',$langs->trans("CreditNote"),$obj->description).' '.$facturestatic->getNomURl(1);
+ print ' | ';
+ }
+ elseif (preg_match('/\(DEPOSIT\)/',$obj->description))
+ {
+ print '';
+ $facturestatic->id=$obj->fk_facture_source;
+ $facturestatic->ref=$obj->ref;
+ $facturestatic->type=$obj->type;
+ print preg_replace('/\(DEPOSIT\)/',$langs->trans("InvoiceDeposit"),$obj->description).' '.$facturestatic->getNomURl(1);
+ print ' | ';
+ }
+ elseif (preg_match('/\(EXCESS RECEIVED\)/',$obj->description))
+ {
+ print '';
+ $facturestatic->id=$obj->fk_facture_source;
+ $facturestatic->ref=$obj->ref;
+ $facturestatic->type=$obj->type;
+ print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("Invoice"),$obj->description).' '.$facturestatic->getNomURl(1);
+ print ' | ';
+ }
+ else
+ {
+ print '';
+ print $obj->description;
+ print ' | ';
+ }
+ print ''.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.' | ';
+ print ''.price($obj->amount_ht).' | ';
+ print ''.price2num($obj->tva_tx,'MU').'% | ';
+ print ''.price($obj->amount_ttc).' | ';
+ print '';
+ print ''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'';
+ print ' | ';
+ print ' | ';
+ print '
';
+ $i++;
+ }
}
+ else
+ {
+ print '| '.$langs->trans("None").' |
';
+ }
+
print "
";
}
else
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index fcd68992b38..6d8f42edffb 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -199,227 +199,226 @@ if (empty($reshook))
$permtodelete = $user->rights->commande->supprimer;
$uploaddir = $conf->commande->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
-}
-
-if ($massaction == 'confirm_createbills') {
-
- $orders = GETPOST('toselect');
- $createbills_onebythird = GETPOST('createbills_onebythird', 'int');
- $validate_invoices = GETPOST('valdate_invoices', 'int');
-
- $TFact = array();
- $TFactThird = array();
-
- $nb_bills_created = 0;
-
- $db->begin();
-
- foreach($orders as $id_order) {
-
- $cmd = new Commande($db);
- if($cmd->fetch($id_order) <= 0) continue;
-
- $object = new Facture($db);
- if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
- else {
-
- $object->socid = $cmd->socid;
- $object->type = Facture::TYPE_STANDARD;
- $object->cond_reglement_id = $cmd->cond_reglement_id;
- $object->mode_reglement_id = $cmd->mode_reglement_id;
- $object->fk_project = $cmd->fk_project;
-
- $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
- if (empty($datefacture))
- {
- $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y"));
- }
-
- $object->date = $datefacture;
- $object->origin = 'commande';
- $object->origin_id = $id_order;
-
- $res = $object->create($user);
-
- if($res > 0) $nb_bills_created++;
-
- }
-
- if($object->id > 0) {
-
- $db->begin();
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
- $sql.= "fk_source";
- $sql.= ", sourcetype";
- $sql.= ", fk_target";
- $sql.= ", targettype";
- $sql.= ") VALUES (";
- $sql.= $id_order;
- $sql.= ", '".$object->origin."'";
- $sql.= ", ".$object->id;
- $sql.= ", '".$object->element."'";
- $sql.= ")";
-
- if ($db->query($sql))
- {
- $db->commit();
- }
- else
- {
- $db->rollback();
- }
-
- $lines = $cmd->lines;
- if (empty($lines) && method_exists($cmd, 'fetch_lines'))
- {
- $cmd->fetch_lines();
- $lines = $cmd->lines;
- }
-
- $fk_parent_line=0;
- $num=count($lines);
-
- for ($i=0;$i<$num;$i++)
- {
- $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
- if ($lines[$i]->subprice < 0)
- {
- // Negative line, we create a discount line
- $discount = new DiscountAbsolute($db);
- $discount->fk_soc=$object->socid;
- $discount->amount_ht=abs($lines[$i]->total_ht);
- $discount->amount_tva=abs($lines[$i]->total_tva);
- $discount->amount_ttc=abs($lines[$i]->total_ttc);
- $discount->tva_tx=$lines[$i]->tva_tx;
- $discount->fk_user=$user->id;
- $discount->description=$desc;
- $discountid=$discount->create($user);
- if ($discountid > 0)
- {
- $result=$object->insert_discount($discountid);
- //$result=$discount->link_to_invoice($lineid,$id);
- }
- else
- {
- setEventMessages($discount->error, $discount->errors, 'errors');
- $error++;
- break;
- }
- }
- else
- {
- // Positive line
- $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
- // Date start
- $date_start=false;
- if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
- if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
- if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
- //Date end
- $date_end=false;
- if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
- if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
- if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
- // Reset fk_parent_line for no child products and special product
- if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
- {
- $fk_parent_line = 0;
- }
- $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,
- $ii,
- $lines[$i]->special_code,
- $object->origin,
- $lines[$i]->rowid,
- $fk_parent_line,
- $lines[$i]->fk_fournprice,
- $lines[$i]->pa_ht,
- $lines[$i]->label
- );
- if ($result > 0)
- {
- $lineid=$result;
- }
- else
- {
- $lineid=0;
- $error++;
- break;
- }
- // Defined the new fk_parent_line
- if ($result > 0 && $lines[$i]->product_type == 9)
- {
- $fk_parent_line = $result;
- }
- }
- }
-
- }
-
- $cmd->classifyBilled($user);
-
- if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object;
- else $TFact[$object->id] = $object;
- }
-
- // Build doc with all invoices
- $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
- $toselect = array();
-
- if(!empty($validate_invoices)) {
-
- $massaction = $action = 'builddoc';
-
- foreach($TAllFact as &$object) {
- $object->validate($user);
- $toselect[] = $object->id; // For builddoc action
-
- // Fac builddoc
- $upload_dir = $conf->facture->dir_output;
- $permissioncreate=$user->rights->facture->creer;
- include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
- }
-
- $objectclass='Facture';
- $objectlabel='Invoice';
- $permtoread = $user->rights->facture->lire;
- $permtodelete = $user->rights->facture->supprimer;
- $uploaddir = $conf->facture->dir_output;
- include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
-
- }
-
- if (! $error)
- {
- $db->commit();
- setEventMessage($langs->trans('BillCreated', $nb_bills_created));
- }
- else
- {
- $db->rollback();
- $action='create';
- $_GET["origin"]=$_POST["origin"];
- $_GET["originid"]=$_POST["originid"];
- setEventMessages($object->error, $object->errors, 'errors');
- $error++;
- }
-
+ // TODO Move this into mass action include
+ if ($massaction == 'confirm_createbills') {
+
+ $orders = GETPOST('toselect');
+ $createbills_onebythird = GETPOST('createbills_onebythird', 'int');
+ $validate_invoices = GETPOST('valdate_invoices', 'int');
+
+ $TFact = array();
+ $TFactThird = array();
+
+ $nb_bills_created = 0;
+
+ $db->begin();
+
+ foreach($orders as $id_order) {
+
+ $cmd = new Commande($db);
+ if($cmd->fetch($id_order) <= 0) continue;
+
+ $object = new Facture($db);
+ if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
+ else {
+
+ $object->socid = $cmd->socid;
+ $object->type = Facture::TYPE_STANDARD;
+ $object->cond_reglement_id = $cmd->cond_reglement_id;
+ $object->mode_reglement_id = $cmd->mode_reglement_id;
+ $object->fk_project = $cmd->fk_project;
+
+ $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
+ if (empty($datefacture))
+ {
+ $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y"));
+ }
+
+ $object->date = $datefacture;
+ $object->origin = 'commande';
+ $object->origin_id = $id_order;
+
+ $res = $object->create($user);
+
+ if($res > 0) $nb_bills_created++;
+
+ }
+
+ if($object->id > 0) {
+
+ $db->begin();
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
+ $sql.= "fk_source";
+ $sql.= ", sourcetype";
+ $sql.= ", fk_target";
+ $sql.= ", targettype";
+ $sql.= ") VALUES (";
+ $sql.= $id_order;
+ $sql.= ", '".$object->origin."'";
+ $sql.= ", ".$object->id;
+ $sql.= ", '".$object->element."'";
+ $sql.= ")";
+
+ if ($db->query($sql))
+ {
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
+ }
+
+ $lines = $cmd->lines;
+ if (empty($lines) && method_exists($cmd, 'fetch_lines'))
+ {
+ $cmd->fetch_lines();
+ $lines = $cmd->lines;
+ }
+
+ $fk_parent_line=0;
+ $num=count($lines);
+
+ for ($i=0;$i<$num;$i++)
+ {
+ $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
+ if ($lines[$i]->subprice < 0)
+ {
+ // Negative line, we create a discount line
+ $discount = new DiscountAbsolute($db);
+ $discount->fk_soc=$object->socid;
+ $discount->amount_ht=abs($lines[$i]->total_ht);
+ $discount->amount_tva=abs($lines[$i]->total_tva);
+ $discount->amount_ttc=abs($lines[$i]->total_ttc);
+ $discount->tva_tx=$lines[$i]->tva_tx;
+ $discount->fk_user=$user->id;
+ $discount->description=$desc;
+ $discountid=$discount->create($user);
+ if ($discountid > 0)
+ {
+ $result=$object->insert_discount($discountid);
+ //$result=$discount->link_to_invoice($lineid,$id);
+ }
+ else
+ {
+ setEventMessages($discount->error, $discount->errors, 'errors');
+ $error++;
+ break;
+ }
+ }
+ else
+ {
+ // Positive line
+ $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
+ // Date start
+ $date_start=false;
+ if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
+ if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
+ if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
+ //Date end
+ $date_end=false;
+ if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
+ if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
+ if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
+ // Reset fk_parent_line for no child products and special product
+ if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
+ {
+ $fk_parent_line = 0;
+ }
+ $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,
+ $ii,
+ $lines[$i]->special_code,
+ $object->origin,
+ $lines[$i]->rowid,
+ $fk_parent_line,
+ $lines[$i]->fk_fournprice,
+ $lines[$i]->pa_ht,
+ $lines[$i]->label
+ );
+ if ($result > 0)
+ {
+ $lineid=$result;
+ }
+ else
+ {
+ $lineid=0;
+ $error++;
+ break;
+ }
+ // Defined the new fk_parent_line
+ if ($result > 0 && $lines[$i]->product_type == 9)
+ {
+ $fk_parent_line = $result;
+ }
+ }
+ }
+
+ }
+
+ $cmd->classifyBilled($user);
+
+ if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object;
+ else $TFact[$object->id] = $object;
+ }
+
+ // Build doc with all invoices
+ $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
+ $toselect = array();
+
+ if(!empty($validate_invoices)) {
+
+ $massaction = $action = 'builddoc';
+
+ foreach($TAllFact as &$object) {
+ $object->validate($user);
+ $toselect[] = $object->id; // For builddoc action
+
+ // Fac builddoc
+ $upload_dir = $conf->facture->dir_output;
+ $permissioncreate=$user->rights->facture->creer;
+ include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
+ }
+
+ $objectclass='Facture';
+ $objectlabel='Invoice';
+ $permtoread = $user->rights->facture->lire;
+ $permtodelete = $user->rights->facture->supprimer;
+ $uploaddir = $conf->facture->dir_output;
+ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
+
+ }
+
+ if (! $error)
+ {
+ $db->commit();
+ setEventMessage($langs->trans('BillCreated', $nb_bills_created));
+ }
+ else
+ {
+ $db->rollback();
+ $action='create';
+ $_GET["origin"]=$_POST["origin"];
+ $_GET["originid"]=$_POST["originid"];
+ setEventMessages($object->error, $object->errors, 'errors');
+ $error++;
+ }
+ }
}
@@ -435,8 +434,9 @@ $formfile = new FormFile($db);
$companystatic = new Societe($db);
$formcompany=new FormCompany($db);
+$title=$langs->trans("Orders");
$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
-llxHeader('',$langs->trans("Orders"),$help_url);
+llxHeader('',$title,$help_url);
$sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
@@ -622,7 +622,6 @@ if ($resql)
if ($show_files) $param.='&show_files=' .$show_files;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
if ($billed != '') $param.='&billed='.$billed;
-
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
@@ -654,6 +653,7 @@ if ($resql)
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit);
+ // TODO Move this into an invluce
if ($massaction == 'presend')
{
$langs->load("mails");
@@ -679,9 +679,6 @@ if ($resql)
print '