Fix: Missing list of details of lines

This commit is contained in:
Laurent Destailleur 2011-11-23 20:18:31 +01:00
parent e4cb045b53
commit 322135c09d

View File

@ -197,9 +197,9 @@ if ($_POST['action'] == 'update' && ! $_POST['cancel'])
*/ */
if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer) if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer)
{ {
$error=0; $error=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']);
$datedue=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); $datedue=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']);
if ($datefacture == '') if ($datefacture == '')
@ -232,93 +232,93 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer)
$facfou->note_public = $_POST['note']; $facfou->note_public = $_POST['note'];
// If creation from another object of another module // If creation from another object of another module
if ($_POST['origin'] && $_POST['originid']) if ($_POST['origin'] && $_POST['originid'])
{ {
// Parse element/subelement (ex: project_task) // Parse element/subelement (ex: project_task)
$element = $subelement = $_POST['origin']; $element = $subelement = $_POST['origin'];
/*if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs)) /*if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs))
{ {
$element = $regs[1]; $element = $regs[1];
$subelement = $regs[2]; $subelement = $regs[2];
}*/ }*/
// For compatibility // For compatibility
if ($element == 'order') { $element = $subelement = 'commande'; } if ($element == 'order') { $element = $subelement = 'commande'; }
if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; }
if ($element == 'contract') { $element = $subelement = 'contrat'; } if ($element == 'contract') { $element = $subelement = 'contrat'; }
if ($element == 'order_supplier') { $element = 'fourn'; $subelement = 'fournisseur.commande'; } if ($element == 'order_supplier') { $element = 'fourn'; $subelement = 'fournisseur.commande'; }
$facfou->origin = $_POST['origin']; $facfou->origin = $_POST['origin'];
$facfou->origin_id = $_POST['originid']; $facfou->origin_id = $_POST['originid'];
$facid = $facfou->create($user); $facid = $facfou->create($user);
// Add lines // Add lines
if ($facid > 0) if ($facid > 0)
{ {
require_once(DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'); require_once(DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php');
$classname = ucfirst($subelement); $classname = ucfirst($subelement);
if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur';
$srcobject = new $classname($db); $srcobject = new $classname($db);
$result=$srcobject->fetch($_POST['originid']); $result=$srcobject->fetch($_POST['originid']);
if ($result > 0) if ($result > 0)
{ {
$lines = $srcobject->lines; $lines = $srcobject->lines;
if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
for ($i = 0 ; $i < sizeof($lines) ; $i++) for ($i = 0 ; $i < sizeof($lines) ; $i++)
{ {
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
// Dates // Dates
// TODO mutualiser // TODO mutualiser
$date_start=$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_debut_reel) $date_start=$lines[$i]->date_debut_reel;
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
$date_end=$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_fin_reel) $date_end=$lines[$i]->date_fin_reel;
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
$result = $facfou->addline( $result = $facfou->addline(
$desc, $desc,
$lines[$i]->subprice, $lines[$i]->subprice,
$lines[$i]->tva_tx, $lines[$i]->tva_tx,
$lines[$i]->localtax1_tx, $lines[$i]->localtax1_tx,
$lines[$i]->localtax2_tx, $lines[$i]->localtax2_tx,
$lines[$i]->qty, $lines[$i]->qty,
$lines[$i]->fk_product, $lines[$i]->fk_product,
$lines[$i]->remise_percent, $lines[$i]->remise_percent,
$date_start, $date_start,
$date_end, $date_end,
0, 0,
$lines[$i]->info_bits, $lines[$i]->info_bits,
'HT', 'HT',
$product_type $product_type
); );
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
break; break;
} }
} }
} }
else else
{ {
$error++; $error++;
} }
} }
else else
{ {
$error++; $error++;
} }
} }
// If some invoice's lines already known // If some invoice's lines already known
else else
{ {
$facid = $facfou->create($user); $facid = $facfou->create($user);
if ($facid < 0) if ($facid < 0)
{ {
$error++; $error++;
@ -326,7 +326,7 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer)
if (! $error) if (! $error)
{ {
for ($i = 1 ; $i < 9 ; $i++) for ($i = 1 ; $i < 9 ; $i++)
{ {
$label = $_POST['label'.$i]; $label = $_POST['label'.$i];
$amountht = price2num($_POST['amount'.$i]); $amountht = price2num($_POST['amount'.$i]);
@ -346,14 +346,14 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer)
} }
$atleastoneline=1; $atleastoneline=1;
$product=new Product($db); $product=new Product($db);
$product->fetch($_POST['idprod'.$i]); $product->fetch($_POST['idprod'.$i]);
$ret=$facfou->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base); $ret=$facfou->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base);
if ($ret < 0) $error++; if ($ret < 0) $error++;
} }
} }
} }
} }
if ($error) if ($error)
@ -383,7 +383,7 @@ if ($_GET['action'] == 'del_ligne')
// Modification d'une ligne // Modification d'une ligne
if ($_REQUEST['action'] == 'update_line') if ($_REQUEST['action'] == 'update_line')
{ {
if ($_REQUEST['etat'] == '1' && ! $_REQUEST['cancel']) // si on valide la modification if ($_REQUEST['etat'] == '1' && ! $_REQUEST['cancel']) // si on valide la modification
{ {
$facfou = new FactureFournisseur($db); $facfou = new FactureFournisseur($db);
$facfou->fetch($_GET['facid']); $facfou->fetch($_GET['facid']);
@ -412,15 +412,15 @@ if ($_REQUEST['action'] == 'update_line')
} }
else else
{ {
if ($facfou->socid) if ($facfou->socid)
{ {
$societe=new Societe($db); $societe=new Societe($db);
$societe->fetch($facfou->socid); $societe->fetch($facfou->socid);
} }
$label = $_POST['label']; $label = $_POST['label'];
$type = $_POST["type"]?$_POST["type"]:0; $type = $_POST["type"]?$_POST["type"]:0;
$localtax1tx= get_localtax($_POST['tauxtva'], 1, $societe); $localtax1tx= get_localtax($_POST['tauxtva'], 1, $societe);
$localtax2tx= get_localtax($_POST['tauxtva'], 2, $societe); $localtax2tx= get_localtax($_POST['tauxtva'], 2, $societe);
} }
$result=$facfou->updateline($_GET['lineid'], $label, $pu, $_POST['tauxtva'], $localtax1tx, $localtax2tx, $_POST['qty'], $_POST['idprod'], $price_base_type, 0, $type); $result=$facfou->updateline($_GET['lineid'], $label, $pu, $_POST['tauxtva'], $localtax1tx, $localtax2tx, $_POST['qty'], $_POST['idprod'], $price_base_type, 0, $type);
@ -441,11 +441,11 @@ if ($_GET['action'] == 'addline')
exit; exit;
} }
if ($facfou->socid) if ($facfou->socid)
{ {
$societe=new Societe($db); $societe=new Societe($db);
$societe->fetch($facfou->socid); $societe->fetch($facfou->socid);
} }
if ($_POST['idprodfournprice']) // > 0 or -1 if ($_POST['idprodfournprice']) // > 0 or -1
{ {
@ -464,7 +464,7 @@ if ($_GET['action'] == 'addline')
$tvatx=get_default_tva($societe,$mysoc,$product->id); $tvatx=get_default_tva($societe,$mysoc,$product->id);
$localtax1tx= get_localtax($tvatx, 1, $societe); $localtax1tx= get_localtax($tvatx, 1, $societe);
$localtax2tx= get_localtax($tvatx, 2, $societe); $localtax2tx= get_localtax($tvatx, 2, $societe);
$type = $product->type; $type = $product->type;
@ -480,8 +480,8 @@ if ($_GET['action'] == 'addline')
else else
{ {
$tauxtva = price2num($_POST['tauxtva']); $tauxtva = price2num($_POST['tauxtva']);
$localtax1tx= get_localtax($tauxtva, 1, $societe); $localtax1tx= get_localtax($tauxtva, 1, $societe);
$localtax2tx= get_localtax($tauxtva, 2, $societe); $localtax2tx= get_localtax($tauxtva, 2, $societe);
if (! $_POST['label']) if (! $_POST['label'])
{ {
@ -528,8 +528,8 @@ if ($_GET['action'] == 'addline')
unset($_POST['pu']); unset($_POST['pu']);
unset($_POST['tva_tx']); unset($_POST['tva_tx']);
unset($_POST['label']); unset($_POST['label']);
unset($localtax1_tx); unset($localtax1_tx);
unset($localtax2_tx); unset($localtax2_tx);
} }
else if (empty($mesg)) else if (empty($mesg))
{ {
@ -621,7 +621,7 @@ if ($_GET['action'] == 'reopen' && $user->rights->fournisseur->facture->creer)
/* /*
* Add file in email form * Add file in email form
*/ */
if ($_POST['addfile']) if ($_POST['addfile'])
{ {
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
@ -638,7 +638,7 @@ if ($_POST['addfile'])
/* /*
* Remove file in email form * Remove file in email form
*/ */
if (! empty($_POST['removedfile'])) if (! empty($_POST['removedfile']))
{ {
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
@ -655,7 +655,7 @@ if (! empty($_POST['removedfile']))
/* /*
* Send mail * Send mail
*/ */
if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel'])
{ {
$langs->load('mails'); $langs->load('mails');
@ -747,7 +747,7 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile']
$facturefourn->actionmsg = $actionmsg; $facturefourn->actionmsg = $actionmsg;
$facturefourn->actionmsg2 = $actionmsg2; $facturefourn->actionmsg2 = $actionmsg2;
$facturefourn->fk_element = $facturefourn->id; $facturefourn->fk_element = $facturefourn->id;
$facturefourn->elementtype = $facturefourn->element; $facturefourn->elementtype = $facturefourn->element;
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
@ -812,14 +812,14 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile']
/* /*
* Build document * Build document
*/ */
if ($_REQUEST['action'] == 'builddoc') if ($_REQUEST['action'] == 'builddoc')
{ {
/* /*
* Generation de la facture * Generation de la facture
* definit dans /includes/modules/supplier_invoice/modules_facturefournisseur.php * definit dans /includes/modules/supplier_invoice/modules_facturefournisseur.php
*/ */
// Save modele used // Save modele used
$facture=new FactureFournisseur($db); $facture=new FactureFournisseur($db);
@ -866,7 +866,7 @@ if ($action=='remove_file')
/* /*
* View * View
*/ */
llxHeader('','',''); llxHeader('','','');
@ -887,53 +887,53 @@ if ($_GET['action'] == 'create')
$societe->fetch($_GET['socid']); $societe->fetch($_GET['socid']);
} }
if (GETPOST('origin') && GETPOST('originid')) if (GETPOST('origin') && GETPOST('originid'))
{ {
// Parse element/subelement (ex: project_task) // Parse element/subelement (ex: project_task)
$element = $subelement = GETPOST('origin'); $element = $subelement = GETPOST('origin');
if ($element == 'project') if ($element == 'project')
{ {
$projectid=GETPOST('originid'); $projectid=GETPOST('originid');
} }
else if (in_array($element,array('order_supplier'))) else if (in_array($element,array('order_supplier')))
{ {
// For compatibility // For compatibility
if ($element == 'order') { $element = $subelement = 'commande'; } if ($element == 'order') { $element = $subelement = 'commande'; }
if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; }
if ($element == 'contract') { $element = $subelement = 'contrat'; } if ($element == 'contract') { $element = $subelement = 'contrat'; }
if ($element == 'order_supplier') { $element = 'fourn'; $subelement = 'fournisseur.commande'; } if ($element == 'order_supplier') { $element = 'fourn'; $subelement = 'fournisseur.commande'; }
require_once(DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php');
$classname = ucfirst($subelement);
if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur';
$objectsrc = new $classname($db);
$objectsrc->fetch(GETPOST('originid'));
$objectsrc->fetch_thirdparty();
require_once(DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'); $projectid = (!empty($objectsrc->fk_project)?$object->fk_project:'');
$classname = ucfirst($subelement); //$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:'');
if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur';
$objectsrc = new $classname($db);
$objectsrc->fetch(GETPOST('originid'));
$objectsrc->fetch_thirdparty();
$projectid = (!empty($objectsrc->fk_project)?$object->fk_project:''); $soc = $objectsrc->client;
//$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1));
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0));
$remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0));
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
$soc = $objectsrc->client; $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']);
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp);
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']);
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); $datedue=($datetmp==''?-1:$datetmp);
$remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); }
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; }
else
$datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); {
$dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp); $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']);
$datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp);
$datedue=($datetmp==''?-1:$datetmp); $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']);
} $datedue=($datetmp==''?-1:$datetmp);
} }
else
{
$datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']);
$dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp);
$datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']);
$datedue=($datetmp==''?-1:$datetmp);
}
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -942,10 +942,10 @@ if ($_GET['action'] == 'create')
print '<input type="hidden" name="originid" value="'.GETPOST('originid').'">'; print '<input type="hidden" name="originid" value="'.GETPOST('originid').'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td>'.$langs->trans('Ref').'</td><td>'.$langs->trans('Draft').'</td></tr>'; print '<tr><td>'.$langs->trans('Ref').'</td><td>'.$langs->trans('Draft').'</td></tr>';
// Third party // Third party
print '<tr><td class="fieldrequired">'.$langs->trans('ThirdParty').'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans('ThirdParty').'</td>';
print '<td>'; print '<td>';
@ -964,91 +964,91 @@ if ($_GET['action'] == 'create')
print '<tr><td class="fieldrequired">'.$langs->trans('RefSupplier').'</td><td><input name="facnumber" value="'.(isset($_POST['facnumber'])?$_POST['facnumber']:$fac_ori->ref).'" type="text"></td>'; print '<tr><td class="fieldrequired">'.$langs->trans('RefSupplier').'</td><td><input name="facnumber" value="'.(isset($_POST['facnumber'])?$_POST['facnumber']:$fac_ori->ref).'" type="text"></td>';
print '</tr>'; print '</tr>';
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('Type').'</td><td colspan="2">'; print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('Type').'</td><td colspan="2">';
print '<table class="nobordernopadding">'."\n"; print '<table class="nobordernopadding">'."\n";
// Standard invoice // Standard invoice
print '<tr height="18"><td width="16px" valign="middle">'; print '<tr height="18"><td width="16px" valign="middle">';
print '<input type="radio" name="type" value="0"'.($_POST['type']==0?' checked="true"':'').'>'; print '<input type="radio" name="type" value="0"'.($_POST['type']==0?' checked="true"':'').'>';
print '</td><td valign="middle">'; print '</td><td valign="middle">';
$desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1); $desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1);
print $desc; print $desc;
print '</td></tr>'."\n"; print '</td></tr>'."\n";
/* /*
// Deposit // Deposit
print '<tr height="18"><td width="16px" valign="middle">'; print '<tr height="18"><td width="16px" valign="middle">';
print '<input type="radio" name="type" value="3"'.($_POST['type']==3?' checked="true"':'').'>'; print '<input type="radio" name="type" value="3"'.($_POST['type']==3?' checked="true"':'').'>';
print '</td><td valign="middle">'; print '</td><td valign="middle">';
$desc=$html->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); $desc=$html->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1);
print $desc; print $desc;
print '</td></tr>'."\n"; print '</td></tr>'."\n";
// Proforma // Proforma
if ($conf->global->FACTURE_USE_PROFORMAT) if ($conf->global->FACTURE_USE_PROFORMAT)
{ {
print '<tr height="18"><td width="16px" valign="middle">'; print '<tr height="18"><td width="16px" valign="middle">';
print '<input type="radio" name="type" value="4"'.($_POST['type']==4?' checked="true"':'').'>'; print '<input type="radio" name="type" value="4"'.($_POST['type']==4?' checked="true"':'').'>';
print '</td><td valign="middle">'; print '</td><td valign="middle">';
$desc=$html->textwithpicto($langs->trans("InvoiceProForma"),$langs->transnoentities("InvoiceProFormaDesc"),1); $desc=$html->textwithpicto($langs->trans("InvoiceProForma"),$langs->transnoentities("InvoiceProFormaDesc"),1);
print $desc; print $desc;
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} }
// Replacement // Replacement
print '<tr height="18"><td valign="middle">'; print '<tr height="18"><td valign="middle">';
print '<input type="radio" name="type" value="1"'.($_POST['type']==1?' checked=true':''); print '<input type="radio" name="type" value="1"'.($_POST['type']==1?' checked=true':'');
if (! $options) print ' disabled="true"'; if (! $options) print ' disabled="true"';
print '>'; print '>';
print '</td><td valign="middle">'; print '</td><td valign="middle">';
$text=$langs->trans("InvoiceReplacementAsk").' '; $text=$langs->trans("InvoiceReplacementAsk").' ';
$text.='<select class="flat" name="fac_replacement"'; $text.='<select class="flat" name="fac_replacement"';
if (! $options) $text.=' disabled="true"'; if (! $options) $text.=' disabled="true"';
$text.='>'; $text.='>';
if ($options) if ($options)
{ {
$text.='<option value="-1">&nbsp;</option>'; $text.='<option value="-1">&nbsp;</option>';
$text.=$options; $text.=$options;
} }
else else
{ {
$text.='<option value="-1">'.$langs->trans("NoReplacableInvoice").'</option>'; $text.='<option value="-1">'.$langs->trans("NoReplacableInvoice").'</option>';
} }
$text.='</select>'; $text.='</select>';
$desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); $desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1);
print $desc; print $desc;
print '</td></tr>'; print '</td></tr>';
// Credit note // Credit note
print '<tr height="18"><td valign="middle">'; print '<tr height="18"><td valign="middle">';
print '<input type="radio" name="type" value="2"'.($_POST['type']==2?' checked=true':''); print '<input type="radio" name="type" value="2"'.($_POST['type']==2?' checked=true':'');
if (! $optionsav) print ' disabled="true"'; if (! $optionsav) print ' disabled="true"';
print '>'; print '>';
print '</td><td valign="middle">'; print '</td><td valign="middle">';
$text=$langs->transnoentities("InvoiceAvoirAsk").' '; $text=$langs->transnoentities("InvoiceAvoirAsk").' ';
// $text.='<input type="text" value="">'; // $text.='<input type="text" value="">';
$text.='<select class="flat" name="fac_avoir"'; $text.='<select class="flat" name="fac_avoir"';
if (! $optionsav) $text.=' disabled="true"'; if (! $optionsav) $text.=' disabled="true"';
$text.='>'; $text.='>';
if ($optionsav) if ($optionsav)
{ {
$text.='<option value="-1">&nbsp;</option>'; $text.='<option value="-1">&nbsp;</option>';
$text.=$optionsav; $text.=$optionsav;
} }
else else
{ {
$text.='<option value="-1">'.$langs->trans("NoInvoiceToCorrect").'</option>'; $text.='<option value="-1">'.$langs->trans("NoInvoiceToCorrect").'</option>';
} }
$text.='</select>'; $text.='</select>';
$desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); $desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1);
//.' ('.$langs->trans("FeatureNotYetAvailable").')',$langs->transnoentities("InvoiceAvoirDesc"),1); //.' ('.$langs->trans("FeatureNotYetAvailable").')',$langs->transnoentities("InvoiceAvoirDesc"),1);
print $desc; print $desc;
print '</td></tr>'."\n"; print '</td></tr>'."\n";
*/ */
print '</table>'; print '</table>';
print '</td></tr>'; print '</td></tr>';
// Label // Label
print '<tr><td>'.$langs->trans('Label').'</td><td><input size="30" name="libelle" value="'.(isset($_POST['libelle'])?$_POST['libelle']:$fac_ori->libelle).'" type="text"></td></tr>'; print '<tr><td>'.$langs->trans('Label').'</td><td><input size="30" name="libelle" value="'.(isset($_POST['libelle'])?$_POST['libelle']:$fac_ori->libelle).'" type="text"></td></tr>';
// Date invoice // Date invoice
@ -1065,68 +1065,83 @@ if ($_GET['action'] == 'create')
print '<td><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea></td>'; print '<td><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea></td>';
print '</tr>'; print '</tr>';
if (is_object($objectsrc)) if (is_object($objectsrc))
{ {
print "\n<!-- ".$classname." info -->"; print "\n<!-- ".$classname." info -->";
print "\n"; print "\n";
print '<input type="hidden" name="amount" value="'.$objectsrc->total_ht.'">'."\n"; print '<input type="hidden" name="amount" value="'.$objectsrc->total_ht.'">'."\n";
print '<input type="hidden" name="total" value="'.$objectsrc->total_ttc.'">'."\n"; print '<input type="hidden" name="total" value="'.$objectsrc->total_ttc.'">'."\n";
print '<input type="hidden" name="tva" value="'.$objectsrc->total_tva.'">'."\n"; print '<input type="hidden" name="tva" value="'.$objectsrc->total_tva.'">'."\n";
print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">'; print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">'; print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
$txt=$langs->trans($classname); $txt=$langs->trans($classname);
if ($classname=='CommandeFournisseur') $txt=$langs->trans("SupplierOrder"); if ($classname=='CommandeFournisseur') $txt=$langs->trans("SupplierOrder");
print '<tr><td>'.$txt.'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>'; print '<tr><td>'.$txt.'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans('TotalHT').'</td><td colspan="2">'.price($objectsrc->total_ht).'</td></tr>'; print '<tr><td>'.$langs->trans('TotalHT').'</td><td colspan="2">'.price($objectsrc->total_ht).'</td></tr>';
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td colspan="2">'.price($objectsrc->total_tva)."</td></tr>"; print '<tr><td>'.$langs->trans('TotalVAT').'</td><td colspan="2">'.price($objectsrc->total_tva)."</td></tr>";
if ($mysoc->pays_code=='ES') if ($mysoc->pays_code=='ES')
{ {
if ($mysoc->localtax1_assuj=="1") //Localtax1 RE if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
{ {
print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->pays_code).'</td><td colspan="2">'.price($objectsrc->total_localtax1)."</td></tr>"; print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->pays_code).'</td><td colspan="2">'.price($objectsrc->total_localtax1)."</td></tr>";
} }
if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
{ {
print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->pays_code).'</td><td colspan="2">'.price($objectsrc->total_localtax2)."</td></tr>"; print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->pays_code).'</td><td colspan="2">'.price($objectsrc->total_localtax2)."</td></tr>";
} }
} }
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td colspan="2">'.price($objectsrc->total_ttc)."</td></tr>"; print '<tr><td>'.$langs->trans('TotalTTC').'</td><td colspan="2">'.price($objectsrc->total_ttc)."</td></tr>";
} }
else else
{ {
if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) if ($conf->global->PRODUCT_SHOW_WHEN_CREATE)
{ {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>&nbsp;</td><td>'.$langs->trans('Label').'</td>'; print '<td>&nbsp;</td><td>'.$langs->trans('Label').'</td>';
print '<td align="right">'.$langs->trans('PriceUHT').'</td>'; print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
print '<td align="right">'.$langs->trans('VAT').'</td>'; print '<td align="right">'.$langs->trans('VAT').'</td>';
print '<td align="right">'.$langs->trans('Qty').'</td>'; print '<td align="right">'.$langs->trans('Qty').'</td>';
print '<td align="right">'.$langs->trans('PriceUTTC').'</td>'; print '<td align="right">'.$langs->trans('PriceUTTC').'</td>';
print '</tr>'; print '</tr>';
for ($i = 1 ; $i < 9 ; $i++) for ($i = 1 ; $i < 9 ; $i++)
{ {
$value_qty = '1'; $value_qty = '1';
$value_tauxtva = ''; $value_tauxtva = '';
print '<tr><td>'.$i.'</td>'; print '<tr><td>'.$i.'</td>';
print '<td><input size="50" name="label'.$i.'" value="'.$value_label.'" type="text"></td>'; print '<td><input size="50" name="label'.$i.'" value="'.$value_label.'" type="text"></td>';
print '<td align="right"><input type="text" size="8" name="amount'.$i.'" value="'.$value_pu.'"></td>'; print '<td align="right"><input type="text" size="8" name="amount'.$i.'" value="'.$value_pu.'"></td>';
print '<td align="right">'; print '<td align="right">';
print $html->load_tva('tauxtva'.$i,$value_tauxtva,$societe,$mysoc); print $html->load_tva('tauxtva'.$i,$value_tauxtva,$societe,$mysoc);
print '</td>'; print '</td>';
print '<td align="right"><input type="text" size="3" name="qty'.$i.'" value="'.$value_qty.'"></td>'; print '<td align="right"><input type="text" size="3" name="qty'.$i.'" value="'.$value_qty.'"></td>';
print '<td align="right"><input type="text" size="8" name="amountttc'.$i.'" value=""></td></tr>'; print '<td align="right"><input type="text" size="8" name="amountttc'.$i.'" value=""></td></tr>';
} }
} }
} }
// Bouton "Create Draft" // Bouton "Create Draft"
print "</table>\n"; print "</table>\n";
print '<br><center><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></center>'; print '<br><center><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></center>';
print "</form>\n"; print "</form>\n";
// Show origin lines
if (is_object($objectsrc))
{
print '<br>';
$title=$langs->trans('ProductsAndServices');
print_titre($title);
print '<table class="noborder" width="100%">';
$objectsrc->printOriginLinesList($hookmanager);
print '</table>';
}
} }
else else
{ {
@ -1212,7 +1227,7 @@ else
{ {
/* /*
* View card * View card
*/ */
$head = facturefourn_prepare_head($fac); $head = facturefourn_prepare_head($fac);
$titre=$langs->trans('SupplierInvoice'); $titre=$langs->trans('SupplierInvoice');
dol_fiche_head($head, 'card', $titre, 0, 'bill'); dol_fiche_head($head, 'card', $titre, 0, 'bill');
@ -1255,7 +1270,7 @@ else
/* /*
* Confirmation de la suppression de la facture fournisseur * Confirmation de la suppression de la facture fournisseur
*/ */
if ($_GET['action'] == 'delete') if ($_GET['action'] == 'delete')
{ {
$ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete', '', 0, 1); $ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete', '', 0, 1);
@ -1265,7 +1280,7 @@ else
/* /*
* Facture * Facture
*/ */
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
@ -1331,7 +1346,7 @@ else
/* /*
* List of payments * List of payments
*/ */
$nbrows=7; $nbrows=7;
if ($conf->projet->enabled) $nbrows++; if ($conf->projet->enabled) $nbrows++;
@ -1484,7 +1499,7 @@ else
/* /*
* Lines * Lines
*/ */
print '<br>'; print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
$var=1; $var=1;
@ -1636,7 +1651,7 @@ else
/* /*
* Form to add new line * Form to add new line
*/ */
if ($fac->statut == 0 && $_GET['action'] != 'mod_ligne') if ($fac->statut == 0 && $_GET['action'] != 'mod_ligne')
{ {
@ -1743,7 +1758,7 @@ else
/* /*
* Boutons actions * Boutons actions
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
@ -1830,7 +1845,7 @@ else
/* /*
* Documents generes * Documents generes
*/ */
$ref=dol_sanitizeFileName($fac->ref); $ref=dol_sanitizeFileName($fac->ref);
$subdir = get_exdir($fac->id,2).$ref; $subdir = get_exdir($fac->id,2).$ref;
@ -1846,7 +1861,7 @@ else
/* /*
* Linked object block * Linked object block
*/ */
$somethingshown=$object->showLinkedObjectBlock(); $somethingshown=$object->showLinkedObjectBlock();
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';