diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php
index c8795a4e322..6c409e912b9 100755
--- a/htdocs/commande/orderstoinvoice.php
+++ b/htdocs/commande/orderstoinvoice.php
@@ -65,7 +65,7 @@ $selected=GETPOST('orders_to_invoice');
$action=GETPOST('action','alpha');
if ($action == 'create')
{
- if (! is_array($selected))
+ if (! is_array($selected))
{
$mesg='
'.$langs->trans('Error_OrderNotChecked').'
';
}
@@ -108,20 +108,20 @@ if (($action == 'create' || $action == 'add') && ! $mesg )
$orders_id = $_GET['orders_to_invoice'];
$n = count($orders_id);
$i = 0;
-
+
$originid=$orders_id[0];
$_GET['originid']=$orders_id[0];
-
+
}
if (isset($_POST['orders_to_invoice']))
{
$orders_id = $_POST['orders_to_invoice'];
$nn = count($orders_id);
$ii = 0;
-
+
$originid=$orders_id[0];
$_POST['originid']=$orders_id[0];
-
+
}
if (GETPOST('mesg','int',1) && isset($_SESSION['message'])) $mesg=$_SESSION['message'];
$sall=isset($_GET['sall'])?trim($_GET['sall']):trim($_POST['sall']);
@@ -134,7 +134,7 @@ if (($action == 'create' || $action == 'add') && ! $mesg )
$lineid =GETPOST('lineid');
$userid =GETPOST('userid');
$search_ref =GETPOST('sf_ref')?GETPOST('sf_ref'):GETPOST('search_ref');
-
+
// Security check
$fieldid = isset($_GET["ref"])?'facnumber':'rowid';
if ($user->societe_id) $socid=$user->societe_id;
@@ -142,21 +142,21 @@ if (($action == 'create' || $action == 'add') && ! $mesg )
$usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE;
$object=new Facture($db);
-
+
// Insert new invoice in database
if ($action == 'add' && $user->rights->facture->creer)
{
$object->socid=GETPOST('socid');
$db->begin();
- $error=0;
-
+ $error=0;
+
// Standard or deposit or proforma invoice
if ($_POST['type'] == 0 )
{
- $datefacture = dol_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
+ $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
if (empty($datefacture))
{
- $datefacture = dol_mktime(12, 0 , 0, date("m"), date("d"), date("Y"));
+ $datefacture = dol_mktime(12, 0, 0, date("m"), date("d"), date("Y"));
}
if (! $error)
{
@@ -176,14 +176,14 @@ if (($action == 'create' || $action == 'add') && ! $mesg )
$object->amount = $_POST['amount'];
$object->remise_absolue = $_POST['remise_absolue'];
$object->remise_percent = $_POST['remise_percent'];
-
+
if ($_POST['origin'] && $_POST['originid'])
{
$object->origin = $_POST['origin'];
$object->origin_id = $orders_id[$ii];
$object->linked_objects = $orders_id;
$id = $object->create($user);
-
+
if ($id>0)
{
foreach($orders_id as $origin => $origin_id)
@@ -201,7 +201,7 @@ if (($action == 'create' || $action == 'add') && ! $mesg )
$sql.= ", ".$id;
$sql.= ", '".$object->element."'";
$sql.= ")";
-
+
dol_syslog(get_class($this)."::add_object_linked sql=".$sql, LOG_DEBUG);
if ($db->query($sql))
{
@@ -209,11 +209,11 @@ if (($action == 'create' || $action == 'add') && ! $mesg )
}
else
{
-
- $db->rollback();
+
+ $db->rollback();
}
}
-
+
while ($ii < $nn)
{
dol_include_once('/commande/class/commande.class.php');
@@ -270,34 +270,34 @@ if (($action == 'create' || $action == 'add') && ! $mesg )
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)
+ if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
{
$fk_parent_line = 0;
}
- $result = $object->addline(
- $id,
- $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
- );
+ $result = $object->addline(
+ $id,
+ $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
+ );
if ($result > 0)
{
$lineid=$result;
@@ -309,7 +309,7 @@ if (($action == 'create' || $action == 'add') && ! $mesg )
break;
}
// Defined the new fk_parent_line
- if ($result > 0 && $lines[$i]->product_type == 9)
+ if ($result > 0 && $lines[$i]->product_type == 9)
{
$fk_parent_line = $result;
}
@@ -322,7 +322,7 @@ if (($action == 'create' || $action == 'add') && ! $mesg )
$error++;
}
$ii++;
- }
+ }
}
else
{
@@ -332,7 +332,7 @@ if (($action == 'create' || $action == 'add') && ! $mesg )
}
}
}
-
+
// End of object creation, we show it
if ($id > 0 && ! $error)
{
@@ -349,7 +349,7 @@ if (($action == 'create' || $action == 'add') && ! $mesg )
if (! $mesg) $mesg=''.$object->error.'
';
}
}
-
+
/*
* View
*/
@@ -357,7 +357,7 @@ if (($action == 'create' || $action == 'add') && ! $mesg )
$htmlother = new FormOther($db);
$formfile = new FormFile($db);
$now=dol_now();
-
+
// Mode creation
if ($action == 'create')
{
@@ -375,7 +375,7 @@ if (($action == 'create' || $action == 'add') && ! $mesg )
}
$remise_absolue = 0;
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
-
+
$absolute_discount=$soc->getAvailableDiscounts();
print '';
- print '