From 57e4453ea2f85d19c4bce52e63f3115d70611634 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Sun, 13 Apr 2014 18:26:21 +0200 Subject: [PATCH 01/10] Add filter date and total line on bank writing list page --- ChangeLog | 1 + htdocs/compta/bank/search.php | 62 ++++++++++++++++++++++++++++------- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a417a386dd..446379d2cd9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -45,6 +45,7 @@ For users: - New: Can filter on status for supplier order. - Fix: Project Task numbering customs rule works. - Fix: Add actions events not implemented. +- New: Add filter date in bank writing list page TODO - New: Predefined product and free product use same form. diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index a94e2fc5cd0..b4f7a65e0cb 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -1,9 +1,10 @@ * Copyright (C) 2004-2008 Laurent Destailleur - * Copytight (C) 2005-2010 Regis Houssin - * Copytight (C) 2012 Vinícius Nogueira - * + * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2012 Vinícius Nogueira + * Copyright (C) 2014 Florian Henry + * * 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 3 of the License, or @@ -29,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; $langs->load("banks"); $langs->load("categories"); @@ -43,14 +45,18 @@ $credit=GETPOST("credit"); $type=GETPOST("type"); $account=GETPOST("account"); $bid=GETPOST("bid","int"); +$search_dt_start=dol_mktime ( 0, 0, 0, GETPOST ( 'search_start_dtmonth', 'int' ), GETPOST ( 'search_start_dtday', 'int' ), GETPOST ( 'search_start_dtyear', 'int' ) ); +$search_dt_end=dol_mktime ( 0, 0, 0, GETPOST ( 'search_end_dtmonth', 'int' ), GETPOST ( 'search_end_dtday', 'int' ), GETPOST ( 'search_end_dtyear', 'int' ) ); $param=''; -if ($description) $param.='&description='.$description; -if ($type) $param.='&type='.$type; -if ($debit) $param.='&debit='.$debit; -if ($credit) $param.='&credit='.$credit; -if ($account) $param.='&account='.$account; -if ($bid) $param.='&bid='.$bid; +if (!empty($description)) $param.='&description='.$description; +if (!empty($type)) $param.='&type='.$type; +if (!empty($debit)) $param.='&debit='.$debit; +if (!empty($credit)) $param.='&credit='.$credit; +if (!empty($account)) $param.='&account='.$account; +if (!empty($bid)) $param.='&bid='.$bid; +if (dol_strlen($search_dt_start)>0) $param.='&search_start_dtmonth='.GETPOST ( 'search_start_dtmonth', 'int' ).'&search_start_dtday='.GETPOST ( 'search_start_dtday', 'int' ).'&search_start_dtyear='.GETPOST ( 'search_start_dtyear', 'int' ); +if (dol_strlen($search_dt_end)>0) $param.='&search_end_dtmonth='.GETPOST ( 'search_end_dtmonth', 'int' ).'&search_end_dtday='.GETPOST ( 'search_end_dtday', 'int' ).'&search_end_dtyear='.GETPOST ( 'search_end_dtyear', 'int' ); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -74,6 +80,7 @@ $bankaccountstatic=new Account($db); llxHeader(); $form = new Form($db); +$formother = new FormOther ( $db ); if ($vline) $viewline = $vline; else $viewline = 50; @@ -108,6 +115,13 @@ if (! empty($type)) { $sql.= " AND b.fk_type = '".$db->escape($type)."' "; } +//Search period criteria +if (dol_strlen($search_dt_start)>0) { + $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'"; +} +if (dol_strlen($search_dt_end)>0) { + $sql .= " AND b.dateo <= '" . $db->idate($search_dt_end) . "'"; +} // Search criteria amount $si=0; $debit = price2num(str_replace('-','',$debit)); @@ -128,6 +142,7 @@ $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1,$offset); //print $sql; +dol_syslog('compta/bank/search.php:: sql='.$sql); $resql = $db->query($sql); if ($resql) { @@ -147,6 +162,19 @@ if ($resql) print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num); } + print '
'; + + $moreforfilter .= $langs->trans ( 'Period' ) . ' '. $langs->trans('DateOperationShort') . ': '; + $moreforfilter .= $form->select_date($search_dt_start,'search_start_dt',0, 0, 1, "search_form", 1, 1, 1); + $moreforfilter .= $langs->trans ( 'PeriodEndDate' ) . ':' . $form->select_date($search_dt_end,'search_end_dt',0, 0, 1, "search_form", 1, 1, 1); + + + if ($moreforfilter) { + print '
'; + print $moreforfilter; + print '
'; + } + print ''; print ''; print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'b.rowid','',$param,'',$sortfield,$sortorder); @@ -161,7 +189,6 @@ if ($resql) print ''; print "\n"; - print ''; print ''; print ''; print ''; @@ -189,6 +216,8 @@ if ($resql) print ''; // Loop on each record + $total_debit=0; + $total_credit=0; while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); @@ -259,10 +288,12 @@ if ($resql) if ($objp->amount < 0) { print "\n"; + $total_debit+=$objp->amount; } else { print "\n"; + $total_credit+=$objp->amount; } // Bank account @@ -275,6 +306,15 @@ if ($resql) } $i++; } + if ($num>0) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } print "
  '.$langs->trans("Account").'
 
