diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php index 1b9d680729e..421e677b3d7 100644 --- a/htdocs/admin/tools/eaccelerator.php +++ b/htdocs/admin/tools/eaccelerator.php @@ -262,7 +262,7 @@ $var=true; > Cached keys - + commande->enabled)) require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'); -if (! empty($conf->projet->enabled)) -{ - require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); - require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); +require '../main.inc.php'; +require DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; +require DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; +require DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; +require DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; +require DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; + +if (! empty($conf->commande->enabled)) { + require DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; +} +if (! empty($conf->projet->enabled)) { + require DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; + require DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php'; } $langs->load('bills'); -//print 'ee'.$langs->trans('BillsCustomer');exit; - $langs->load('companies'); $langs->load('products'); $langs->load('main'); @@ -2374,7 +2374,7 @@ else if ($id > 0 || ! empty($ref)) print ''; - if ($action != 'refclient' && $object->brouillon) print ''; + if ($action != 'refclient' && ! empty($object->brouillon)) print ''; print '
'; print $langs->trans('RefCustomer'); print ''.img_edit($langs->trans('Modify')).''.img_edit($langs->trans('Modify')).'
'; print ''; print ''; @@ -2547,7 +2547,7 @@ else if ($id > 0 || ! empty($ref)) print ''; - if ($object->type != 2 && $action != 'editinvoicedate' && $object->brouillon && $user->rights->facture->creer) print ''; + if ($object->type != 2 && $action != 'editinvoicedate' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; print '
'; print $langs->trans('Date'); print 'id.'">'.img_edit($langs->trans('SetDate'),1).'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; print ''; @@ -2770,7 +2770,7 @@ else if ($id > 0 || ! empty($ref)) print ''; - if ($object->type != 2 && $action != 'editpaymentterm' && $object->brouillon && $user->rights->facture->creer) print ''; + if ($object->type != 2 && $action != 'editpaymentterm' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; print '
'; print $langs->trans('DateMaxPayment'); print 'id.'">'.img_edit($langs->trans('SetDate'),1).'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; print ''; if ($object->type != 2) @@ -2782,7 +2782,7 @@ else if ($id > 0 || ! empty($ref)) 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 && ! $object->am) print img_warning($langs->trans('Late')); + 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')); } } else @@ -2796,7 +2796,7 @@ else if ($id > 0 || ! empty($ref)) print ''; - if ($object->type != 2 && $action != 'editconditions' && $object->brouillon && $user->rights->facture->creer) print ''; + if ($object->type != 2 && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; print '
'; print $langs->trans('PaymentConditionsShort'); print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; print ''; if ($object->type != 2) @@ -2821,7 +2821,7 @@ else if ($id > 0 || ! empty($ref)) print ''; - if ($action != 'editmode' && $object->brouillon && $user->rights->facture->creer) print ''; + if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'),1).'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; print ''; if ($action == 'editmode') @@ -2868,7 +2868,7 @@ else if ($id > 0 || ! empty($ref)) print ''.($object->getLibStatut(4,$totalpaye)).''; // Project - if ($conf->projet->enabled) + if (! empty($conf->projet->enabled)) { $langs->load('projects'); print ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 87405b5e0be..6e7c1ac9043 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2996,12 +2996,10 @@ class Facture extends CommonInvoice function getLinesArray() { $sql = 'SELECT l.rowid, l.description, l.fk_product, l.product_type, l.qty, l.tva_tx,'; - $sql.= ' l.fk_remise_except,'; + $sql.= ' l.fk_remise_except, localtax1_tx, localtax2_tx,'; $sql.= ' l.remise_percent, l.subprice, l.info_bits, l.rang, l.special_code, l.fk_parent_line,'; $sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; - $sql.= ' l.date_start,'; - $sql.= ' l.date_end,'; - $sql.= ' l.product_type,'; + $sql.= ' l.date_start, l.date_end,'; $sql.= ' p.ref as product_ref, p.fk_product_type, p.label as product_label,'; $sql.= ' p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 05750bb2238..55a1b536fda 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -38,10 +38,11 @@ $langs->load('other'); $langs->load("bills"); -$action = GETPOST('action'); -$confirm = GETPOST('confirm'); -$id = GETPOST('facid','int'); -$ref = GETPOST('ref'); +$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility +$ref=GETPOST('ref','alpha'); +$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm', 'alpha'); // Security check if ($user->societe_id) @@ -70,7 +71,7 @@ $object = new Facture($db); */ // Envoi fichier -if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) { if ($object->fetch($id)) { @@ -106,8 +107,6 @@ llxHeader(); $form = new Form($db); -$id = $_GET['facid']?$_GET['facid']:$_GET['id']; -$ref= $_GET['ref']; if ($id > 0 || ! empty($ref)) { if ($object->fetch($id,$ref) > 0) diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 47f6c7ff0f8..ab3b2ba3d8a 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -1,8 +1,9 @@ - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2010 Laurent Destailleur - * Copyright (C) 2010 Juanjo Menent +/* Copyright (C) 2002-2005 Rodolphe Quiedeville + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2010 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,45 +37,56 @@ $langs->load("bills"); $langs->load("banks"); $langs->load("withdrawals"); -// Security check -if ($user->societe_id > 0) -{ - $action = ''; - $socid = $user->societe_id; -} +$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility +$ref=GETPOST('ref','alpha'); +$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); + +$fieldid = (! empty($ref)?'facnumber':'rowid'); +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); $object = new Facture($db); +// Load object +if ($id > 0 || ! empty($ref)) +{ + $ret=$object->fetch($id, $ref); + if ($ret > 0) + { + $object->fetch_thirdparty(); + } +} /* * Actions */ -if ($_GET["action"] == "new") +if ($action == "new") { - if ($object->fetch($_GET["facid"])) + if ($object->id > 0) { $result = $object->demande_prelevement($user); if ($result > 0) { - Header("Location: prelevement.php?facid=".$object->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - $mesg='
'.$object->error.'
'; + setEventMessage($object->error, 'errors'); } } } -if ($_GET["action"] == "delete") +if ($action == "delete") { - if ($object->fetch($_GET["facid"])) + if ($object->id > 0) { - $result = $object->demande_prelevement_delete($user,$_GET["did"]); + $result = $object->demande_prelevement_delete($user, GETPOST('did')); if ($result == 0) { - Header("Location: prelevement.php?facid=".$object->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } } @@ -87,7 +99,7 @@ if ($_GET["action"] == "delete") $now=dol_now(); -llxHeader('',$langs->trans("Bill")); +llxHeader('', $langs->trans("Bill")); $form = new Form($db); @@ -97,477 +109,465 @@ $form = new Form($db); /* */ /* *************************************************************************** */ -if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"]) +if ($object->id > 0) { - if ($object->fetch($_REQUEST["facid"], $_REQUEST["ref"]) > 0) - { - dol_htmloutput_mesg($mesg); + $totalpaye = $object->getSommePaiement(); + $totalcreditnotes = $object->getSumCreditNotesUsed(); + $totaldeposits = $object->getSumDepositsUsed(); + //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; - $soc = new Societe($db); - $soc->fetch($object->socid); + // We can also use bcadd to avoid pb with floating points + // For example print 239.2 - 229.3 - 9.9; does not return 0. + //$resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); + //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); + $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT'); - $totalpaye = $object->getSommePaiement(); - $totalcreditnotes = $object->getSumCreditNotesUsed(); - $totaldeposits = $object->getSumDepositsUsed(); - //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; + if ($object->paye) $resteapayer=0; + $resteapayeraffiche=$resteapayer; - // We can also use bcadd to avoid pb with floating points - // For example print 239.2 - 229.3 - 9.9; does not return 0. - //$resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); - //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); - $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT'); + $absolute_discount=$object->thirdparty->getAvailableDiscounts('','fk_facture_source IS NULL'); + $absolute_creditnote=$object->thirdparty->getAvailableDiscounts('','fk_facture_source IS NOT NULL'); + $absolute_discount=price2num($absolute_discount,'MT'); + $absolute_creditnote=price2num($absolute_creditnote,'MT'); - if ($object->paye) $resteapayer=0; - $resteapayeraffiche=$resteapayer; + $author = new User($db); + if ($object->user_author) + { + $author->fetch($object->user_author); + } - $absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL'); - $absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL'); - $absolute_discount=price2num($absolute_discount,'MT'); - $absolute_creditnote=price2num($absolute_creditnote,'MT'); + $head = facture_prepare_head($object); - $author = new User($db); - if ($object->user_author) - { - $author->fetch($object->user_author); - } + dol_fiche_head($head, 'standingorders', $langs->trans('InvoiceCustomer'),0,'bill'); - $head = facture_prepare_head($object); + /* + * Facture + */ + print ''; - dol_fiche_head($head, 'standingorders', $langs->trans('InvoiceCustomer'),0,'bill'); + $linkback = ''.$langs->trans("BackToList").''; - /* - * Facture - */ - print '
'; + // Ref + print '"; - $linkback = ''.$langs->trans("BackToList").''; + // Ref customer + print ''; + print ''; - // Ref - print '"; + // Third party + print ''; + print ''; + print ''; - // Ref customer - print ''; - print ''; + // Type + print ''; - print ''; - print ''; + $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 ')'; + } + // FIXME $facidnext not defined + /* + if ($facidnext > 0) + { + $facthatreplace=new Facture($db); + $facthatreplace->fetch($facidnext); + print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')'; + } + */ + print ''; - // Type - print ''; - $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 ($facidnext > 0) - { - $facthatreplace=new Facture($db); - $facthatreplace->fetch($facidnext); - print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')'; - } - print ''; + // Date invoice + print ''; + if ($object->type != 2) + { + if ($action == 'editinvoicedate') + { + $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id,$object->date,'invoicedate'); + } + else + { + print dol_print_date($object->date,'daytext'); + } + } + else + { + print dol_print_date($object->date,'daytext'); + } + print ''; + print ''; - // Date invoice - print ''; - if ($object->type != 2) - { - if ($_GET['action'] == 'editinvoicedate') - { - $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->date,'invoicedate'); - } - else - { - print dol_print_date($object->date,'daytext'); - } - } - else - { - print dol_print_date($object->date,'daytext'); - } - print ''; - print ''; + // Conditions de reglement + print ''; - // Date payment term - print ''; + // Mode de reglement + print ''; - // Conditions de reglement - print ''; + // Montants + print ''; + print ''; + print ''; + print ''; + print ''; - // Mode de reglement - print ''; + // Amount Local Taxes + if ($mysoc->country_code=='ES') + { + if ($mysoc->localtax1_assuj=="1") //Localtax1 RE + { + print ''; + print ''; + print ''; + } + if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF + { + print ''; + print ''; + print ''; + } + } - // Montants - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; - // Amount Local Taxes - if ($mysoc->country_code=='ES') - { - if ($mysoc->localtax1_assuj=="1") //Localtax1 RE - { - print ''; - print ''; - print ''; - } - if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF - { - print ''; - print ''; - print ''; - } - } + // Statut + print ''; + print ''; - print ''; - print ''; + print ''; - // Statut - print ''; - print ''; + print '
'.$langs->trans("Ref").''; + $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 "
'; + print ''; + print '
'; + print $langs->trans('RefCustomer'); + print '
'; + print '
'; + print $object->ref_client; + print '
'.$langs->trans("Ref").''; - $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 "
'.$langs->trans('Company').''.$object->thirdparty->getNomUrl(1,'compta'); + print '   ('.$langs->trans('OtherBills').')
'; - print ''; - print '
'; - print $langs->trans('RefCustomer'); - print '
'; - print '
'; - print $object->ref_client; - 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)).')'; + } - // Third party - print '
'.$langs->trans('Company').''.$soc->getNomUrl(1,'compta'); - print '   ('.$langs->trans('OtherBills').')
'.$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)).')'; - } + // Discounts + print '
'.$langs->trans('Discounts').''; + if ($object->thirdparty->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_client); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + print '. '; + if ($absolute_discount > 0) + { + if ($object->statut > 0 || $object->type == 2 || $object->type == 3) + { + if ($object->statut == 0) + { + print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)).'. '; + } + 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); + } + } + } + else + { + // Remise dispo de type non avoir + $filter='fk_facture_source IS NULL'; + print '
'; + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id',$object->thirdparty->id,$absolute_discount,$filter,$resteapayer); + } + } + 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 ($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 + $filter='fk_facture_source IS NOT NULL'; + if (! $absolute_discount) print '
'; + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id_for_payment',$object->thirdparty->id,$absolute_creditnote,$filter,$resteapayer); + } + } + if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; + print '
'; + print ''; + if ($object->type != 2 && $action != 'editinvoicedate' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; + print '
'; + print $langs->trans('Date'); + print 'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; + print '
'; - // Discounts - print '
'.$langs->trans('Discounts').''; - if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - print '. '; - if ($absolute_discount > 0) - { - if ($object->statut > 0 || $object->type == 2 || $object->type == 3) - { - if ($object->statut == 0) - { - print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)).'. '; - } - 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); - } - } - } - else - { - // Remise dispo de type non avoir - $filter='fk_facture_source IS NULL'; - print '
'; - $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id,0,'remise_id',$soc->id,$absolute_discount,$filter,$resteapayer); - } - } - 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 ($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 - $filter='fk_facture_source IS NOT NULL'; - if (! $absolute_discount) print '
'; - $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id,0,'remise_id_for_payment',$soc->id,$absolute_creditnote,$filter,$resteapayer); - } - } - if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; - print '
'; - print ''; - if ($object->type != 2 && $_GET['action'] != 'editinvoicedate' && $object->brouillon && $user->rights->facture->creer) print ''; - print '
'; - print $langs->trans('Date'); - print 'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; - print '
'; + // Date payment term + print '
'; + print ''; + if ($object->type != 2 && $action != 'editpaymentterm' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; + print '
'; + print $langs->trans('DateMaxPayment'); + print 'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; + print '
'; + if ($object->type != 2) + { + if ($action == 'editpaymentterm') + { + $form->form_date($_SERVER['PHP_SELF'].'?id='.$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')); + } + } + else + { + print ' '; + } + print '
'; + print ''; + if ($object->type != 2 && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; + print '
'; + print $langs->trans('PaymentConditionsShort'); + print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; + print '
'; + if ($object->type != 2) + { + if ($action == 'editconditions') + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id'); + } + else + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none'); + } + } + else + { + print ' '; + } + print '
'; - print ''; - if ($object->type != 2 && $_GET['action'] != 'editpaymentterm' && $object->brouillon && $user->rights->facture->creer) print ''; - print '
'; - print $langs->trans('DateMaxPayment'); - print 'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; - print '
'; - if ($object->type != 2) - { - if ($_GET['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 && ! $object->am) print img_warning($langs->trans('Late')); - } - } - else - { - print ' '; - } - print '
'; + print ''; + if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; + print '
'; + print $langs->trans('PaymentMode'); + print 'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; + print '
'; + if ($action == 'editmode') + { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id'); + } + else + { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none'); + } + print '
'; - print ''; - if ($object->type != 2 && $_GET['action'] != 'editconditions' && $object->brouillon && $user->rights->facture->creer) print ''; - print '
'; - print $langs->trans('PaymentConditionsShort'); - print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; - print '
'; - if ($object->type != 2) - { - if ($_GET['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'); - } - } - else - { - print ' '; - } - print '
'.$langs->trans('AmountHT').''.price($object->total_ht).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->trans('AmountVAT').''.price($object->total_tva).''.$langs->trans('Currency'.$conf->currency).'
'; - print ''; - if ($_GET['action'] != 'editmode' && $object->brouillon && $user->rights->facture->creer) print ''; - print '
'; - print $langs->trans('PaymentMode'); - print 'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; - print '
'; - if ($_GET['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 '
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($object->total_localtax1).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($object->total_localtax2).''.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('AmountHT').''.price($object->total_ht).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->trans('AmountVAT').''.price($object->total_tva).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->trans('AmountTTC').''.price($object->total_ttc).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($object->total_localtax1).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($object->total_localtax2).''.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('Status').''.($object->getLibStatut(4,$totalpaye)).'
'.$langs->trans('AmountTTC').''.price($object->total_ttc).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->trans("RIB").''; + print $object->thirdparty->display_rib(); + print '
'.$langs->trans('Status').''.($object->getLibStatut(4,$totalpaye)).'
'; - print ''.$langs->trans("RIB").''; - print $soc->display_rib(); - print ''; - - print ''; - - dol_fiche_end(); + dol_fiche_end(); - /* - * Withdrawal request - */ + /* + * Withdrawal request + */ - $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande"; - $sql .= " , pfd.date_traite as date_traite"; - $sql .= " , pfd.amount"; - $sql .= " , u.rowid as user_id, u.name, u.firstname, u.login"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql .= " , ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE fk_facture = ".$object->id; - $sql .= " AND pfd.fk_user_demande = u.rowid"; - $sql .= " AND pfd.traite = 0"; - $sql .= " ORDER BY pfd.date_demande DESC"; + $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande"; + $sql .= " , pfd.date_traite as date_traite"; + $sql .= " , pfd.amount"; + $sql .= " , u.rowid as user_id, u.name, u.firstname, u.login"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " , ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE fk_facture = ".$object->id; + $sql .= " AND pfd.fk_user_demande = u.rowid"; + $sql .= " AND pfd.traite = 0"; + $sql .= " ORDER BY pfd.date_demande DESC"; - $result_sql = $db->query($sql); - if ($result_sql) - { - $num = $db->num_rows($result_sql); - } + $result_sql = $db->query($sql); + if ($result_sql) + { + $num = $db->num_rows($result_sql); + } - /* - * Buttons - */ - print "\n
\n"; + /* + * Buttons + */ + print "\n
\n"; - // Add a withdraw request - if ($object->statut > 0 && $object->paye == 0 && $num == 0) - { - if ($user->rights->prelevement->bons->creer) - { - print ''.$langs->trans("MakeWithdrawRequest").''; - } - else - { - print ''.$langs->trans("MakeWithdrawRequest").''; - } - } + // Add a withdraw request + if ($object->statut > 0 && $object->paye == 0 && $num == 0) + { + if ($user->rights->prelevement->bons->creer) + { + print ''.$langs->trans("MakeWithdrawRequest").''; + } + else + { + print ''.$langs->trans("MakeWithdrawRequest").''; + } + } - print "

\n"; + print "

\n"; - print $langs->trans("DoStandingOrdersBeforePayments").'
'; + print $langs->trans("DoStandingOrdersBeforePayments").'
'; - /* - * Withdrawals - */ - print ''; + /* + * Withdrawals + */ + print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $var=True; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $var=True; - if ($result_sql) - { - $i = 0; + if ($result_sql) + { + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($result_sql); - $var=!$var; + while ($i < $num) + { + $obj = $db->fetch_object($result_sql); + $var=!$var; - print ""; - print '\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $i++; - } + print ""; + print '\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $i++; + } - $db->free($result_sql); - } - else - { - dol_print_error($db); - } + $db->free($result_sql); + } + else + { + dol_print_error($db); + } - $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande,"; - $sql.= " pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,"; - $sql.= " pb.ref,"; - $sql.= " u.rowid as user_id, u.name, u.firstname, u.login"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd,"; - $sql.= " ".MAIN_DB_PREFIX."prelevement_bons as pb,"; - $sql.= " ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE fk_facture = ".$object->id; - $sql.= " AND pfd.fk_user_demande = u.rowid"; - $sql.= " AND pb.rowid = pfd.fk_prelevement_bons"; - $sql.= " AND pfd.traite = 1"; - $sql.= " ORDER BY pfd.date_demande DESC"; + $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande,"; + $sql.= " pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,"; + $sql.= " pb.ref,"; + $sql.= " u.rowid as user_id, u.name, u.firstname, u.login"; + $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd,"; + $sql.= " ".MAIN_DB_PREFIX."prelevement_bons as pb,"; + $sql.= " ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE fk_facture = ".$object->id; + $sql.= " AND pfd.fk_user_demande = u.rowid"; + $sql.= " AND pb.rowid = pfd.fk_prelevement_bons"; + $sql.= " AND pfd.traite = 1"; + $sql.= " ORDER BY pfd.date_demande DESC"; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $var=!$var; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $var=!$var; - print ""; + print ""; - print '\n"; + print '\n"; - print '\n"; + print '\n"; - print ''; + print ''; - print '\n"; + print '\n"; - print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print "\n"; - $i++; - } + print "\n"; + $i++; + } - $db->free($result); - } - else - { - dol_print_error($db); - } + $db->free($result); + } + else + { + dol_print_error($db); + } - print "
'.$langs->trans("DateRequest").''.$langs->trans("DateProcess").''.$langs->trans("Amount").''.$langs->trans("WithdrawalReceipt").''.$langs->trans("User").'  
'.$langs->trans("DateRequest").''.$langs->trans("DateProcess").''.$langs->trans("Amount").''.$langs->trans("WithdrawalReceipt").''.$langs->trans("User").'  
'.dol_print_date($db->jdate($obj->date_demande),'day')."'.$langs->trans("OrderWaiting").''.price($obj->amount).'-'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.' '; - print ''; - print img_delete(); - print '
'.dol_print_date($db->jdate($obj->date_demande),'day')."'.$langs->trans("OrderWaiting").''.price($obj->amount).'-'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.' '; + print ''; + print img_delete(); + print '
'.dol_print_date($db->jdate($obj->date_demande),'day')."'.dol_print_date($db->jdate($obj->date_demande),'day')."'.dol_print_date($db->jdate($obj->date_traite),'day')."'.dol_print_date($db->jdate($obj->date_traite),'day')."'.price($obj->amount).''.price($obj->amount).''; - $withdrawreceipt=new BonPrelevement($db); - $withdrawreceipt->id=$obj->fk_prelevement_bons; - $withdrawreceipt->ref=$obj->ref; - print $withdrawreceipt->getNomUrl(1); - print "'; + $withdrawreceipt=new BonPrelevement($db); + $withdrawreceipt->id=$obj->fk_prelevement_bons; + $withdrawreceipt->ref=$obj->ref; + print $withdrawreceipt->getNomUrl(1); + print "'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'    
"; - - } - else - { - /* Invoice not found */ - print $langs->trans("ErrorBillNotFound",$_GET["facid"]); - } + print ""; } -$db->close(); - llxFooter(); +$db->close(); ?> diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 9bef9a46617..b58e072d613 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2012 Juanjo Menent * Copyright (C) 2010-2012 Laurent Destailleur * @@ -28,7 +28,9 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'); -if ($conf->esaeb->enabled) dol_include_once('/esaeb/class/esaeb19.class.php'); +// FIXME don't include external module class +if (! empty($conf->esaeb->enabled)) + dol_include_once('/esaeb/class/esaeb19.class.php'); /** diff --git a/htdocs/compta/prelevement/facturesrejets.php b/htdocs/compta/prelevement/facturesrejets.php index 1266c1eee69..41675d1c1ec 100644 --- a/htdocs/compta/prelevement/facturesrejets.php +++ b/htdocs/compta/prelevement/facturesrejets.php @@ -17,10 +17,10 @@ * */ -/** - * \file htdocs/compta/prelevement/facturesrejets.php - * \ingroup prelevement - * \brief Invoice reject +/** + * \file htdocs/compta/prelevement/facturesrejets.php + * \ingroup prelevement + * \brief Invoice reject */ require("../bank/pre.inc.php"); diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index a0e2597f0d7..dfced7618f5 100755 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2011-2012 Juanjo Menent +/* Copyright (C) 2002-2003 Rodolphe Quiedeville + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2011-2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -73,18 +73,21 @@ llxHeader(); $sql = "SELECT"; $sql.= " f.ref, f.rowid as fichid, f.fk_statut, f.description,"; $sql.= " fd.description as descriptiondetail, fd.date as dp, fd.duree,"; -$sql.= " s.nom, s.rowid as socid"; +$sql.= " s.nom, s.rowid as socid, s.client"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (! $user->rights->societe->client->voir && empty($socid)) + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ", ".MAIN_DB_PREFIX."fichinter as f)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid"; $sql.= " WHERE f.fk_soc = s.rowid "; $sql.= " AND f.entity = ".$conf->entity; -if ($search_ref) $sql .= " AND f.ref like '%".$db->escape($search_ref)."%'"; -if ($search_company) $sql .= " AND s.nom like '%".$db->escape($search_company)."%'"; -if ($search_desc) $sql .= " AND (f.description like '%".$db->escape($search_desc)."%' OR fd.description like '%".$db->escape($search_desc)."%')"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($socid) $sql.= " AND s.rowid = " . $socid; +if ($search_ref) $sql .= " AND f.ref LIKE '%".$db->escape($search_ref)."%'"; +if ($search_company) $sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; +if ($search_desc) $sql .= " AND (f.description LIKE '%".$db->escape($search_desc)."%' OR fd.description LIKE '%".$db->escape($search_desc)."%')"; +if (! $user->rights->societe->client->voir && empty($socid)) + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +if ($socid) + $sql.= " AND s.rowid = " . $socid; $sql.= " ORDER BY ".$sortfield." ".$sortorder; $sql.= $db->plimit($limit+1, $offset); @@ -96,12 +99,12 @@ if ($result) $interventionstatic=new Fichinter($db); $urlparam="&socid=$socid"; - print_barre_liste($langs->trans("ListOfInterventions"), $page, "list.php",$urlparam,$sortfield,$sortorder,'',$num); + print_barre_liste($langs->trans("ListOfInterventions"), $page, $_SERVER['PHP_SELF'], $urlparam, $sortfield, $sortorder, '', $num); print '
'."\n"; print ''; - print ""; + print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.ref","",$urlparam,'width="15%"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$urlparam,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Description"),$_SERVER["PHP_SELF"],"f.description","",$urlparam,'',$sortfield,$sortorder);