diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index cc4d2cff7e7..1f54c0b6805 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -569,11 +569,13 @@ if (empty($reshook)) // Boucle sur chaque taux de tva $i = 0; - foreach ($object->lines as $line) { - if($line->total_ht!=0) { // no need to create discount if amount is null - $amount_ht [$line->tva_tx] += $line->total_ht; - $amount_tva [$line->tva_tx] += $line->total_tva; - $amount_ttc [$line->tva_tx] += $line->total_ttc; + foreach ($object->lines as $line) + { + if ($line->total_ht!=0) + { // no need to create discount if amount is null + $amount_ht[$line->tva_tx] += $line->total_ht; + $amount_tva[$line->tva_tx] += $line->total_tva; + $amount_ttc[$line->tva_tx] += $line->total_ttc; $i ++; } } @@ -593,10 +595,11 @@ if (empty($reshook)) $error = 0; - foreach ($amount_ht as $tva_tx => $xxx) { - $discount->amount_ht = abs($amount_ht [$tva_tx]); - $discount->amount_tva = abs($amount_tva [$tva_tx]); - $discount->amount_ttc = abs($amount_ttc [$tva_tx]); + foreach ($amount_ht as $tva_tx => $xxx) + { + $discount->amount_ht = abs($amount_ht[$tva_tx]); + $discount->amount_tva = abs($amount_tva[$tva_tx]); + $discount->amount_ttc = abs($amount_ttc[$tva_tx]); $discount->tva_tx = abs($tva_tx); $result = $discount->create($user); diff --git a/htdocs/core/modules/expensereport/pdf_teclib.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php similarity index 97% rename from htdocs/core/modules/expensereport/pdf_teclib.modules.php rename to htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 6b3b59639e5..450007a0dc6 100755 --- a/htdocs/core/modules/expensereport/pdf_teclib.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -1,8 +1,5 @@ - * Copyright (C) 2005-2010 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010 Juanjo Menent +/* Copyright (C) 2015 Laurent Destailleur * * 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 @@ -15,16 +12,14 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program. If not, see . * or see http://www.gnu.org/ */ /** - * \file htdocs/expensereport/core/modules/expensereport/pdf_.modules.php - * \ingroup facture - * \brief File of class to generate invoices from crab model - * \author Laurent Destailleur + * \file htdocs/core/modules/expensereport/doc/pdf_standard.modules.php + * \ingroup expensereport + * \brief File of class to generate invoices from standard model */ dol_include_once("/expensereport/core/modules/expensereport/modules_expensereport.php"); @@ -664,7 +659,7 @@ class pdf_ extends ModeleExpenseReport /** * Affiche la grille des lignes de factures - * + * * @param $pdf Objet PDF * @param $tab_top Tab top * @param $tab_height Tab height diff --git a/htdocs/core/modules/expensereport/modules_deplacement.php b/htdocs/core/modules/expensereport/modules_deplacement.php index 707eaad54b8..86fa894dbaf 100755 --- a/htdocs/core/modules/expensereport/modules_deplacement.php +++ b/htdocs/core/modules/expensereport/modules_deplacement.php @@ -1,4 +1,21 @@ + * + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index 54d0496a4dd..edee0952b00 100755 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -1,8 +1,6 @@ - * Copyright (C) 2004-2009 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin - * Copyright (C) 2011 Dimitri Mouillard +/* Copyright (C) 2011 Dimitri Mouillard + * Copyright (C) 2015 Laurent Destailleur * * 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 @@ -15,8 +13,8 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program. If not, see . + * or see http://www.gnu.org/ */ /** @@ -329,12 +327,12 @@ class modExpenseReport extends DolibarrModules } /** - * Function called when module is disabled. + * Function called when module is disabled. * Remove from database constants, boxes and permissions from Dolibarr database. * Data directories are not deleted. * - * @param string Options - * @return int 1 if OK, 0 if KO + * @param string $options Options + * @return int 1 if OK, 0 if KO */ function remove($options='') { diff --git a/htdocs/expensereport/ajax/ajaxprojet.php b/htdocs/expensereport/ajax/ajaxprojet.php index 0ab75543309..5246e7eb5d9 100755 --- a/htdocs/expensereport/ajax/ajaxprojet.php +++ b/htdocs/expensereport/ajax/ajaxprojet.php @@ -15,8 +15,8 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program. If not, see . + * or see http://www.gnu.org/ */ /** diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 5a6f3a29b07..5b7045fd628 100755 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -14,8 +14,8 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program. If not, see . + * or see http://www.gnu.org/ */ /** @@ -927,7 +927,7 @@ else if ($action == 'remove_file') * View */ -llxHeader(); +llxHeader('', $langs->trans("ExpenseReport")); $html = new Form($db); $formfile = new FormFile($db); @@ -1028,7 +1028,7 @@ else $object = new ExpenseReport($db); $result = $object->fetch($id,$user); - if($result) + if ($result) { if ($object->fk_user_author != $user->id) { @@ -1237,7 +1237,7 @@ else } print ''; print ''.$langs->trans("Statut").''; - print ''.$object->libelle_statut.''; + print ''.$object->getLibStatut(4).''; print ''; print ''; print ''.$langs->trans("Note").''; @@ -1261,9 +1261,12 @@ else print ''; print ''.$langs->trans("VALIDATOR").''; print ''; - $userfee=new User($db); - $userfee->fetch($object->fk_user_validator); - print $userfee->getNomUrl(1); + if ($object->fk_user_validator > 0) + { + $userfee=new User($db); + $userfee->fetch($object->fk_user_validator); + print $userfee->getNomUrl(1); + } print ''; } elseif($object->fk_c_expensereport_statuts==4) @@ -1271,9 +1274,12 @@ else print ''; print ''.$langs->trans("CANCEL_USER").''; print ''; - $userfee=new User($db); - $userfee->fetch($object->fk_user_cancel); - print $userfee->getNomUrl(1); + if ($object->fk_user_cancel > 0) + { + $userfee=new User($db); + $userfee->fetch($object->fk_user_cancel); + print $userfee->getNomUrl(1); + } print ''; print ''; print ''.$langs->trans("MOTIF_CANCEL").''; @@ -1289,9 +1295,12 @@ else print ''; print ''.$langs->trans("VALIDOR").''; print ''; - $userfee=new User($db); - $userfee->fetch($object->fk_user_valid); - print $userfee->getNomUrl(1); + if ($object->fk_user_valid > 0) + { + $userfee=new User($db); + $userfee->fetch($object->fk_user_valid); + print $userfee->getNomUrl(1); + } print ''; print ''; print ''.$langs->trans("DATE_VALIDE").''; @@ -1302,9 +1311,12 @@ else print ''; print ''.$langs->trans("AUTHOR").''; print ''; - $userfee=new User($db); - $userfee->fetch($object->fk_user_author); - print $userfee->getNomUrl(1); + if ($object->fk_user_author > 0) + { + $userfee=new User($db); + $userfee->fetch($object->fk_user_author); + print $userfee->getNomUrl(1); + } print ''; print ''; @@ -1351,12 +1363,10 @@ else $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,'; $sql.= ' fde.fk_c_tva, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; $sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,'; - $sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref,'; - $sql.= ' tva.rowid as tva_id, tva.taux as tva_taux'; + $sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref'; $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det fde'; $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees ctf ON fde.fk_c_type_fees=ctf.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet pjt ON fde.fk_projet=pjt.rowid'; - $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_tva tva ON fde.fk_c_tva=tva.rowid'; $sql.= ' WHERE fde.fk_expensereport = '.$id; $resql = $db->query($sql); @@ -1503,7 +1513,7 @@ else //print ''; // Ajouter une ligne - if (($object->fk_c_expensereport_statuts==1 || $object->fk_c_expensereport_statuts==99) && $action != 'editline') + if (($object->fk_c_expensereport_statuts==0 || $object->fk_c_expensereport_statuts==99) && $action != 'editline') { print_fiche_titre($langs->trans("AddLine"),'',''); @@ -1570,6 +1580,10 @@ else } // Fin si c'est payé/validé } + else + { + dol_print_error($db); + } } // end edit or not edit dol_fiche_end(); @@ -1602,9 +1616,9 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_author == user courant * Afficher : "Enregistrer" / "Modifier" / "Supprimer" */ - if($user->rights->expensereport->creer AND $object->fk_c_expensereport_statuts==1) + if ($user->rights->expensereport->creer AND $object->fk_c_expensereport_statuts==0) { - if($object->fk_user_author==$user->id) + if ($object->fk_user_author == $user->id) { // Modifier print ''.$langs->trans('ModifyInfoGen').''; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 092a642b4b4..f5ff354ffbc 100755 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -139,10 +139,10 @@ class ExpenseReport extends CommonObject $sql.= ", '".$this->db->idate($this->date_fin)."'"; $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", ".($user->id > 0 ? $user->id:"null"); - $sql.= ", ".($this->fk_user_validator > 0 ? $this->fk_user_validator:2); - $sql.= ", ".($this->fk_c_expensereport_statuts > 1 ? $this->fk_c_expensereport_statuts:1); - $sql.= ", ".($this->fk_c_paiement > 0 ? $this->fk_c_paiement:2); - $sql.= ", ".($this->note?"'".$this->note."'":"null"); + $sql.= ", ".($this->fk_user_validator > 0 ? $this->fk_user_validator:"null"); + $sql.= ", ".($this->fk_c_expensereport_statuts > 1 ? $this->fk_c_expensereport_statuts:0); + $sql.= ", ".($this->fk_c_paiement > 0 ? $this->fk_c_paiement:"null"); + $sql.= ", ".($this->note?"'".$this->db->escape($this->note)."'":"null"); $sql.= ")"; dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); @@ -263,11 +263,10 @@ class ExpenseReport extends CommonObject $sql.= " d.date_refuse, d.date_cancel,"; // ACTIONS $sql.= " d.total_ht, d.total_ttc, d.total_tva,"; // TOTAUX (int) $sql.= " d.date_debut, d.date_fin, d.date_create, d.date_valide, d.date_paiement,"; // DATES (datetime) - $sql.= " d.fk_user_author, d.fk_user_validator, d.fk_c_expensereport_statuts, d.fk_c_paiement,"; // FOREING KEY (int) + $sql.= " d.fk_user_author, d.fk_user_validator, d.fk_c_expensereport_statuts as status, d.fk_c_paiement,"; $sql.= " d.fk_user_valid, d.fk_user_paid,"; // FOREING KEY 2 (int) $sql.= " dp.libelle as libelle_paiement, dp.code as code_paiement"; // INNER JOIN paiement - $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." d"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement dp ON d.fk_c_paiement = dp.id"; + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." d LEFT JOIN ".MAIN_DB_PREFIX."c_paiement dp ON d.fk_c_paiement = dp.id"; $sql.= " WHERE d.rowid = ".$id; $sql.= $restrict; @@ -276,71 +275,78 @@ class ExpenseReport extends CommonObject if ($result) { $obj = $db->fetch_object($result); - - $this->id = $obj->rowid; - $this->ref = $obj->ref_number; - $this->ref_number = $obj->ref_number; - $this->total_ht = $obj->total_ht; - $this->total_tva = $obj->total_tva; - $this->total_ttc = $obj->total_ttc; - $this->note = $obj->note; - $this->detail_refuse = $obj->detail_refuse; - $this->detail_cancel = $obj->detail_cancel; - - $this->date_debut = $obj->date_debut; - $this->date_fin = $obj->date_fin; - $this->date_paiement = $obj->date_paiement; - $this->date_valide = $obj->date_valide; - $this->date_create = $obj->date_create; - $this->date_refuse = $obj->date_refuse; - $this->date_cancel = $obj->date_cancel; - - $this->fk_user_author = $obj->fk_user_author; - $this->fk_user_validator = $obj->fk_user_validator; - $this->fk_user_valid = $obj->fk_user_valid; - $this->fk_user_paid = $obj->fk_user_paid; - $this->fk_user_refuse = $obj->fk_user_refuse; - $this->fk_user_cancel = $obj->fk_user_cancel; - - $user_author = new User($this->db); - $user_author->fetch($this->fk_user_author); - $this->user_author_infos = dolGetFirstLastname($user_author->firstname, $user_author->lastname); - - $user_approver = new User($this->db); - $user_approver->fetch($this->fk_user_validator); - $this->user_validator_infos = dolGetFirstLastname($user_approver->firstname, $user_approver->lastname); - - $this->fk_c_expensereport_statuts = $obj->fk_c_expensereport_statuts; - $this->fk_c_paiement = $obj->fk_c_paiement; - - if ($this->fk_c_expensereport_statuts==5 || $this->fk_c_expensereport_statuts==6) + if ($obj) { - $user_valid = new User($this->db); - $user_valid->fetch($this->fk_user_valid); - $this->user_valid_infos = dolGetFirstLastname($user_valid->firstname, $user_valid->lastname); - } + $this->id = $obj->rowid; + $this->ref = $obj->ref_number; + $this->ref_number = $obj->ref_number; + $this->total_ht = $obj->total_ht; + $this->total_tva = $obj->total_tva; + $this->total_ttc = $obj->total_ttc; + $this->note = $obj->note; + $this->detail_refuse = $obj->detail_refuse; + $this->detail_cancel = $obj->detail_cancel; - if ($this->fk_c_expensereport_statuts==6) + $this->date_debut = $obj->date_debut; + $this->date_fin = $obj->date_fin; + $this->date_paiement = $obj->date_paiement; + $this->date_valide = $obj->date_valide; + $this->date_create = $obj->date_create; + $this->date_refuse = $obj->date_refuse; + $this->date_cancel = $obj->date_cancel; + + $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_validator = $obj->fk_user_validator; + $this->fk_user_valid = $obj->fk_user_valid; + $this->fk_user_paid = $obj->fk_user_paid; + $this->fk_user_refuse = $obj->fk_user_refuse; + $this->fk_user_cancel = $obj->fk_user_cancel; + + $user_author = new User($this->db); + $user_author->fetch($this->fk_user_author); + $this->user_author_infos = dolGetFirstLastname($user_author->firstname, $user_author->lastname); + + $user_approver = new User($this->db); + $user_approver->fetch($this->fk_user_validator); + $this->user_validator_infos = dolGetFirstLastname($user_approver->firstname, $user_approver->lastname); + + $this->fk_c_expensereport_statuts = $obj->status; + $this->status = $obj->status; + $this->fk_c_paiement = $obj->fk_c_paiement; + + if ($this->fk_c_expensereport_statuts==5 || $this->fk_c_expensereport_statuts==6) + { + $user_valid = new User($this->db); + $user_valid->fetch($this->fk_user_valid); + $this->user_valid_infos = dolGetFirstLastname($user_valid->firstname, $user_valid->lastname); + } + + if ($this->fk_c_expensereport_statuts==6) + { + $user_paid = new User($this->db); + $user_paid->fetch($this->fk_user_paid); + $this->user_paid_infos = dolGetFirstLastname($user_paid->firstname, $user_paid->lastname); + } + + $this->libelle_statut = $obj->libelle_statut; + $this->libelle_paiement = $obj->libelle_paiement; + $this->code_statut = $obj->code_statut; + $this->code_paiement = $obj->code_paiement; + + $this->lignes = array(); + + $result=$this->fetch_lines(); + + return 1; + } + else { - $user_paid = new User($this->db); - $user_paid->fetch($this->fk_user_paid); - $this->user_paid_infos = dolGetFirstLastname($user_paid->firstname, $user_paid->lastname); + return 0; } - - $this->libelle_statut = $obj->libelle_statut; - $this->libelle_paiement = $obj->libelle_paiement; - $this->code_statut = $obj->code_statut; - $this->code_paiement = $obj->code_paiement; - - $this->lignes = array(); - - $result=$this->fetch_lines(); - - return 1; } else { - $this->error=$db->error(); + $this->error=$db->lasterror(); return -1; } } @@ -980,7 +986,7 @@ class ExpenseReport extends CommonObject function updateline($rowid, $type_fees_id, $projet_id, $c_tva, $comments, $qty, $value_unit, $date, $expensereport_id) { - if ($this->fk_c_expensereport_statuts==1 || $this->fk_c_expensereport_statuts==99) + if ($this->fk_c_expensereport_statuts==0 || $this->fk_c_expensereport_statuts==99) { $this->db->begin(); diff --git a/htdocs/expensereport/document.php b/htdocs/expensereport/document.php index 65ee2a1bbaa..7c02617c9ad 100644 --- a/htdocs/expensereport/document.php +++ b/htdocs/expensereport/document.php @@ -19,6 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * or see http://www.gnu.org/ */ /** diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index aae513618db..2ea024fb3b0 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -16,6 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * or see http://www.gnu.org/ */ /** diff --git a/htdocs/expensereport/info.php b/htdocs/expensereport/info.php index 866e67ec04b..0349cfb12e1 100644 --- a/htdocs/expensereport/info.php +++ b/htdocs/expensereport/info.php @@ -14,6 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * or see http://www.gnu.org/ */ /** @@ -46,15 +47,15 @@ if ($id) $object = new ExpenseReport($db); $object->fetch($id); $object->info($id); - + $head = trip_prepare_head($object); - + dol_fiche_head($head, 'info', $langs->trans("TripCard"), 0, 'trip'); print '
'; dol_print_object_info($object); print '
'; - + print ''; } diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 0d2be8a7c45..b9ec3c8e400 100755 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -15,8 +15,8 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program. If not, see . + * or see http://www.gnu.org/ */ /** @@ -81,7 +81,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$sql = "SELECT d.rowid, d.ref_number, d.total_ht, d.total_tva, d.total_ttc, d.fk_c_expensereport_statuts,"; +$sql = "SELECT d.rowid, d.ref_number, d.total_ht, d.total_tva, d.total_ttc, d.fk_c_expensereport_statuts as status,"; $sql.= " d.date_debut, d.date_fin,"; $sql.= " u.rowid as id_user, u.firstname, u.lastname"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport d\n"; @@ -266,8 +266,11 @@ if ($resql) print ''.price($objp->total_tva).''; print ''.price($objp->total_ttc).''; - $expensereporttmp->status=$objp->statut; - print ''.$expensereporttmp->getLibStatut(5).''; + $expensereporttmp->status=$objp->status; + print ''; + //print $objp->status; + print $expensereporttmp->getLibStatut(5); + print ''; print "\n"; $total_total_ht = $total_total_ht + $objp->total_ht; diff --git a/htdocs/expensereport/synchro_compta.php b/htdocs/expensereport/synchro_compta.php index 3f94da6eb1b..7d427c44fa1 100755 --- a/htdocs/expensereport/synchro_compta.php +++ b/htdocs/expensereport/synchro_compta.php @@ -1,4 +1,20 @@ + * + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ require '../main.inc.php'; require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php');