".price($objp->amount * -1)."  ".price($objp->amount)."
' . $langs->trans ( 'Total' ) . ''.price($total_debit*-1).''.price($total_credit).'
"; @@ -285,7 +325,7 @@ else dol_print_error($db); } -// Si acc�s issu d'une recherche et rien de trouv� +// If no data to display after a search if ($_POST["action"] == "search" && ! $num) { print $langs->trans("NoRecordFound"); From 7d84c573ab6c969c030af3656495622ba6c6a4a5 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Sun, 13 Apr 2014 18:57:35 +0200 Subject: [PATCH 02/10] syntax travis ruleset.xml --- htdocs/compta/bank/search.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index b4f7a65e0cb..acf46b18fce 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -45,8 +45,8 @@ $credit=GETPOST("credit"); $type=GETPOST("type"); $account=GETPOST("account"); $bid=GETPOST("bid","int"); -$search_dt_start=dol_mktime ( 0, 0, 0, GETPOST ( 'search_start_dtmonth', 'int' ), GETPOST ( 'search_start_dtday', 'int' ), GETPOST ( 'search_start_dtyear', 'int' ) ); -$search_dt_end=dol_mktime ( 0, 0, 0, GETPOST ( 'search_end_dtmonth', 'int' ), GETPOST ( 'search_end_dtday', 'int' ), GETPOST ( 'search_end_dtyear', 'int' ) ); +$search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int')); +$search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int')); $param=''; if (!empty($description)) $param.='&description='.$description; @@ -55,8 +55,10 @@ if (!empty($debit)) $param.='&debit='.$debit; if (!empty($credit)) $param.='&credit='.$credit; if (!empty($account)) $param.='&account='.$account; if (!empty($bid)) $param.='&bid='.$bid; -if (dol_strlen($search_dt_start)>0) $param.='&search_start_dtmonth='.GETPOST ( 'search_start_dtmonth', 'int' ).'&search_start_dtday='.GETPOST ( 'search_start_dtday', 'int' ).'&search_start_dtyear='.GETPOST ( 'search_start_dtyear', 'int' ); -if (dol_strlen($search_dt_end)>0) $param.='&search_end_dtmonth='.GETPOST ( 'search_end_dtmonth', 'int' ).'&search_end_dtday='.GETPOST ( 'search_end_dtday', 'int' ).'&search_end_dtyear='.GETPOST ( 'search_end_dtyear', 'int' ); +if (dol_strlen($search_dt_start) > 0) + $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int'); +if (dol_strlen($search_dt_end) > 0) + $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -164,9 +166,9 @@ if ($resql) print ''; - $moreforfilter .= $langs->trans ( 'Period' ) . ' '. $langs->trans('DateOperationShort') . ': '; - $moreforfilter .= $form->select_date($search_dt_start,'search_start_dt',0, 0, 1, "search_form", 1, 1, 1); - $moreforfilter .= $langs->trans ( 'PeriodEndDate' ) . ':' . $form->select_date($search_dt_end,'search_end_dt',0, 0, 1, "search_form", 1, 1, 1); + $moreforfilter .= $langs->trans('Period') . ' ' . $langs->trans('DateOperationShort') . ': '; + $moreforfilter .= $form->select_date($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 1, 1); + $moreforfilter .= $langs->trans('PeriodEndDate') . ':' . $form->select_date($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 1, 1); if ($moreforfilter) { @@ -308,10 +310,10 @@ if ($resql) } if ($num>0) { print ''; - print '' . $langs->trans ( 'Total' ) . ''; + print '' . $langs->trans('Total') . ''; print ''; - print ''.price($total_debit*-1).''; - print ''.price($total_credit).''; + print '' . price($total_debit * - 1) . ''; + print '' . price($total_credit) . ''; print ''; print ''; } From 0d1697589ed625ca8df2f3c480930fdb2085d467 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Sun, 13 Apr 2014 20:39:40 +0200 Subject: [PATCH 03/10] syntax --- htdocs/compta/bank/search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index acf46b18fce..20b5247ffd7 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -82,7 +82,7 @@ $bankaccountstatic=new Account($db); llxHeader(); $form = new Form($db); -$formother = new FormOther ( $db ); +$formother = new FormOther($db); if ($vline) $viewline = $vline; else $viewline = 50; From c87515d3a14507f4adb6cb12150764eff75db47b Mon Sep 17 00:00:00 2001 From: Benjamin Date: Mon, 14 Apr 2014 11:18:14 +0200 Subject: [PATCH 04/10] Add 2 lang variables for new tab in adherent Added MembersStatisticsByRegion and MembersByRegion --- htdocs/langs/en_US/members.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 6b7abb382ba..fd17000a8e0 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -170,6 +170,8 @@ LastSubscriptionAmount=Last subscription amount MembersStatisticsByCountries=Members statistics by country MembersStatisticsByState=Members statistics by state/province MembersStatisticsByTown=Members statistics by town +MembersStatisticsByRegion=Members statistics by region +MemberByRegion=Members by region NbOfMembers=Number of members NoValidatedMemberYet=No validated members found MembersByCountryDesc=This screen show you statistics on members by countries. Graphic depends however on Google online graph service and is available only if an internet connection is is working. From f86d49c1aca8e3e9af6e4ba67097d3909ce3c6f7 Mon Sep 17 00:00:00 2001 From: fxw Date: Wed, 16 Apr 2014 16:33:36 +0200 Subject: [PATCH 05/10] Update server_thirdparty.php For the method getListOfThirdParties, return all the extrafieldsOptions of the thirdParty Object --- htdocs/webservices/server_thirdparty.php | 71 ++++++++++++++---------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index ccc05902dca..6010306a98a 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -290,7 +290,7 @@ function getThirdParty($authentication,$id='',$ref='',$ref_ext='') $result=$thirdparty->fetch($id,$ref,$ref_ext); if ($result > 0) { - + $thirdparty_result_fields=array( 'id' => $thirdparty->id, 'ref' => $thirdparty->name, @@ -328,16 +328,16 @@ function getThirdParty($authentication,$id='',$ref='',$ref_ext='') 'vat_number' => $thirdparty->tva_intra, 'note_private' => $thirdparty->note_private, 'note_public' => $thirdparty->note_public); - + //Retreive all extrafield for thirdsparty // fetch optionals attributes and labels $extrafields=new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label('societe',true); //Get extrafield values $thirdparty->fetch_optionals($thirdparty->id,$extralabels); - + foreach($extrafields->attribute_label as $key=>$label) - { + { $thirdparty_result_fields=array_merge($thirdparty_result_fields,array('options_'.$key => $thirdparty->array_options['options_'.$key])); } @@ -444,7 +444,7 @@ function createThirdParty($authentication,$thirdparty) $newobject->canvas=$thirdparty['canvas']; $newobject->particulier=$thirdparty['individual']; - + //Retreive all extrafield for thirdsparty // fetch optionals attributes and labels $extrafields=new ExtraFields($db); @@ -520,16 +520,16 @@ function updateThirdParty($authentication,$thirdparty) if (! $error) { $objectfound=false; - + include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $object=new Societe($db); $result=$object->fetch($thirdparty['id']); - + if (!empty($object->id)) { - + $objectfound=true; - + $object->ref=$thirdparty['ref']; $object->name=$thirdparty['ref']; $object->ref_ext=$thirdparty['ref_ext']; @@ -546,12 +546,12 @@ function updateThirdParty($authentication,$thirdparty) $object->address=$thirdparty['address']; $object->zip=$thirdparty['zip']; $object->town=$thirdparty['town']; - + $object->country_id=$thirdparty['country_id']; if ($thirdparty['country_code']) $object->country_id=getCountry($thirdparty['country_code'],3); $object->province_id=$thirdparty['province_id']; //if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3); - + $object->phone=$thirdparty['phone']; $object->fax=$thirdparty['fax']; $object->email=$thirdparty['email']; @@ -562,15 +562,15 @@ function updateThirdParty($authentication,$thirdparty) $object->idprof4=$thirdparty['profid4']; $object->idprof5=$thirdparty['profid5']; $object->idprof6=$thirdparty['profid6']; - + $object->capital=$thirdparty['capital']; - + $object->barcode=$thirdparty['barcode']; $object->tva_assuj=$thirdparty['vat_used']; $object->tva_intra=$thirdparty['vat_number']; - + $object->canvas=$thirdparty['canvas']; - + //Retreive all extrafield for thirdsparty // fetch optionals attributes and labels $extrafields=new ExtraFields($db); @@ -580,9 +580,9 @@ function updateThirdParty($authentication,$thirdparty) $key='options_'.$key; $object->array_options[$key]=$thirdparty[$key]; } - + $db->begin(); - + $result=$object->update($thirdparty['id'],$fuser); if ($result <= 0) { $error++; @@ -640,6 +640,7 @@ function getListOfThirdParties($authentication,$filterthirdparty) // Init and check authentication $objectresp=array(); $arraythirdparties=array(); + $errorcode='';$errorlabel=''; $error=0; $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel); @@ -647,9 +648,11 @@ function getListOfThirdParties($authentication,$filterthirdparty) if (! $error) { - $sql ="SELECT s.rowid, s.nom as ref, s.ref_ext, s.address, s.zip, s.town, p.libelle as country, s.phone, s.fax, s.url"; + $sql ="SELECT s.rowid as socRowid, s.nom as ref, s.ref_ext, s.address, s.zip, s.town, p.libelle as country, s.phone, s.fax, s.url, extra.*"; $sql.=" FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_pays as p ON s.fk_pays = p.rowid'; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as extra ON s.rowid=fk_object"; + $sql.=" WHERE entity=".$conf->entity; foreach($filterthirdparty as $key => $val) { @@ -658,6 +661,11 @@ function getListOfThirdParties($authentication,$filterthirdparty) if ($key == 'category' && $val != '') $sql.=" AND s.rowid IN (SELECT fk_societe FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_categorie=".$db->escape($val).") "; } dol_syslog("Function: getListOfThirdParties sql=".$sql); + + $extrafields=new ExtraFields($db); + $extralabels=$extrafields->fetch_name_optionals_label('societe',true); + + $resql=$db->query($sql); if ($resql) { @@ -666,18 +674,25 @@ function getListOfThirdParties($authentication,$filterthirdparty) $i=0; while ($i < $num) { + $extrafieldsOptions=array(); $obj=$db->fetch_object($resql); - $arraythirdparties[]=array('id'=>$obj->rowid, - 'ref'=>$obj->ref, - 'ref_ext'=>$obj->ref_ext, - 'adress'=>$obj->adress, - 'zip'=>$obj->zip, - 'town'=>$obj->town, - 'country'=>$obj->country, - 'phone'=>$obj->phone, - 'fax'=>$obj->fax, - 'url'=>$obj->url + foreach($extrafields->attribute_label as $key=>$label) + { + $extrafieldsOptions['options_'.$key] = $obj->{$key}; + } + $arraythirdparties[]=array('id'=>$obj->socRowid, + 'ref'=>$obj->ref, + 'ref_ext'=>$obj->ref_ext, + 'adress'=>$obj->adress, + 'zip'=>$obj->zip, + 'town'=>$obj->town, + 'country'=>$obj->country, + 'phone'=>$obj->phone, + 'fax'=>$obj->fax, + 'url'=>$obj->url ); + $arraythirdparties[$i] = array_merge($arraythirdparties[$i],$extrafieldsOptions); + $i++; } } From 0b78a04756ca59d8c896fdaa8fc86ef100a922ab Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Sat, 19 Apr 2014 12:32:01 +0200 Subject: [PATCH 06/10] Update doc_generic_project_odt.modules.php --- .../pdf/doc_generic_project_odt.modules.php | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php index 0e7ec535ac6..c8cf919742b 100644 --- a/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php @@ -841,46 +841,56 @@ class doc_generic_project_odt extends ModelePDFProjects 'propal'=>array( 'title'=>"ListProposalsAssociatedProject", 'class'=>'Propal', - 'test'=>$conf->propal->enabled), + 'table'=>'propal', + 'test'=>$conf->propal->enabled && $user->rights->propale->lire), 'order'=>array( 'title'=>"ListOrdersAssociatedProject", 'class'=>'Commande', - 'test'=>$conf->commande->enabled), + 'table'=>'commande', + 'test'=>$conf->commande->enabled && $user->rights->commande->lire), 'invoice'=>array( 'title'=>"ListInvoicesAssociatedProject", 'class'=>'Facture', - 'test'=>$conf->facture->enabled), + 'table'=>'facture', + 'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'invoice_predefined'=>array( 'title'=>"ListPredefinedInvoicesAssociatedProject", 'class'=>'FactureRec', - 'test'=>$conf->facture->enabled), + 'table'=>'facture_rec', + 'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'order_supplier'=>array( 'title'=>"ListSupplierOrdersAssociatedProject", + 'table'=>'commande_fournisseur', 'class'=>'CommandeFournisseur', - 'test'=>$conf->fournisseur->enabled), + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire), 'invoice_supplier'=>array( 'title'=>"ListSupplierInvoicesAssociatedProject", + 'table'=>'facture_fourn', 'class'=>'FactureFournisseur', - 'test'=>$conf->fournisseur->enabled), + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), 'contract'=>array( 'title'=>"ListContractAssociatedProject", 'class'=>'Contrat', - 'test'=>$conf->contrat->enabled), + 'table'=>'contrat', + 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), 'intervention'=>array( 'title'=>"ListFichinterAssociatedProject", 'class'=>'Fichinter', + 'table'=>'fichinter', 'disableamount'=>1, - 'test'=>$conf->ficheinter->enabled), + 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), 'trip'=>array( 'title'=>"ListTripAssociatedProject", 'class'=>'Deplacement', + 'table'=>'deplacement', 'disableamount'=>1, - 'test'=>$conf->deplacement->enabled), + 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), 'agenda'=>array( 'title'=>"ListActionsAssociatedProject", 'class'=>'ActionComm', + 'table'=>'actioncomm', 'disableamount'=>1, - 'test'=>$conf->agenda->enabled) + 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire) ); //Insert reference @@ -891,11 +901,12 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($listofreferent as $keyref => $valueref) { $title=$valueref['title']; + $tablename=$valueref['table']; $classname=$valueref['class']; $qualified=$valueref['test']; if ($qualified) { - $elementarray = $object->get_element_list($keyref); + $elementarray = $object->get_element_list($keyref, $tablename); if (count($elementarray)>0 && is_array($elementarray)) { $var=true; From 09d231ad0a62ab2e124f5d121fed88120a80294e Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Sat, 19 Apr 2014 12:36:15 +0200 Subject: [PATCH 07/10] Update project.class.php --- htdocs/projet/class/project.class.php | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 46f70c7ca89..27a6c4ca0d3 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -391,31 +391,14 @@ class Project extends CommonObject * @param string $type 'propal','order','invoice','order_supplier','invoice_supplier' * @return array List of orders linked to project, <0 if error */ - function get_element_list($type) + function get_element_list($type, $tablename) { $elements = array(); - $sql = ''; - if ($type == 'propal') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "propal WHERE fk_projet=" . $this->id; - if ($type == 'order') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "commande WHERE fk_projet=" . $this->id; - if ($type == 'invoice') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "facture WHERE fk_projet=" . $this->id; - if ($type == 'invoice_predefined') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "facture_rec WHERE fk_projet=" . $this->id; - if ($type == 'order_supplier') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "commande_fournisseur WHERE fk_projet=" . $this->id; - if ($type == 'invoice_supplier') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "facture_fourn WHERE fk_projet=" . $this->id; - if ($type == 'contract') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "contrat WHERE fk_projet=" . $this->id; - if ($type == 'intervention') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "fichinter WHERE fk_projet=" . $this->id; - if ($type == 'trip') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "deplacement WHERE fk_projet=" . $this->id; if ($type == 'agenda') $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id; + else + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id; if (! $sql) return -1; //print $sql; From cebbf1607c4b3c5607f139e1bc7007cfeca2a791 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Sat, 19 Apr 2014 13:00:42 +0200 Subject: [PATCH 08/10] Update element.php --- htdocs/projet/element.php | 73 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 4266d0f745e..c6756ac6713 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -151,6 +151,7 @@ $listofreferent=array( 'invoice'=>array( 'title'=>"ListInvoicesAssociatedProject", 'class'=>'Facture', + 'margin'=>'add', 'table'=>'facture', 'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'invoice_predefined'=>array( @@ -166,6 +167,7 @@ $listofreferent=array( 'invoice_supplier'=>array( 'title'=>"ListSupplierInvoicesAssociatedProject", 'class'=>'FactureFournisseur', + 'margin'=>'minus', 'table'=>'facture_fourn', 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), 'contract'=>array( @@ -183,6 +185,7 @@ $listofreferent=array( 'title'=>"ListTripAssociatedProject", 'class'=>'Deplacement', 'table'=>'deplacement', + 'margin'=>'minus', 'disableamount'=>1, 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), 'agenda'=>array( @@ -237,7 +240,7 @@ foreach ($listofreferent as $key => $value) if (empty($value['disableamount'])) print ''.$langs->trans("AmountTTC").''; print ''.$langs->trans("Status").''; print ''; - $elementarray = $project->get_element_list($key); + $elementarray = $project->get_element_list($key, $tablename); if (count($elementarray)>0 && is_array($elementarray)) { $var=true; @@ -334,6 +337,74 @@ foreach ($listofreferent as $key => $value) } } +// Margin display of the project +print_titre("Margin"); +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + + +foreach ($listofreferent as $key => $value) +{ + $title=$value['title']; + $classname=$value['class']; + $tablename=$value['table']; + $qualified=$value['test']; + $margin = $value['margin']; + if (isset($margin)) + { + $elementarray = $project->get_element_list($key); + if (count($elementarray)>0 && is_array($elementarray)) + { + $var=true; + $total_ht = 0; + $total_ttc = 0; + $num=count($elementarray); + for ($i = 0; $i < $num; $i++) + { + $element = new $classname($db); + $element->fetch($elementarray[$i]); + $element->fetch_thirdparty(); + //print $classname; + + $total_ht = $total_ht + $element->total_ht; + $total_ttc = $total_ttc + $element->total_ttc; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($margin=="add") + { + $margin_ht+= $total_ht; + $margin_ttc+= $total_ttc; + } + else + { + $margin_ht-= $total_ht; + $margin_ttc-= $total_ttc; + } + } + + } +} +// and the margin amount total +print ''; +print ''; +print ''; +print ''; +print ''; + +print "
'.$langs->trans("Element").''.$langs->trans("Number").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").'
'.$classname.''.$i.''.price($total_ht).''.price($total_ttc).'
'.$langs->trans("Total").''.price($margin_ht).''.price($margin_ttc).'
"; + + llxFooter(); $db->close(); From ebab7a0b624596d302bced10ddc53fb48e7e154a Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Sat, 19 Apr 2014 13:06:11 +0200 Subject: [PATCH 09/10] Update element.php --- htdocs/projet/element.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index c6756ac6713..fd36808ccdd 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -357,7 +357,7 @@ foreach ($listofreferent as $key => $value) $margin = $value['margin']; if (isset($margin)) { - $elementarray = $project->get_element_list($key); + $elementarray = $project->get_element_list($key, $tablename); if (count($elementarray)>0 && is_array($elementarray)) { $var=true; From c55e51d82520e85e41ea86184007fb2b6b89ad56 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Sat, 19 Apr 2014 14:59:42 +0200 Subject: [PATCH 10/10] Update project.class.php --- htdocs/projet/class/project.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 27a6c4ca0d3..719c7c5f034 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -389,6 +389,7 @@ class Project extends CommonObject * Return list of elements for type linked to project * * @param string $type 'propal','order','invoice','order_supplier','invoice_supplier' + * @param string $tablename name of table associated of the type * @return array List of orders linked to project, <0 if error */ function get_element_list($type, $tablename)