From 4333e8cb2aa62223b250de33352a35023009f760 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Feb 2009 02:41:21 +0000 Subject: [PATCH] Changes to support deposit invoices --- htdocs/comm/remx.php | 47 +++++++++-------- htdocs/compta/facture.php | 21 +++++++- htdocs/document.php | 12 ++++- htdocs/facture.class.php | 1 + htdocs/langs/en_US/bills.lang | 3 +- htdocs/langs/fr_FR/bills.lang | 3 +- htdocs/main.inc.php | 95 +++++++++++++++++++---------------- 7 files changed, 114 insertions(+), 68 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index e638e2f94ea..b61cd30c76c 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2008 Raphael Bertrand (Resultic) - * + * * 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 * the Free Software Foundation; either version 2 of the License, or @@ -21,7 +21,7 @@ /** * \file htdocs/comm/remx.php * \ingroup commercial, invoice - * \brief Onglet de définition des avoirs + * \brief Page to edit absolute discounts for a customer * \version $Id$ */ @@ -35,7 +35,7 @@ $langs->load("companies"); // Sécurité si un client essaye d'accéder à une autre fiche que la sienne $_socid = $_GET["id"]; -if ($user->societe_id > 0) +if ($user->societe_id > 0) { $_socid = $user->societe_id; } @@ -49,7 +49,7 @@ if ($_POST["action"] == 'setremise') { if (price2num($_POST["amount_ht"]) > 0) { - if (! $_POST["desc"]) + if (! $_POST["desc"]) { $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("ReasonDiscount")).'
'; } @@ -57,7 +57,7 @@ if ($_POST["action"] == 'setremise') $soc = new Societe($db); $soc->fetch($_GET["id"]); $soc->set_remise_except($_POST["amount_ht"],$user,$_POST["desc"],$_POST["tva_tx"]); - + if ($result > 0) { Header("Location: remx.php?id=".$_GET["id"]); @@ -77,7 +77,7 @@ if ($_POST["action"] == 'setremise') if ($_GET["action"] == 'remove') { $db->begin(); - + $soc = new Societe($db); $soc->fetch($_GET["id"]); $result=$soc->del_remise_except($_GET["remid"]); @@ -100,18 +100,18 @@ if ($_GET["action"] == 'remove') $form=new Form($db); $facturestatic=new Facture($db); - + llxHeader(); if ($_socid > 0) { if ($mesg) print $mesg."
"; - + // On recupere les donnees societes par l'objet $objsoc = new Societe($db); $objsoc->id=$_socid; $objsoc->fetch($_socid,$to); - + /* * Affichage onglets */ @@ -151,7 +151,7 @@ if ($_socid > 0) print ''.$remise_user.' '.$langs->trans("Currency".$conf->monnaie).''; print ""; print '
'; - + print ''; print ''; print ''; @@ -161,14 +161,14 @@ if ($_socid > 0) print ''; print ''; print ''; - + print ''; - + print "
'.$langs->trans("NewGlobalDiscount").' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("NoteReason").'
"; - print "\n"; + print "\n"; - print '
'; + print '
'; /* @@ -217,6 +217,13 @@ if ($_socid > 0) $facturestatic->type=$obj->type; print $langs->trans("CreditNote").' '.$facturestatic->getNomURl(1); } + elseif ($obj->description == '(DEPOSIT)') + { + $facturestatic->id=$obj->fk_facture_source; + $facturestatic->ref=$obj->ref; + $facturestatic->type=$obj->type; + print $langs->trans("InvoiceDeposit").' '.$facturestatic->getNomURl(1); + } else { print $obj->description; @@ -278,14 +285,14 @@ if ($_socid > 0) $sql2.= " WHERE rc.fk_soc =". $objsoc->id; $sql2.= " AND rc.fk_facture = f.rowid"; $sql2.= " AND rc.fk_user = u.rowid"; - + $sql2.= " ORDER BY dc DESC"; $resql=$db->query($sql); $resql2=null; if ($resql) $resql2=$db->query($sql2); if ($resql2) - { + { print_titre($langs->trans("DiscountAlreadyCounted")); print ''; print ''; @@ -308,8 +315,8 @@ if ($_socid > 0) $tab_sqlobj[] = $sqlobj; $tab_sqlobjOrder[]=$sqlobj->dc; } - $db->free($resql); - + $db->free($resql); + $num = $db->num_rows($resql2); for ($i = 0;$i < $num;$i++) { @@ -319,7 +326,7 @@ if ($_socid > 0) } $db->free($resql2); array_multisort ($tab_sqlobjOrder,SORT_DESC,$tab_sqlobj); - + $num = sizeOf($tab_sqlobj); $i = 0 ; while ($i < $num ) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 1cbe607807e..a49744d4b65 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -429,9 +429,14 @@ if ($_POST['action'] == 'confirm_converttoreduc' && $_POST['confirm'] == 'yes' & $i++; } - // Insère une remise par famille de taux tva + // Insert one discount by VAT rate category $discount = new DiscountAbsolute($db); - $discount->desc='(CREDIT_NOTE)'; + if ($fac->type == 2) $discount->desc='(CREDIT_NOTE)'; + elseif ($fac->type == 3) $discount->desc='(DEPOSIT)'; + else { + $this->error="CantConvertToReducAnInvoiceOfThisType"; + return -1; + } $discount->tva_tx=abs($fac->total_ttc); $discount->fk_soc=$fac->socid; $discount->fk_facture_source=$fac->id; @@ -1849,6 +1854,12 @@ if ($_GET['action'] == 'create') $discount->fetch($objp->fk_remise_except); print $langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); } + elseif ($obj->description == '(DEPOSIT)') + { + $discount=new DiscountAbsolute($db); + $discount->fetch($objp->fk_remise_except); + print $langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); + } else { print dol_trunc($objp->description,60); @@ -2612,6 +2623,12 @@ else $discount->fetch($objp->fk_remise_except); print ' - '.$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); } + elseif ($objp->description == '(DEPOSIT)') + { + $discount=new DiscountAbsolute($db); + $discount->fetch($objp->fk_remise_except); + print ' - '.$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); + } else { print ' - '.nl2br($objp->description); diff --git a/htdocs/document.php b/htdocs/document.php index 5fc819902c7..f4ef3112065 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -23,7 +23,8 @@ * \file htdocs/document.php * \brief Wrapper to download data files * \version $Id$ - * \remarks L'appel est document.php?file=pathrelatifdufichier&modulepart=repfichierconcerne + * \remarks Call of this wrapper is mad with URL: + * document.php?modulepart=repfichierconcerne&file=pathrelatifdufichier */ $original_file = urldecode($_GET["file"]); @@ -32,6 +33,7 @@ $type = isset($_GET["type"]) ? urldecode($_GET["type"]) : ''; // Define if we need master or master+main $needmasteronly=false; +if ($modulepart == 'bittorrent') $needmasteronly=true; //if ($modulepart == 'webcal') $needmasteronly=true; //if ($modulepart == 'agenda') $needmasteronly=true; @@ -391,6 +393,14 @@ if ($modulepart) $original_file=DOL_DATA_ROOT.'/admin/temp/'.$original_file; $sqlprotectagainstexternals = ''; } + + // Wrapping pour BitTorrent + if ($modulepart == 'bittorrent') + { + $accessallowed=1; + $original_file=DOL_DATA_ROOT.'/bittorrent/files/'.$original_file; + $sqlprotectagainstexternals = ''; + } } // Basic protection (against external users only) diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 4fb4350b383..3046a5b4136 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -1997,6 +1997,7 @@ class Facture extends CommonObject global $langs; $langs->load('bills'); + //print "$paye,$statut,$mode,$alreadypayed,$type"; if ($mode == 0) { $prefix=''; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 06fc5c47963..70c4c494a7e 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -229,6 +229,7 @@ GlobalDiscount=Global discount CreditNote=Credit note CreditNotes=Credit notes DiscountFromCreditNote=Discount from credit note %s +DiscountFromDeposit=Payments from deposit invoice %s NewGlobalDiscount=New discount NoteReason=Note/Reason ReasonDiscount=Reason @@ -324,7 +325,7 @@ ChequesReceipts=Cheques receipts ChequesArea=Cheques deposits area ChequeDeposits=Cheques deposits Cheques=Cheques -CreditNoteConvertedIntoDiscount=This credit note has been converted into %s +CreditNoteConvertedIntoDiscount=This credit note or deposit invoice has been converted into %s UsBillingContactAsIncoiveRecipientIfExist=Use customer billing contact address instead of third party address as recipient for invoices PaymentInvoiceRef=Payment invoice %s # oursin PDF model diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index a75f6767151..0672199a3c5 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -228,6 +228,7 @@ GlobalDiscount=Remise fixe CreditNote=Avoir CreditNotes=Avoirs DiscountFromCreditNote=Remise issue de l'avoir %s +DiscountFromDeposit=Paiements issue de l'accompte %s NewGlobalDiscount=Nouvelle remise fixe NoteReason=Note/Motif ReasonDiscount=Motif @@ -325,7 +326,7 @@ ChequesReceipts=Bordereaux de remise de chèques ChequesArea=Espace remises de chèques ChequeDeposits=Dépots de chèques Cheques=Chèques -CreditNoteConvertedIntoDiscount=Cet avoir a été converti en %s +CreditNoteConvertedIntoDiscount=Cet avoir ou accompte a été converti en %s UsBillingContactAsIncoiveRecipientIfExist=Utiliser l'adresse du contact facturation client de la facture plutot que l'adresse du tiers comme destinataire des factures ShowUnpayedAll=Afficher tous les impayés ShowUnpayedLateOnly=Afficher impayés en retard uniquement diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f19bb371466..6ac68cbdbb3 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -834,17 +834,61 @@ function top_menu($head, $title='', $target='') * \brief Affiche barre de menu gauche * \param menu_array Tableau des entrees de menu * \param helppagename Url pour le lien aide ('' par defaut) - * \param form_search Formulaire de recherche permanant supplementaire + * \param moresearchform Formulaire de recherche permanant supplementaire */ -function left_menu($menu_array, $helppagename='', $form_search='') +function left_menu($menu_array, $helppagename='', $moresearchform='') { global $user, $conf, $langs, $db; + $searchform=''; + $bookmarks=''; + // print '
'."\n"; print '
'.$langs->trans("Date").'
'; print "\n"; + + // Define $searchform + if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_SOCIETE && $user->rights->societe->lire) + { + $langs->load("companies"); + $searchform.=printSearchForm(DOL_URL_ROOT.'/societe.php', DOL_URL_ROOT.'/societe.php', + img_object($langs->trans("List"),'company').' '.$langs->trans("Companies"), 'soc', 'socname'); + } + + if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_CONTACT && $user->rights->societe->lire) + { + $langs->load("companies"); + $searchform.=printSearchForm(DOL_URL_ROOT.'/contact/index.php', DOL_URL_ROOT.'/contact/index.php', + img_object($langs->trans("List"),'contact').' '.$langs->trans("Contacts"), 'contact', 'contactname'); + } + + if (($conf->produit->enabled || $conf->service->enabled) && $conf->global->MAIN_SEARCHFORM_PRODUITSERVICE && $user->rights->produit->lire) + { + $langs->load("products"); + $searchform.=printSearchForm(DOL_URL_ROOT.'/product/liste.php', DOL_URL_ROOT.'/product/index.php', + img_object($langs->trans("List"),'product').' '.$langs->trans("Products")."/".$langs->trans("Services"), 'products', 'sall'); + } + + if ($conf->adherent->enabled && $conf->global->MAIN_SEARCHFORM_ADHERENT && $user->rights->adherent->lire) + { + $langs->load("members"); + $searchform.=printSearchForm(DOL_URL_ROOT.'/adherents/liste.php', DOL_URL_ROOT.'/adherents/liste.php', + img_object($langs->trans("List"),'user').' '.$langs->trans("Members"), 'member', 'sall'); + } + + // Define $bookmarks + if ($conf->bookmark->enabled && $user->rights->bookmark->lire) + { + include_once (DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'); + $langs->load("bookmarks"); + + $bookmarks=printBookmarksList($db, $langs); + } + + + // Colonne de gauche print ''."\n"; print '
'."\n"; @@ -859,63 +903,28 @@ function left_menu($menu_array, $helppagename='', $form_search='') $menuleft=new MenuLeft($db,$menu_array); $menuleft->showmenu(); - // Affichage des zones de recherche permanantes - $ret=''; - if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_SOCIETE && $user->rights->societe->lire) - { - $langs->load("companies"); - $ret.=printSearchForm(DOL_URL_ROOT.'/societe.php', DOL_URL_ROOT.'/societe.php', - img_object($langs->trans("List"),'company').' '.$langs->trans("Companies"), 'soc', 'socname'); - } - if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_CONTACT && $user->rights->societe->lire) - { - $langs->load("companies"); - $ret.=printSearchForm(DOL_URL_ROOT.'/contact/index.php', DOL_URL_ROOT.'/contact/index.php', - img_object($langs->trans("List"),'contact').' '.$langs->trans("Contacts"), 'contact', 'contactname'); - } - - if (($conf->produit->enabled || $conf->service->enabled) && $conf->global->MAIN_SEARCHFORM_PRODUITSERVICE && $user->rights->produit->lire) - { - $langs->load("products"); - $ret.=printSearchForm(DOL_URL_ROOT.'/product/liste.php', DOL_URL_ROOT.'/product/index.php', - img_object($langs->trans("List"),'product').' '.$langs->trans("Products")."/".$langs->trans("Services"), 'products', 'sall'); - } - - if ($conf->adherent->enabled && $conf->global->MAIN_SEARCHFORM_ADHERENT && $user->rights->adherent->lire) - { - $langs->load("members"); - $ret.=printSearchForm(DOL_URL_ROOT.'/adherents/liste.php', DOL_URL_ROOT.'/adherents/liste.php', - img_object($langs->trans("List"),'user').' '.$langs->trans("Members"), 'member', 'sall'); - } - - if ($ret) + if ($searchform) { print "\n"; print "\n"; print '
'."\n"; - print $ret; + print $searchform; print '
'."\n"; print "\n"; } - // Zone de recherche supplementaire - if ($form_search) + if ($moresearchform) { - print $form_search; + print $moresearchform; } - // Zone d'affichage permanente des marque pages - if ($conf->bookmark->enabled && $user->rights->bookmark->lire) + if ($bookmarks) { - include_once (DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'); - $langs->load("bookmarks"); - - $ret=printBookmarksList($db, $langs); print "\n"; print "\n"; print '
'."\n"; - print $ret; + print $bookmarks; print '
'."\n"; print "\n"; }