| '.$langs->trans('Discounts');
+ print ' | ';
+ if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
+ else print $langs->trans("CompanyHasNoRelativeDiscount");
+ //print ' ('.$addrelativediscount.')';
+
+ if ($absolute_discount > 0)
+ {
+ print '. ';
+ if ($object->statut > 0 || $object->type == 2 || $object->type == 3)
+ {
+ if ($object->statut == 0)
{
- $facturereplacement=new Facture($db);
- $facturereplacement->fetch($objectidnext);
- $statusreplacement=$facturereplacement->statut;
- }
- if ($objectidnext && $statusreplacement == 0)
- {
- print ' '.$langs->trans("ErrorCantCancelIfReplacementInvoiceNotValidated").' ';
+ print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
+ print '. ';
}
else
{
- // Code
- $close[1]['code']='badcustomer';
- $close[2]['code']='abandon';
- // Help
- $close[1]['label']=$langs->trans("ConfirmClassifyPaidPartiallyReasonBadCustomerDesc");
- $close[2]['label']=$langs->trans("ConfirmClassifyAbandonReasonOtherDesc");
- // Texte
- $close[1]['reason']=$form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadCustomer",$object->ref),$close[1]['label'],1);
- $close[2]['reason']=$form->textwithpicto($langs->transnoentities("ConfirmClassifyAbandonReasonOther"),$close[2]['label'],1);
- // arrayreasons
- $arrayreasons[$close[1]['code']]=$close[1]['reason'];
- $arrayreasons[$close[2]['code']]=$close[2]['reason'];
-
- // Cree un tableau formulaire
- $formquestion=array(
- 'text' => $langs->trans("ConfirmCancelBillQuestion"),
- array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons),
- array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'size' => '100')
- );
-
- $formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('CancelBill'),$langs->trans('ConfirmCancelBill',$object->ref),'confirm_canceled',$formquestion,"yes");
- }
- }
-
- // Confirmation de la suppression d'une ligne produit
- if ($action == 'ask_deleteline')
- {
- $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1);
- }
-
- // Clone confirmation
- if ($action == 'clone')
- {
- // Create an array for form
- $formquestion=array(
- //'text' => $langs->trans("ConfirmClone"),
- //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1)
- );
- // Paiement incomplet. On demande si motif = escompte ou autre
- $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$object->ref),'confirm_clone',$formquestion,'yes',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;
-
-
- // Invoice content
-
- print '';
-
- $linkback = ''.$langs->trans("BackToList").'';
-
- // Ref
- print '| '.$langs->trans('Ref').' | ';
- print '';
- $morehtmlref='';
- $discount=new DiscountAbsolute($db);
- $result=$discount->fetch(0,$object->id);
- if ($result > 0)
- {
- $morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')';
- }
- if ($result < 0)
- {
- dol_print_error('',$discount->error);
- }
- print $form->showrefnav($object, 'ref', $linkback, 1, 'facnumber', 'ref', $morehtmlref);
- print ' | ';
-
- // Ref customer
- print '| ';
- print '';
- print ' | ';
- print '';
- if ($user->rights->facture->creer && $action == 'refclient')
- {
- print '';
- }
- else
- {
- print $object->ref_client;
- }
- print ' | ';
-
- // Third party
- print '| ';
- print '';
- print ' | ';
- if ($action == 'editthirdparty')
- {
- $form->form_thirdparty($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->socid,'socid');
- }
- else
- {
- print ' '.$soc->getNomUrl(1,'compta');
- print ' ('.$langs->trans('OtherBills').')';
- }
- print ' | ';
-
- // Type
- print '| '.$langs->trans('Type').' | ';
- print $object->getLibType();
- if ($object->type == 1)
- {
- $facreplaced=new Facture($db);
- $facreplaced->fetch($object->fk_facture_source);
- print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')';
- }
- if ($object->type == 2)
- {
- $facusing=new Facture($db);
- $facusing->fetch($object->fk_facture_source);
- print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')';
- }
-
- $facidavoir=$object->getListIdAvoirFromInvoice();
- if (count($facidavoir) > 0)
- {
- print ' ('.$langs->transnoentities("InvoiceHasAvoir");
- $i=0;
- foreach($facidavoir as $id)
- {
- if ($i==0) print ' ';
- else print ',';
- $facavoir=new Facture($db);
- $facavoir->fetch($id);
- print $facavoir->getNomUrl(1);
- }
- print ')';
- }
- if ($objectidnext > 0)
- {
- $facthatreplace=new Facture($db);
- $facthatreplace->fetch($objectidnext);
- print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')';
- }
- print ' | ';
-
- // Relative and absolute discounts
- $addrelativediscount='id.'">'.$langs->trans("EditRelativeDiscounts").'';
- $addabsolutediscount='id.'">'.$langs->trans("EditGlobalDiscounts").'';
- $addcreditnote='id.'">'.$langs->trans("AddCreditNote").'';
-
- print '| '.$langs->trans('Discounts');
- print ' | ';
- if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
- else print $langs->trans("CompanyHasNoRelativeDiscount");
- //print ' ('.$addrelativediscount.')';
-
- if ($absolute_discount > 0)
- {
- print '. ';
- if ($object->statut > 0 || $object->type == 2 || $object->type == 3)
- {
- if ($object->statut == 0)
+ if ($object->statut < 1 || $object->type == 2 || $object->type == 3)
{
- print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
- print '. ';
+ $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
+ print ' '.$text.'. ';
}
else
{
- if ($object->statut < 1 || $object->type == 2 || $object->type == 3)
- {
- $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
- print ' '.$text.'. ';
- }
- else
- {
- $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
- $text2=$langs->trans("AbsoluteDiscountUse");
- print $form->textwithpicto($text,$text2);
- }
+ $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
+ $text2=$langs->trans("AbsoluteDiscountUse");
+ print $form->textwithpicto($text,$text2);
}
}
- else
- {
- // Remise dispo de type remise fixe (not credit note)
- print ' ';
- $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, GETPOST('discountid'), 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, $resteapayer, ' ('.$addabsolutediscount.')');
- }
}
else
{
- if ($absolute_creditnote > 0) // If not, link will be added later
- {
- if ($object->statut == 0 && $object->type != 2 && $object->type != 3) print ' ('.$addabsolutediscount.') ';
- else print '. ';
- }
- else print '. ';
+ // Remise dispo de type remise fixe (not credit note)
+ print ' ';
+ $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, GETPOST('discountid'), 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, $resteapayer, ' ('.$addabsolutediscount.')');
}
- if ($absolute_creditnote > 0)
+ }
+ else
+ {
+ if ($absolute_creditnote > 0) // If not, link will be added later
{
- // If validated, we show link "add credit note to payment"
- if ($object->statut != 1 || $object->type == 2 || $object->type == 3)
- {
- if ($object->statut == 0 && $object->type != 3)
- {
- $text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency));
- print $form->textwithpicto($text,$langs->trans("CreditNoteDepositUse"));
- }
- else
- {
- print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)).'.';
- }
- }
- else
- {
- // Remise dispo de type avoir
- if (! $absolute_discount) print ' ';
- //$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer);
- $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, 0); // We must allow credit not even if amount is higher
- }
- }
- if (! $absolute_discount && ! $absolute_creditnote)
- {
- print $langs->trans("CompanyHasNoAbsoluteDiscount");
if ($object->statut == 0 && $object->type != 2 && $object->type != 3) print ' ('.$addabsolutediscount.') ';
else print '. ';
}
- /*if ($object->statut == 0 && $object->type != 2 && $object->type != 3)
- {
- if (! $absolute_discount && ! $absolute_creditnote) print ' ';
- //print ' - ';
- print $addabsolutediscount;
- //print ' - '.$addcreditnote; // We disbale link to credit note
- }*/
- print ' | ';
-
- // Date invoice
- print '';
- print '| ';
- print $langs->trans('Date');
- print ' | ';
- if ($object->type != 2 && $action != 'editinvoicedate' && ! empty($object->brouillon) && $user->rights->facture->creer) print 'id.'">'.img_edit($langs->trans('SetDate'),1).' | ';
- print ' ';
- print ' | ';
-
- if ($object->type != 2)
+ else print '. ';
+ }
+ if ($absolute_creditnote > 0)
+ {
+ // If validated, we show link "add credit note to payment"
+ if ($object->statut != 1 || $object->type == 2 || $object->type == 3)
{
- if ($action == 'editinvoicedate')
+ if ($object->statut == 0 && $object->type != 3)
{
- $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->date,'invoicedate');
+ $text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency));
+ print $form->textwithpicto($text,$langs->trans("CreditNoteDepositUse"));
}
else
{
- print dol_print_date($object->date,'daytext');
+ print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)).'.';
}
}
else
+ {
+ // Remise dispo de type avoir
+ if (! $absolute_discount) print ' ';
+ //$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer);
+ $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, 0); // We must allow credit not even if amount is higher
+ }
+ }
+ if (! $absolute_discount && ! $absolute_creditnote)
+ {
+ print $langs->trans("CompanyHasNoAbsoluteDiscount");
+ if ($object->statut == 0 && $object->type != 2 && $object->type != 3) print ' ('.$addabsolutediscount.') ';
+ else print '. ';
+ }
+ /*if ($object->statut == 0 && $object->type != 2 && $object->type != 3)
+ {
+ if (! $absolute_discount && ! $absolute_creditnote) print ' ';
+ //print ' - ';
+ print $addabsolutediscount;
+ //print ' - '.$addcreditnote; // We disbale link to credit note
+ }*/
+ print ' | ';
+
+ // Date invoice
+ print '';
+ print '| ';
+ print $langs->trans('Date');
+ print ' | ';
+ if ($object->type != 2 && $action != 'editinvoicedate' && ! empty($object->brouillon) && $user->rights->facture->creer) print 'id.'">'.img_edit($langs->trans('SetDate'),1).' | ';
+ print ' ';
+ print ' | ';
+
+ if ($object->type != 2)
+ {
+ if ($action == 'editinvoicedate')
+ {
+ $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->date,'invoicedate');
+ }
+ else
{
print dol_print_date($object->date,'daytext');
}
- print ' | ';
+ }
+ else
+ {
+ print dol_print_date($object->date,'daytext');
+ }
+ print '';
- /*
- * List of payments
- */
+ /*
+ * List of payments
+ */
- $sign=1;
- if ($object->type == 2) $sign=-1;
+ $sign=1;
+ if ($object->type == 2) $sign=-1;
- $nbrows=8; $nbcols=2;
- if (! empty($conf->projet->enabled)) $nbrows++;
- if (! empty($conf->banque->enabled)) $nbcols++;
- if($mysoc->localtax1_assuj=="1") $nbrows++;
- if($mysoc->localtax2_assuj=="1") $nbrows++;
- if ($selleruserevenustamp) $nbrows++;
+ $nbrows=8; $nbcols=2;
+ if (! empty($conf->projet->enabled)) $nbrows++;
+ if (! empty($conf->banque->enabled)) $nbcols++;
+ if($mysoc->localtax1_assuj=="1") $nbrows++;
+ if($mysoc->localtax2_assuj=="1") $nbrows++;
+ if ($selleruserevenustamp) $nbrows++;
- print '';
+ print ' | ';
- print '';
+ print '';
- // List of payments already done
- print '';
- print '| '.($object->type == 2 ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).' | ';
- print ''.$langs->trans('Type').' | ';
- if (! empty($conf->banque->enabled)) print ''.$langs->trans('BankAccount').' | ';
- print ''.$langs->trans('Amount').' | ';
- print ' | ';
- print ' ';
+ // List of payments already done
+ print '';
+ print '| '.($object->type == 2 ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).' | ';
+ print ''.$langs->trans('Type').' | ';
+ if (! empty($conf->banque->enabled)) print ''.$langs->trans('BankAccount').' | ';
+ print ''.$langs->trans('Amount').' | ';
+ print ' | ';
+ print ' ';
- $var=true;
+ $var=true;
- // Payments already done (from payment on this invoice)
- $sql = 'SELECT p.datep as dp, p.num_paiement, p.rowid, p.fk_bank,';
- $sql.= ' c.code as payment_code, c.libelle as payment_label,';
- $sql.= ' pf.amount,';
- $sql.= ' ba.rowid as baid, ba.ref, ba.label';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
- $sql.= ' WHERE pf.fk_facture = '.$object->id.' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid';
- $sql.= ' ORDER BY p.datep, p.tms';
+ // Payments already done (from payment on this invoice)
+ $sql = 'SELECT p.datep as dp, p.num_paiement, p.rowid, p.fk_bank,';
+ $sql.= ' c.code as payment_code, c.libelle as payment_label,';
+ $sql.= ' pf.amount,';
+ $sql.= ' ba.rowid as baid, ba.ref, ba.label';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
+ $sql.= ' WHERE pf.fk_facture = '.$object->id.' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid';
+ $sql.= ' ORDER BY p.datep, p.tms';
- $result = $db->query($sql);
- if ($result)
+ $result = $db->query($sql);
+ if ($result)
+ {
+ $num = $db->num_rows($result);
+ $i = 0;
+
+ //if ($object->type != 2)
+ //{
+ if ($num > 0)
{
- $num = $db->num_rows($result);
- $i = 0;
-
- //if ($object->type != 2)
- //{
- if ($num > 0)
+ while ($i < $num)
{
+ $objp = $db->fetch_object($result);
+ $var=!$var;
+ print '| ';
+ print ''.img_object($langs->trans('ShowPayment'),'payment').' ';
+ print dol_print_date($db->jdate($objp->dp),'day').' | ';
+ $label=($langs->trans("PaymentType".$objp->payment_code)!=("PaymentType".$objp->payment_code))?$langs->trans("PaymentType".$objp->payment_code):$objp->payment_label;
+ print ''.$label.' '.$objp->num_paiement.' | ';
+ if (! empty($conf->banque->enabled))
+ {
+ $bankaccountstatic->id=$objp->baid;
+ $bankaccountstatic->ref=$objp->ref;
+ $bankaccountstatic->label=$objp->ref;
+ print '';
+ if ($bankaccountstatic->id) print $bankaccountstatic->getNomUrl(1,'transactions');
+ print ' | ';
+ }
+ print ''.price($sign * $objp->amount).' | ';
+ print ' | ';
+ print ' ';
+ $i++;
+ }
+ }
+ else
+ {
+ print '| '.$langs->trans("None").' | | | ';
+ }
+ //}
+ $db->free($result);
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+
+ if ($object->type != 2)
+ {
+ // Total already paid
+ print '| ';
+ if ($object->type != 3) print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits');
+ else print $langs->trans('AlreadyPaid');
+ print ' : | '.price($totalpaye).' | | ';
+
+ $resteapayeraffiche=$resteapayer;
+
+ // Loop on each credit note or deposit amount applied
+ $creditnoteamount=0;
+ $depositamount=0;
+ $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
+ $sql.= " re.description, re.fk_facture_source";
+ $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
+ $sql.= " WHERE fk_facture = ".$object->id;
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+ $invoice=new Facture($db);
while ($i < $num)
{
- $objp = $db->fetch_object($result);
- $var=!$var;
- print '| ';
- print ''.img_object($langs->trans('ShowPayment'),'payment').' ';
- print dol_print_date($db->jdate($objp->dp),'day').' | ';
- $label=($langs->trans("PaymentType".$objp->payment_code)!=("PaymentType".$objp->payment_code))?$langs->trans("PaymentType".$objp->payment_code):$objp->payment_label;
- print ''.$label.' '.$objp->num_paiement.' | ';
- if (! empty($conf->banque->enabled))
- {
- $bankaccountstatic->id=$objp->baid;
- $bankaccountstatic->ref=$objp->ref;
- $bankaccountstatic->label=$objp->ref;
- print '';
- if ($bankaccountstatic->id) print $bankaccountstatic->getNomUrl(1,'transactions');
- print ' | ';
- }
- print ''.price($sign * $objp->amount).' | ';
- print ' | ';
- print ' ';
+ $obj = $db->fetch_object($resql);
+ $invoice->fetch($obj->fk_facture_source);
+ print '| ';
+ if ($invoice->type == 2) print $langs->trans("CreditNote").' ';
+ if ($invoice->type == 3) print $langs->trans("Deposit").' ';
+ print $invoice->getNomUrl(0);
+ print ' : | ';
+ print ''.price($obj->amount_ttc).' | ';
+ print '';
+ print 'id.'&action=unlinkdiscount&discountid='.$obj->rowid.'">'.img_delete().'';
+ print ' | ';
$i++;
+ if ($invoice->type == 2) $creditnoteamount += $obj->amount_ttc;
+ if ($invoice->type == 3) $depositamount += $obj->amount_ttc;
}
}
else
- {
- print '| '.$langs->trans("None").' | | | ';
- }
- //}
- $db->free($result);
- }
- else
{
dol_print_error($db);
}
- if ($object->type != 2)
+ // Paye partiellement 'escompte'
+ if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'discount_vat')
{
- // Total already paid
- print '| ';
- if ($object->type != 3) print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits');
- else print $langs->trans('AlreadyPaid');
- print ' : | '.price($totalpaye).' | | ';
-
- $resteapayeraffiche=$resteapayer;
-
- // Loop on each credit note or deposit amount applied
- $creditnoteamount=0;
- $depositamount=0;
- $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
- $sql.= " re.description, re.fk_facture_source";
- $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
- $sql.= " WHERE fk_facture = ".$object->id;
- $resql=$db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0;
- $invoice=new Facture($db);
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
- $invoice->fetch($obj->fk_facture_source);
- print '| ';
- if ($invoice->type == 2) print $langs->trans("CreditNote").' ';
- if ($invoice->type == 3) print $langs->trans("Deposit").' ';
- print $invoice->getNomUrl(0);
- print ' : | ';
- print ''.price($obj->amount_ttc).' | ';
- print '';
- print 'id.'&action=unlinkdiscount&discountid='.$obj->rowid.'">'.img_delete().'';
- print ' | ';
- $i++;
- if ($invoice->type == 2) $creditnoteamount += $obj->amount_ttc;
- if ($invoice->type == 3) $depositamount += $obj->amount_ttc;
- }
- }
- else
- {
- dol_print_error($db);
- }
-
- // Paye partiellement 'escompte'
- if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'discount_vat')
- {
- print '| ';
- print $form->textwithpicto($langs->trans("Discount").':',$langs->trans("HelpEscompte"),-1);
- print ' | '.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' | | ';
- $resteapayeraffiche=0;
- }
- // Paye partiellement ou Abandon 'badcustomer'
- if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'badcustomer')
- {
- print '| ';
- print $form->textwithpicto($langs->trans("Abandoned").':',$langs->trans("HelpAbandonBadCustomer"),-1);
- print ' | '.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' | | ';
- //$resteapayeraffiche=0;
- }
- // Paye partiellement ou Abandon 'product_returned'
- if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'product_returned')
- {
- print '| ';
- print $form->textwithpicto($langs->trans("ProductReturned").':',$langs->trans("HelpAbandonProductReturned"),-1);
- print ' | '.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' | | ';
- $resteapayeraffiche=0;
- }
- // Paye partiellement ou Abandon 'abandon'
- if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'abandon')
- {
- print '';
- $text=$langs->trans("HelpAbandonOther");
- if ($object->close_note) $text.='
'.$langs->trans("Reason").':'.$object->close_note;
- print $form->textwithpicto($langs->trans("Abandoned").':',$text,-1);
- print ' | '.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' | | ';
- $resteapayeraffiche=0;
- }
-
- // Billed
- print '| '.$langs->trans("Billed").' : | '.price($object->total_ttc).' | | ';
-
- // Remainder to pay
- print '| ';
- if ($resteapayeraffiche >= 0) print $langs->trans('RemainderToPay');
- else print $langs->trans('ExcessReceived');
- print ' : | ';
- print ''.price($resteapayeraffiche).' | ';
- print ' | ';
+ print '| ';
+ print $form->textwithpicto($langs->trans("Discount").':',$langs->trans("HelpEscompte"),-1);
+ print ' | '.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' | | ';
+ $resteapayeraffiche=0;
}
- else // Credit note
+ // Paye partiellement ou Abandon 'badcustomer'
+ if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'badcustomer')
{
- // Total already paid back
- print '| ';
- print $langs->trans('AlreadyPaidBack');
- print ' : | '.price($sign * $totalpaye).' | | ';
-
- // Billed
- print '| '.$langs->trans("Billed").' : | '.price($sign * $object->total_ttc).' | | ';
-
- // Remainder to pay back
- print '| ';
- if ($resteapayeraffiche <= 0) print $langs->trans('RemainderToPayBack');
- else print $langs->trans('ExcessPaydBack');
- print ' : | ';
- print ''.price($sign * $resteapayeraffiche).' | ';
- print ' | ';
-
- // Sold credit note
- //print '| '.$langs->trans('TotalTTC').' : | ';
- //print ''.price($sign * $object->total_ttc).' | | ';
+ print '| ';
+ print $form->textwithpicto($langs->trans("Abandoned").':',$langs->trans("HelpAbandonBadCustomer"),-1);
+ print ' | '.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' | | ';
+ //$resteapayeraffiche=0;
+ }
+ // Paye partiellement ou Abandon 'product_returned'
+ if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'product_returned')
+ {
+ print '| ';
+ print $form->textwithpicto($langs->trans("ProductReturned").':',$langs->trans("HelpAbandonProductReturned"),-1);
+ print ' | '.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' | | ';
+ $resteapayeraffiche=0;
+ }
+ // Paye partiellement ou Abandon 'abandon'
+ if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'abandon')
+ {
+ print '';
+ $text=$langs->trans("HelpAbandonOther");
+ if ($object->close_note) $text.='
'.$langs->trans("Reason").':'.$object->close_note;
+ print $form->textwithpicto($langs->trans("Abandoned").':',$text,-1);
+ print ' | '.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' | | ';
+ $resteapayeraffiche=0;
}
- print ' ';
+ // Billed
+ print '| '.$langs->trans("Billed").' : | '.price($object->total_ttc).' | | ';
- // Margin Infos
- if (! empty($conf->margin->enabled))
+ // Remainder to pay
+ print '| ';
+ if ($resteapayeraffiche >= 0) print $langs->trans('RemainderToPay');
+ else print $langs->trans('ExcessReceived');
+ print ' : | ';
+ print ''.price($resteapayeraffiche).' | ';
+ print ' | ';
+ }
+ else // Credit note
+ {
+ // Total already paid back
+ print '| ';
+ print $langs->trans('AlreadyPaidBack');
+ print ' : | '.price($sign * $totalpaye).' | | ';
+
+ // Billed
+ print '| '.$langs->trans("Billed").' : | '.price($sign * $object->total_ttc).' | | ';
+
+ // Remainder to pay back
+ print '| ';
+ if ($resteapayeraffiche <= 0) print $langs->trans('RemainderToPayBack');
+ else print $langs->trans('ExcessPaydBack');
+ print ' : | ';
+ print ''.price($sign * $resteapayeraffiche).' | ';
+ print ' | ';
+
+ // Sold credit note
+ //print '| '.$langs->trans('TotalTTC').' : | ';
+ //print ''.price($sign * $object->total_ttc).' | | ';
+ }
+
+ print ' ';
+
+ // Margin Infos
+ if (! empty($conf->margin->enabled))
+ {
+ print ' ';
+ $object->displayMarginInfos($object->statut > 0);
+ }
+
+ print ' | ';
+
+ // Conditions de reglement
+ print '| ';
+ print '';
+ print ' | ';
+ if ($object->type != 2)
+ {
+ if ($action == 'editconditions')
{
- print ' ';
- $object->displayMarginInfos($object->statut > 0);
- }
-
- print ' | ';
-
- // Conditions de reglement
- print '| ';
- print '';
- print ' | ';
- if ($object->type != 2)
- {
- if ($action == 'editconditions')
- {
- $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
- }
- else
- {
- $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->cond_reglement_id,'none');
- }
+ $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
}
else
{
- print ' ';
+ $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->cond_reglement_id,'none');
}
- print ' | ';
+ }
+ else
+ {
+ print ' ';
+ }
+ print '';
- // Date payment term
- print '';
- print '| ';
- print $langs->trans('DateMaxPayment');
- print ' | ';
- if ($object->type != 2 && $action != 'editpaymentterm' && ! empty($object->brouillon) && $user->rights->facture->creer) print 'id.'">'.img_edit($langs->trans('SetDate'),1).' | ';
- print ' ';
- print ' | ';
- if ($object->type != 2)
+ // Date payment term
+ print ' | ';
+ print '| ';
+ print $langs->trans('DateMaxPayment');
+ print ' | ';
+ if ($object->type != 2 && $action != 'editpaymentterm' && ! empty($object->brouillon) && $user->rights->facture->creer) print 'id.'">'.img_edit($langs->trans('SetDate'),1).' | ';
+ print ' ';
+ print ' | ';
+ if ($object->type != 2)
+ {
+ if ($action == 'editpaymentterm')
{
- if ($action == 'editpaymentterm')
- {
- $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->date_lim_reglement,'paymentterm');
- }
- else
- {
- print dol_print_date($object->date_lim_reglement,'daytext');
- if ($object->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $object->paye && $object->statut == 1 && ! isset($object->am)) print img_warning($langs->trans('Late'));
- }
+ $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->date_lim_reglement,'paymentterm');
}
else
{
- print ' ';
+ print dol_print_date($object->date_lim_reglement,'daytext');
+ if ($object->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $object->paye && $object->statut == 1 && ! isset($object->am)) print img_warning($langs->trans('Late'));
}
- print ' | ';
+ }
+ else
+ {
+ print ' ';
+ }
+ print '';
- // Payment mode
+ // Payment mode
+ print '| ';
+ print '';
+ print ' | ';
+ if ($action == 'editmode')
+ {
+ $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
+ }
+ else
+ {
+ $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->mode_reglement_id,'none');
+ }
+ print ' | ';
+
+ // Amount
+ print '| '.$langs->trans('AmountHT').' | ';
+ print ''.price($object->total_ht,1,'',1,-1,-1,$conf->currency).' | ';
+ print '| '.$langs->trans('AmountVAT').' | '.price($object->total_tva,1,'',1,-1,-1,$conf->currency).' | ';
+ print '';
+
+ // Amount Local Taxes
+ if ($mysoc->localtax1_assuj=="1" && $mysoc->useLocalTax(1)) //Localtax1 (example RE)
+ {
+ print '| '.$langs->transcountry("AmountLT1",$mysoc->country_code).' | ';
+ print ''.price($object->total_localtax1,1,'',1,-1,-1,$conf->currency).' | ';
+ }
+ if ($mysoc->localtax2_assuj=="1" && $mysoc->useLocalTax(2)) //Localtax2 (example IRPF)
+ {
+ print '| '.$langs->transcountry("AmountLT2",$mysoc->country_code).' | ';
+ print ''.price($object->total_localtax2,1,'',1,-1,-1,$conf->currency).' | ';
+ }
+
+ // Revenue stamp
+ if ($selleruserevenustamp) // Test company use revenue stamp
+ {
print '| ';
print '';
- print ' | ';
- if ($action == 'editmode')
+ print ' | ';
+ if ($action == 'editrevenuestamp')
{
- $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
+ print '';
}
else
{
- $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->mode_reglement_id,'none');
+ print price($object->revenuestamp,1,'',1,-1,-1,$conf->currency);
}
print ' | ';
+ }
- // Amount
- print '| '.$langs->trans('AmountHT').' | ';
- print ''.price($object->total_ht,1,'',1,-1,-1,$conf->currency).' | ';
- print '| '.$langs->trans('AmountVAT').' | '.price($object->total_tva,1,'',1,-1,-1,$conf->currency).' | ';
+ // Total with tax
+ print '| '.$langs->trans('AmountTTC').' | '.price($object->total_ttc,1,'',1,-1,-1,$conf->currency).' | ';
+
+ // Statut
+ print '| '.$langs->trans('Status').' | ';
+ print ''.($object->getLibStatut(4,$totalpaye)).' | ';
+
+ // Project
+ if (! empty($conf->projet->enabled))
+ {
+ $langs->load('projects');
+ print '';
+ print '| ';
+
+ print '';
+
+ print ' | ';
+ if ($action == 'classify')
+ {
+ $form->form_project($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->socid,$object->fk_project,'projectid');
+ }
+ else
+ {
+ $form->form_project($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->socid,$object->fk_project,'none');
+ }
+ print ' | ';
print ' ';
+ }
- // Amount Local Taxes
- if ($mysoc->localtax1_assuj=="1" && $mysoc->useLocalTax(1)) //Localtax1 (example RE)
+ // Other attributes
+ $res=$object->fetch_optionals($object->id,$extralabels);
+ $parameters=array('colspan' => ' colspan="2"');
+ $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook) && ! empty($extrafields->attribute_label))
+ {
+
+ if ($action == 'edit_extras')
{
- print '| '.$langs->transcountry("AmountLT1",$mysoc->country_code).' | ';
- print ''.price($object->total_localtax1,1,'',1,-1,-1,$conf->currency).' | ';
- }
- if ($mysoc->localtax2_assuj=="1" && $mysoc->useLocalTax(2)) //Localtax2 (example IRPF)
- {
- print '| '.$langs->transcountry("AmountLT2",$mysoc->country_code).' | ';
- print ''.price($object->total_localtax2,1,'',1,-1,-1,$conf->currency).' | ';
+ print ' ';
-
- if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
- {
- $blocname = 'contacts';
- $title = $langs->trans('ContactsAddresses');
- include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
- }
-
- if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
- {
- $blocname = 'notes';
- $title = $langs->trans('Notes');
- include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
- }
-
- /*
- * Lines
- */
- $result = $object->getLinesArray();
-
- if (! empty($conf->use_javascript_ajax) && $object->statut == 0)
- {
- include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
- }
-
- print '';
-
- // Show object lines
- if (! empty($object->lines))
- $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1);
-
- /*
- * Form to add new line
- */
- if ($object->statut == 0 && $user->rights->facture->creer && $action <> 'valid' && $action <> 'editline')
- {
- $var=true;
-
- if ($conf->global->MAIN_FEATURES_LEVEL > 1)
- {
- // Add free or predefined products/services
- $object->formAddObjectLine(1,$mysoc,$soc);
- }
- else
- {
- // Add free products/services
- $object->formAddFreeProduct(1,$mysoc,$soc);
-
- // Add predefined products/services
- if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
+ else
{
- $var=!$var;
- $object->formAddPredefinedProduct(1,$mysoc,$soc);
+ print $extrafields->showOutputField($key,$value);
}
+ print ''."\n";
}
-
- $parameters=array();
- $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
}
- print " \n";
+ if(count($extrafields->attribute_label) > 0) {
- print "\n";
-
-
- /*
- * Boutons actions
- */
-
- if ($action != 'prerelance' && $action != 'presend')
- {
- if ($user->societe_id == 0 && $action <> 'valid' && $action <> 'editline')
+ if ($action == 'edit_extras' && $user->rights->facture->creer)
{
- print '';
+ print ' | ';
+ print '';
+ print '';
+ print ' | ';
- // Editer une facture deja validee, sans paiement effectue et pas exporte en compta
- if ($object->statut == 1)
+ }
+ else {
+ if ($object->statut == 0 && $user->rights->facture->creer)
{
- // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
- $ventilExportCompta = $object->getVentilExportCompta();
+ print ' | '.img_picto('','edit').' '.$langs->trans('Modify').' | ';
+ }
+ }
+ }
+ }
- if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0)
+ print ' |