diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 221f071ad69..cb697e6cc70 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -180,15 +180,18 @@ if ($conf->tax->enabled) print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"cs.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"pc.rowid","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"pc.datep","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"pct.code","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"pc.amount","",$param,'align="right"',$sortfield,$sortorder); print "\n"; $sql = "SELECT c.id, c.libelle as lib,"; $sql.= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; - $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye"; + $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment,"; + $sql.= " pct.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; $sql.= " WHERE cs.fk_type = c.id"; $sql.= " AND cs.entity = ".$conf->entity; if ($year > 0) @@ -241,19 +244,27 @@ if ($conf->tax->enabled) print ''.$payment_sc_static->getNomUrl(1)."\n"; // Date payment print ''.dol_print_date($db->jdate($obj->datep),'day').''; + // Type payment + print ''; + if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + print $obj->num_payment.''; // Paid - print ''.price($obj->totalpaye).''; + print ''; + if ($obj->totalpaye) print price($obj->totalpaye); + print ''; print ''; + $total = $total + $obj->total; $totalnb = $totalnb + $obj->nb; $totalpaye = $totalpaye + $obj->totalpaye; $i++; } - print ''.$langs->trans("Total").''; - print ''.price($total).""; - print ' '; - print ' '; - print ''.price($totalpaye).""; + print ''.$langs->trans("Total").''; + print ''.price($total).""; + print ' '; + print ' '; + print ' '; + print ''.price($totalpaye).""; print ""; } else diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index cd52ada8220..61f50a08a0e 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -20,7 +20,7 @@ /** * \file htdocs/compta/deplacement/stats/index.php * \ingroup deplacement - * \brief Page des stats deplacement et notes de frais + * \brief Page for statistics of module trips and expenses */ require '../../../main.inc.php'; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index a8b1f737f39..831eb3f52ad 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -336,7 +336,8 @@ else if ($action == 'set_ref_client' && $user->rights->facture->creer) { } // Classify to validated -else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider) { +else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider) +{ $idwarehouse = GETPOST('idwarehouse'); $object->fetch($id); @@ -345,8 +346,8 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu // Check parameters // Check for mandatory prof id - for($i = 1; $i < 5; $i ++) { - + for($i = 1; $i < 6; $i ++) + { $idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY'; $idprof = 'idprof' . $i; if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) { @@ -374,9 +375,11 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu } } - if (! $error) { + if (! $error) + { $result = $object->validate($user, '', $idwarehouse); - if ($result >= 0) { + if ($result >= 0) + { // Define output language $outputlangs = $langs; $newlang = ''; @@ -393,7 +396,8 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else { - setEventMessage($object->error, 'errors'); + if (count($object->errors)) setEventMessage($object->errors, 'errors'); + else setEventMessage($object->error, 'errors'); } } } @@ -1878,7 +1882,9 @@ if ($action == 'create') } $absolute_discount = $soc->getAvailableDiscounts(); - if (! empty($conf->use_javascript_ajax)) { + if (! empty($conf->use_javascript_ajax)) + { + require_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; print ajax_combobox('fac_replacement'); print ajax_combobox('fac_avoir'); } diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 6b570f2eb5e..b6d30ae01b0 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -185,7 +185,7 @@ if ($_GET["action"] == 'create') print ''.$langs->trans("Label").''.$charge->lib."\n"; print ''.$langs->trans("DateDue")."".dol_print_date($charge->date_ech,'day')."\n"; - print ''.$langs->trans("AmountTTC")."".price($charge->amount).' '.$langs->trans("Currency".$conf->currency).''; + print ''.$langs->trans("Amount")."".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).''; $sql = "SELECT sum(p.amount) as total"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; @@ -197,8 +197,8 @@ if ($_GET["action"] == 'create') $sumpaid = $obj->total; $db->free(); } - print ''.$langs->trans("AlreadyPaid").''.price($sumpaid).' '.$langs->trans("Currency".$conf->currency).''; - print "".$langs->trans("RemainderToPay")."".price($total - $sumpaid).' '.$langs->trans("Currency".$conf->currency).''; + print ''.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).''; + print "".$langs->trans("RemainderToPay")."".price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).''; print "".$langs->trans("Payment").''; @@ -223,9 +223,10 @@ if ($_GET["action"] == 'create') $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, '',1); // Show opend bank account list print ''; + // Number print ''.$langs->trans('Numero'); print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - print "\n"; + print ''."\n"; /* * Autres charges impayees @@ -238,7 +239,7 @@ if ($_GET["action"] == 'create') print ''; //print ''.$langs->trans("SocialContribution").''; print ''.$langs->trans("DateDue").''; - print ''.$langs->trans("AmountTTC").''; + print ''.$langs->trans("Amount").''; print ''.$langs->trans("AlreadyPaid").''; print ''.$langs->trans("RemainderToPay").''; print ''.$langs->trans("Amount").''; @@ -296,7 +297,7 @@ if ($_GET["action"] == 'create') { // Print total print ""; - print ''.$langs->trans("TotalTTC").':'; + print ''.$langs->trans("Total").':'; print "".price($total_ttc).""; print "".price($totalrecu).""; print "".price($total_ttc - $totalrecu).""; @@ -304,29 +305,18 @@ if ($_GET["action"] == 'create') print "\n"; } print "\n"; - // } - // $db->free(); - // } - // else - // { - // print $sql ."
".$db->error(); - // } - /* - * - */ print ""; print '
'; - //print ''; + print ''; print '   '; print ''; print '
'; - //print ''; + print "\n"; - // } } diff --git a/htdocs/compta/payment_sc/fiche.php b/htdocs/compta/payment_sc/fiche.php index d502e6e2fc0..fd0df83fc1a 100644 --- a/htdocs/compta/payment_sc/fiche.php +++ b/htdocs/compta/payment_sc/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2009 Regis Houssin * @@ -37,13 +37,19 @@ $langs->load('banks'); $langs->load('companies'); // Security check -$id=isset($_GET["id"])?$_GET["id"]:$_POST["id"]; -$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; +$id=GETPOST("id"); +$action=GETPOST("action"); +$confirm=GETPOST('confirm'); if ($user->societe_id) $socid=$user->societe_id; // TODO ajouter regle pour restreindre acces paiement //$result = restrictedArea($user, 'facture', $id,''); -$mesg=''; +$paiement = new PaymentSocialContribution($db); +if ($id > 0) +{ + $result=$paiement->fetch($id); + if (! $result) dol_print_error($db,'Failed to get payment id '.$id); +} /* @@ -51,12 +57,10 @@ $mesg=''; */ // Delete payment -if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->tax->charges->supprimer) +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->charges->supprimer) { $db->begin(); - $paiement = new PaymentSocialContribution($db); - $paiement->fetch($_REQUEST['id']); $result = $paiement->delete($user); if ($result > 0) { @@ -66,19 +70,19 @@ if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && } else { - $mesg='
'.$paiement->error.'
'; + setEventMessage($paiement->error, 'errors'); $db->rollback(); } } // Create payment -if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $user->rights->tax->charges->creer) +if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->charges->creer) { $db->begin(); - $paiement = new PaymentSocialContribution($db); - $paiement->id = $_REQUEST['id']; - if ($paiement->valide() > 0) + $result=$paiement->valide(); + + if ($result > 0) { $db->commit(); @@ -102,7 +106,7 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && } else { - $mesg='
'.$paiement->error.'
'; + setEventMessage($paiement->error); $db->rollback(); } } @@ -115,14 +119,6 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && llxHeader(); $socialcontrib=new ChargeSociales($db); -$paiement = new PaymentSocialContribution($db); - -$result=$paiement->fetch($_GET['id']); -if ($result <= 0) -{ - dol_print_error($db,'Payment '.$_GET['id'].' not found in database'); - exit; -} $form = new Form($db); @@ -144,7 +140,7 @@ dol_fiche_head($head, $hselected, $langs->trans("PaymentSocialContribution"), 0, /* * Confirmation de la suppression du paiement */ -if ($_GET['action'] == 'delete') +if ($action == 'delete') { print $form->formconfirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2); @@ -153,7 +149,7 @@ if ($_GET['action'] == 'delete') /* * Confirmation de la validation du paiement */ -if ($_GET['action'] == 'valide') +if ($action == 'valide') { $facid = $_GET['facid']; print $form->formconfirm('fiche.php?id='.$paiement->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2); @@ -161,9 +157,6 @@ if ($_GET['action'] == 'valide') } -if ($mesg) print $mesg.'
'; - - print ''; // Ref @@ -182,8 +175,7 @@ print ''; // Montant -print ''; - +print ''; // Note print ''; @@ -262,7 +254,7 @@ if ($resql) // Expected to pay print ''; // Status - print ''; + print ''; // Amount payed print ''; print "\n"; @@ -323,7 +315,8 @@ if ($_GET['action'] == '') print ''; -$db->close(); llxFooter(); + +$db->close(); ?> diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index ebdd5fa1655..87e23e02deb 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -1,19 +1,19 @@ * - * 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 - * (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 . - */ +* 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 +* (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 . +*/ /** * \file htdocs/compta/salaries/class/paymentsalary.class.php @@ -26,270 +26,199 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; /** - * Put here description of your class + * Class to manage salary payments */ class PaymentSalary extends CommonObject { //public $element='payment_salary'; //!< Id that identify managed objects //public $table_element='payment_salary'; //!< Name of table without prefix where object is stored - var $id; - var $ref; + var $id; + var $ref; var $tms; var $fk_user; - var $datep; + var $datep; var $datev; var $amount; + var $type_payment; + var $num_payment; var $label; - var $datesp; - var $dateep; + var $datesp; + var $dateep; var $note; var $fk_bank; var $fk_user_creat; var $fk_user_modif; - - /** + /** * Constructor * * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - $this->element = 'payment_salary'; - $this->table_element = 'payment_salary'; - return 1; - } + */ + function __construct($db) + { + $this->db = $db; + $this->element = 'payment_salary'; + $this->table_element = 'payment_salary'; + return 1; + } + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=no, 1=yes (no update trigger) + * @return int <0 if KO, >0 if OK + */ + function update($user=0, $notrigger=0) + { + global $conf, $langs; - /** - * Create in database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ - function create($user) - { - global $conf, $langs; + $error=0; - $error=0; + // Clean parameters + $this->fk_user=trim($this->fk_user); + $this->amount=trim($this->amount); + $this->label=trim($this->label); + $this->note=trim($this->note); + $this->fk_bank=trim($this->fk_bank); + $this->fk_user_creat=trim($this->fk_user_creat); + $this->fk_user_modif=trim($this->fk_user_modif); - // Clean parameters - $this->fk_user=trim($this->fk_user); - $this->amount=trim($this->amount); - $this->label=trim($this->label); - $this->note=trim($this->note); - $this->fk_bank=trim($this->fk_bank); - $this->fk_user_creat=trim($this->fk_user_creat); - $this->fk_user_modif=trim($this->fk_user_modif); + // Check parameters + if (empty($this->fk_user) || $this->fk_user < 0) + { + $this->error='ErrorBadParameter'; + return -1; + } - // Check parameters - // Put here code to add control on parameters values + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; - // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary("; - $sql.= "tms,"; - $sql.= "fk_user,"; - $sql.= "datep,"; - $sql.= "datev,"; - $sql.= "amount,"; - $sql.= "label,"; - $sql.= "datesp,"; - $sql.= "dateep,"; - $sql.= "note,"; - $sql.= "fk_bank,"; - $sql.= "fk_user_creat,"; - $sql.= "fk_user_modif"; + $sql.= " tms=".$this->db->idate($this->tms).","; + $sql.= " fk_user='".$this->fk_user."',"; + $sql.= " datep=".$this->db->idate($this->datep).","; + $sql.= " datev=".$this->db->idate($this->datev).","; + $sql.= " amount='".$this->amount."',"; + $sql.= " fk_typepayment=".$this->fk_typepayment."',"; + $sql.= " num_payment='".$this->num_payment."',"; + $sql.= " label='".$this->db->escape($this->label)."',"; + $sql.= " datesp=".$this->db->idate($this->datesp).","; + $sql.= " dateep=".$this->db->idate($this->dateep).","; + $sql.= " note='".$this->db->escape($this->note)."',"; + $sql.= " fk_bank=".($this->fk_bank > 0 ? "'".$this->fk_bank."'":"null").","; + $sql.= " fk_user_creat='".$this->fk_user_creat."',"; + $sql.= " fk_user_modif='".$this->fk_user_modif."'"; - $sql.= ") VALUES ("; + $sql.= " WHERE rowid=".$this->id; - $sql.= " '".$this->db->idate($this->tms).","; - $sql.= " '".$this->fk_user."',"; - $sql.= " '".$this->db->idate($this->datep)."',"; - $sql.= " '".$this->db->idate($this->datev)."',"; - $sql.= " '".$this->amount."',"; - $sql.= " '".$this->label."',"; - $sql.= " '".$this->db->idate($this->datesp)."',"; - $sql.= " '".$this->db->idate($this->dateep)."',"; - $sql.= " '".$this->note."',"; - $sql.= " ".($this->fk_bank <= 0 ? "NULL" : "'".$this->fk_bank."'").","; - $sql.= " '".$this->fk_user_creat."',"; - $sql.= " '".$this->fk_user_modif."'"; - - $sql.= ")"; - - dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PAYMENT_SALARY_CREATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - - return $this->id; - } - else - { - $this->error="Error ".$this->db->lasterror(); - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -1; - } - } - - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=no, 1=yes (no update trigger) - * @return int <0 if KO, >0 if OK - */ - function update($user=0, $notrigger=0) - { - global $conf, $langs; - - $error=0; - - // Clean parameters - $this->fk_user=trim($this->fk_user); - $this->amount=trim($this->amount); - $this->label=trim($this->label); - $this->note=trim($this->note); - $this->fk_bank=trim($this->fk_bank); - $this->fk_user_creat=trim($this->fk_user_creat); - $this->fk_user_modif=trim($this->fk_user_modif); - - // Check parameters - if (empty($this->fk_user) || $this->fk_user < 0) - { - $this->error='ErrorBadParameter'; - return -1; - } - - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; - - $sql.= " tms=".$this->db->idate($this->tms).","; - $sql.= " fk_user='".$this->fk_user."',"; - $sql.= " datep=".$this->db->idate($this->datep).","; - $sql.= " datev=".$this->db->idate($this->datev).","; - $sql.= " amount='".$this->amount."',"; - $sql.= " label='".$this->db->escape($this->label)."',"; - $sql.= " datesp=".$this->db->idate($this->datesp).","; - $sql.= " dateep=".$this->db->idate($this->dateep).","; - $sql.= " note='".$this->db->escape($this->note)."',"; - $sql.= " fk_bank='".$this->fk_bank."',"; - $sql.= " fk_user_creat='".$this->fk_user_creat."',"; - $sql.= " fk_user_modif='".$this->fk_user_modif."'"; - - $sql.= " WHERE rowid=".$this->id; - - dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) - { - $this->error="Error ".$this->db->lasterror(); - dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); - return -1; - } + dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); + return -1; + } if (! $notrigger) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PAYMENT_SALARY_MODIFY',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - } + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('PAYMENT_SALARY_MODIFY',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + } - return 1; - } + return 1; + } - /** - * Load object in memory from database - * - * @param int $id id object - * @param User $user User that load - * @return int <0 if KO, >0 if OK - */ - function fetch($id, $user=0) - { - global $langs; - $sql = "SELECT"; - $sql.= " s.rowid,"; + /** + * Load object in memory from database + * + * @param int $id id object + * @param User $user User that load + * @return int <0 if KO, >0 if OK + */ + function fetch($id, $user=0) + { + global $langs; + $sql = "SELECT"; + $sql.= " s.rowid,"; - $sql.= " s.tms,"; - $sql.= " s.fk_user,"; - $sql.= " s.datep,"; - $sql.= " s.datev,"; - $sql.= " s.amount,"; - $sql.= " s.label,"; - $sql.= " s.datesp,"; - $sql.= " s.dateep,"; - $sql.= " s.note,"; - $sql.= " s.fk_bank,"; - $sql.= " s.fk_user_creat,"; - $sql.= " s.fk_user_modif,"; - $sql.= " b.fk_account,"; - $sql.= " b.fk_type,"; - $sql.= " b.rappro"; + $sql.= " s.tms,"; + $sql.= " s.fk_user,"; + $sql.= " s.datep,"; + $sql.= " s.datev,"; + $sql.= " s.amount,"; + $sql.= " s.fk_typepayment,"; + $sql.= " s.num_payment,"; + $sql.= " s.label,"; + $sql.= " s.datesp,"; + $sql.= " s.dateep,"; + $sql.= " s.note,"; + $sql.= " s.fk_bank,"; + $sql.= " s.fk_user_creat,"; + $sql.= " s.fk_user_modif,"; + $sql.= " b.fk_account,"; + $sql.= " b.fk_type,"; + $sql.= " b.rappro"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; - $sql.= " WHERE s.rowid = ".$id; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; + $sql.= " WHERE s.rowid = ".$id; - dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->tms = $this->db->jdate($obj->tms); - $this->fk_user = $obj->fk_user; - $this->datep = $this->db->jdate($obj->datep); - $this->datev = $this->db->jdate($obj->datev); - $this->amount = $obj->amount; - $this->label = $obj->label; - $this->datesp = $this->db->jdate($obj->datesp); - $this->dateep = $this->db->jdate($obj->dateep); - $this->note = $obj->note; - $this->fk_bank = $obj->fk_bank; - $this->fk_user_creat = $obj->fk_user_creat; - $this->fk_user_modif = $obj->fk_user_modif; - $this->fk_account = $obj->fk_account; - $this->fk_type = $obj->fk_type; - $this->rappro = $obj->rappro; - } - $this->db->free($resql); + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->tms = $this->db->jdate($obj->tms); + $this->fk_user = $obj->fk_user; + $this->datep = $this->db->jdate($obj->datep); + $this->datev = $this->db->jdate($obj->datev); + $this->amount = $obj->amount; + $this->type_payement = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; + $this->label = $obj->label; + $this->datesp = $this->db->jdate($obj->datesp); + $this->dateep = $this->db->jdate($obj->dateep); + $this->note = $obj->note; + $this->fk_bank = $obj->fk_bank; + $this->fk_user_creat = $obj->fk_user_creat; + $this->fk_user_modif = $obj->fk_user_modif; + $this->fk_account = $obj->fk_account; + $this->fk_type = $obj->fk_type; + $this->rappro = $obj->rappro; + } + $this->db->free($resql); - return 1; - } - else - { - $this->error="Error ".$this->db->lasterror(); - dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); - return -1; - } - } + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } - /** + /** * Delete object in database * - * @param User $user User that delete + * @param User $user User that delete * @return int <0 if KO, >0 if OK */ function delete($user) @@ -301,32 +230,34 @@ class PaymentSalary extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary"; $sql.= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::delete sql=".$sql); + dol_syslog(get_class($this)."::delete sql=".$sql); $resql = $this->db->query($sql); if (! $resql) { $this->error="Error ".$this->db->lasterror(); - dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); return -1; } - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PAYMENT_SALARY_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('PAYMENT_SALARY_DELETE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers return 1; } /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void */ function initAsSpecimen() { @@ -334,7 +265,7 @@ class PaymentSalary extends CommonObject $this->tms=''; $this->fk_user=''; - $this->datep=''; + $this->datep=''; $this->datev=''; $this->amount=''; $this->label=''; @@ -346,192 +277,198 @@ class PaymentSalary extends CommonObject $this->fk_user_modif=''; } - /** - * Ajoute un paiement de salaire - * + /** + * Ajoute un paiement de salaire + * * @param User $user Object user that insert * @return int <0 if KO, rowid in tva table if OK - */ - function addPayment($user) - { - global $conf,$langs; + */ + function create($user) + { + global $conf,$langs; - $this->db->begin(); + // Clean parameters + $this->amount=price2num(trim($this->amount)); - // Clean parameters - $this->amount=price2num(trim($this->amount)); + // Check parameters + if (! $this->label) + { + $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")); + return -3; + } + if ($this->fk_user < 0 || $this->fk_user == '') + { + $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Employee")); + return -4; + } + if ($this->amount < 0 || $this->amount == '') + { + $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount")); + return -5; + } + if (! empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) + { + $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Account")); + return -6; + } + if (! empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) + { + $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); + return -6; + } - // Check parameters - if (! $this->label) - { - $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")); - return -3; - } - if ($this->fk_user < 0 || $this->fk_user == '') - { - $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Employee")); - return -4; - } - if ($this->amount < 0 || $this->amount == '') - { - $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount")); - return -5; - } - if (! empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) - { - $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Account")); - return -6; - } - if (! empty($conf->banque->enabled) && (empty($this->paymenttype) || $this->paymenttype <= 0)) - { - $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); - return -6; - } + $this->db->begin(); - // Insertion dans table des paiement salaires - $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user"; - $sql.= ", datep"; - $sql.= ", datev"; - $sql.= ", amount"; - if ($this->note) $sql.=", note"; - if ($this->label) $sql.=", label"; - $sql.= ", datesp"; - $sql.= ", dateep"; - $sql.= ", fk_user_creat"; - $sql.= ", fk_bank"; - $sql.= ", entity"; - $sql.= ") "; - $sql.= " VALUES ("; - $sql.= "'".$this->fk_user."'"; - $sql.= ", '".$this->db->idate($this->datep)."'"; - $sql.= ", '".$this->db->idate($this->datev)."'"; - $sql.= ", ".$this->amount; - if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; - if ($this->label) $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", '".$this->db->idate($this->datesp)."'"; - $sql.= ", '".$this->db->idate($this->dateep)."'"; - $sql.= ", '".$user->id."'"; - $sql.= ", NULL"; - $sql.= ", ".$conf->entity; - $sql.= ")"; + // Insertion dans table des paiement salaires + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user"; + $sql.= ", datep"; + $sql.= ", datev"; + $sql.= ", amount"; + $sql.= ", fk_typepayment"; + $sql.= ", num_payment"; + $sql.=", note"; + $sql.=", label"; + $sql.= ", datesp"; + $sql.= ", dateep"; + $sql.= ", fk_user_creat"; + $sql.= ", fk_bank"; + $sql.= ", entity"; + $sql.= ") "; + $sql.= " VALUES ("; + $sql.= "'".$this->fk_user."'"; + $sql.= ", '".$this->db->idate($this->datep)."'"; + $sql.= ", '".$this->db->idate($this->datev)."'"; + $sql.= ", ".$this->amount; + $sql.= ", ".$this->type_payment; + $sql.= ", ".$this->num_payment; + $sql.= ", '".$this->db->escape($this->note)."'"; + $sql.= ", '".$this->db->escape($this->label)."'"; + $sql.= ", '".$this->db->idate($this->datesp)."'"; + $sql.= ", '".$this->db->idate($this->dateep)."'"; + $sql.= ", '".$user->id."'"; + $sql.= ", NULL"; + $sql.= ", ".$conf->entity; + $sql.= ")"; - dol_syslog(get_class($this)."::addPayment sql=".$sql); - $result = $this->db->query($sql); - if ($result) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); // TODO devrait s'appeler payment_salary + dol_syslog(get_class($this)."::create sql=".$sql); + $result = $this->db->query($sql); + if ($result) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); // TODO devrait s'appeler payment_salary - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PAYMENT_SALARY_ADDPAYMENT',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('PAYMENT_SALARY_CREATE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers - if ($this->id > 0) - { - $ok=1; - if (! empty($conf->banque->enabled) && ! empty($this->amount)) - { - // Insertion dans llx_bank - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + if ($this->id > 0) + { + $ok=1; + if (! empty($conf->banque->enabled) && ! empty($this->amount)) + { + // Insertion dans llx_bank + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $acc = new Account($this->db); - $result=$acc->fetch($this->accountid); - if ($result <= 0) dol_print_error($this->db); + $acc = new Account($this->db); + $result=$acc->fetch($this->accountid); + if ($result <= 0) dol_print_error($this->db); - // Insert payment into llx_bank - // Add link 'payment_salary' in bank_url between payment and bank transaction - $bank_line_id = $acc->addline( - $this->datep, - $this->paymenttype, - $this->label, - -abs($this->amount), - '', - '', - $user - ); + // Insert payment into llx_bank + // Add link 'payment_salary' in bank_url between payment and bank transaction + $bank_line_id = $acc->addline( + $this->datep, + $this->type_payment, + $this->label, + -abs($this->amount), + $this->num_payment, + '', + $user + ); - // Mise a jour fk_bank dans llx_paiement. - // On connait ainsi le paiement qui a genere l'ecriture bancaire - if ($bank_line_id > 0) - { - $this->update_fk_bank($bank_line_id); - } - else - { - $this->error=$acc->error; - $ok=0; - } + // Mise a jour fk_bank dans llx_paiement. + // On connait ainsi le paiement qui a genere l'ecriture bancaire + if ($bank_line_id > 0) + { + $this->update_fk_bank($bank_line_id); + } + else + { + $this->error=$acc->error; + $ok=0; + } - // Add link 'payment_salary' in bank_url between payment and bank transaction - $url=DOL_URL_ROOT.'/compta/salaries/fiche.php?id='; + // Add link 'payment_salary' in bank_url between payment and bank transaction + $url=DOL_URL_ROOT.'/compta/salaries/fiche.php?id='; - $result=$acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); - if ($result <= 0) - { - $this->error=$acc->error; - $ok=0; - } + $result=$acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); + if ($result <= 0) + { + $this->error=$acc->error; + $ok=0; + } - // Add link 'user' in bank_url between operation and bank transaction - $linkaddedforthirdparty=array(); - foreach ($this->amounts as $key => $value) - { - $sal = new PaymentSalary($this->db); + // Add link 'user' in bank_url between operation and bank transaction + $linkaddedforthirdparty=array(); + foreach ($this->amounts as $key => $value) + { + $sal = new PaymentSalary($this->db); - $sal->fetch($key); - $sal->fetch_user($this->fk_user); + $sal->fetch($key); + $sal->fetch_user($this->fk_user); - if (! in_array($sal->user->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty - { - $result=$acc->add_url_line( - $bank_line_id, - $sal->user->id, - DOL_URL_ROOT.'/user/fiche.php?id=', - $sal->user->lastname, - 'user' - ); + if (! in_array($sal->user->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty + { + $result=$acc->add_url_line( + $bank_line_id, + $sal->user->id, + DOL_URL_ROOT.'/user/fiche.php?id=', + $sal->user->lastname, + 'user' + ); - if ($result <= 0) dol_print_error($this->db); - $linkaddedforthirdparty[$sal->user->id]=$sal->user->id; // Mark as done for this thirdparty - } + if ($result <= 0) dol_print_error($this->db); + $linkaddedforthirdparty[$sal->user->id]=$sal->user->id; // Mark as done for this thirdparty + } - } - } + } + } - if ($ok) - { - $this->db->commit(); - return $this->id; - } - else - { - $this->db->rollback(); - return -3; - } - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -2; - } - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } - } + if ($ok) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + return -3; + } + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -2; + } + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } - /** - * Mise a jour du lien entre le paiement salaire et la ligne générée dans llx_bank - * - * @param int $id_bank Id compte bancaire + /** + * Mise a jour du lien entre le paiement salaire et la ligne générée dans llx_bank + * + * @param int $id_bank Id compte bancaire * @return int <0 if KO, >0 if OK - */ + */ function update_fk_bank($id_bank) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank; diff --git a/htdocs/compta/salaries/fiche.php b/htdocs/compta/salaries/fiche.php index ca49efc068b..5febffa2b7b 100644 --- a/htdocs/compta/salaries/fiche.php +++ b/htdocs/compta/salaries/fiche.php @@ -1,5 +1,6 @@ + * Copyright (C) 2014 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 @@ -17,7 +18,7 @@ /** * \file htdocs/compta/salaries/fiche.php - * \ingroup tax + * \ingroup salaries * \brief Page of salaries payments */ @@ -59,50 +60,73 @@ if ($_POST["cancel"] == $langs->trans("Cancel")) if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { - $db->begin(); + $error=0; - $datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); - $datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); - $datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]); - $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]); + $datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); + $datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); + $datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]); + $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]); + $sal->accountid=GETPOST("accountid"); + $sal->fk_user=GETPOST("fk_user"); + $sal->datev=$datev; + $sal->datep=$datep; + $sal->amount=price2num(GETPOST("amount")); + $sal->label=GETPOST("label"); + $sal->datesp=$datesp; + $sal->dateep=$dateep; + $sal->type_payment=GETPOST("paymenttype"); + $sal->num_payment=GETPOST('num_payment'); - $sal->accountid=$_POST["accountid"]; - $sal->paymenttype=$_POST["paiementtype"]; - $sal->fk_user=$_POST["fk_user"]; - $sal->datev=$datev; - $sal->datep=$datep; - $sal->amount=$_POST["amount"]; - $sal->label=$_POST["label"]; - $sal->datesp=$datesp; - $sal->dateep=$dateep; + if (empty($sal->fk_user) || $sal->fk_user < 0) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Employee")),'errors'); + $error++; + } + if (empty($sal->type_payment) || $sal->type_payment < 0) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentMode")),'errors'); + $error++; + } + if (empty($sal->amount)) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")),'errors'); + $error++; + } - $ret=$sal->addPayment($user); - if ($ret > 0) - { - $db->commit(); - header("Location: index.php"); - exit; - } - else - { - $db->rollback(); - setEventMessage($sal->error, 'errors'); - $action="create"; - } + if (! $error) + { + $db->begin(); + + $ret=$sal->create($user); + if ($ret > 0) + { + $db->commit(); + header("Location: index.php"); + exit; + } + else + { + $db->rollback(); + setEventMessage($sal->error, 'errors'); + $action="create"; + } + } + + $action='create'; } if ($action == 'delete') { - $result=$sal->fetch($id); + $result=$sal->fetch($id); if ($sal->rappro == 0) { - $db->begin(); + $db->begin(); - $ret=$sal->delete($user); - if ($ret > 0) - { + $ret=$sal->delete($user); + if ($ret > 0) + { if ($sal->fk_bank) { $accountline=new AccountLine($db); @@ -122,23 +146,23 @@ if ($action == 'delete') $db->rollback(); setEventMessage($sal->error,'errors'); } - } - else - { - $db->rollback(); - setEventMessage($sal->error,'errors'); - } + } + else + { + $db->rollback(); + setEventMessage($sal->error,'errors'); + } } else { - setEventMessage('Error try do delete a line linked to a conciliated bank transaction','errors'); + setEventMessage('Error try do delete a line linked to a conciliated bank transaction','errors'); } } /* -* View -*/ + * View + */ llxHeader(); @@ -146,7 +170,7 @@ $form = new Form($db); if ($id) { - $salpayment = new PaymentSalary($db); + $salpayment = new PaymentSalary($db); $result = $salpayment->fetch($id); if ($result <= 0) { @@ -158,86 +182,93 @@ if ($id) // Formulaire saisie salaire if ($action == 'create') { - $year_current = strftime("%Y",dol_now()); - $pastmonth = strftime("%m",dol_now()) - 1; - $pastmonthyear = $year_current; - if ($pastmonth == 0) - { - $pastmonth = 12; - $pastmonthyear--; - } + $year_current = strftime("%Y",dol_now()); + $pastmonth = strftime("%m",dol_now()) - 1; + $pastmonthyear = $year_current; + if ($pastmonth == 0) + { + $pastmonth = 12; + $pastmonthyear--; + } - $datesp=dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear); - $dateep=dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear); + $datesp=dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear); + $dateep=dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear); - if (empty($datesp) || empty($dateep)) // We define date_start and date_end - { - $datesp=dol_get_first_day($pastmonthyear,$pastmonth,false); $dateep=dol_get_last_day($pastmonthyear,$pastmonth,false); - } + if (empty($datesp) || empty($dateep)) // We define date_start and date_end + { + $datesp=dol_get_first_day($pastmonthyear,$pastmonth,false); $dateep=dol_get_last_day($pastmonthyear,$pastmonth,false); + } - print "
\n"; - print ''; - print ''; + print "\n"; + print ''; + print ''; - print_fiche_titre($langs->trans("NewSalaryPayment")); + print_fiche_titre($langs->trans("NewSalaryPayment")); - print '
'.$langs->trans('Mode').''.$lan print '
'.$langs->trans('Numero').''.$paiement->num_paiement.'
'.$langs->trans('Amount').''.price($paiement->amount).' '.$langs->trans('Currency'.$conf->currency).'
'.$langs->trans('Amount').''.price($paiement->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($paiement->note).'
'.price($objp->sc_amount).''.$socialcontrib->getLibStatut(4).''.$socialcontrib->getLibStatut(4,$objp->amount).''.price($objp->amount).'
'; + print '
'; - print ""; - print ''; + print ""; + print ''; - print ''; + print ''; - // Employee - print ""; - print ''; + // Employee + print ""; + print ''; - // Label - print ''; + // Label + print ''; - print ""; - print ''; + print ""; + print ''; - print ''; + print ''; - // Amount - print ''; + // Amount + print ''; - // Bank - if (! empty($conf->banque->enabled)) - { - print ''; + // Bank + if (! empty($conf->banque->enabled)) + { + print ''; - print '\n"; - print ""; - } + } - // Other attributes - $parameters=array('colspan' => ' colspan="1"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + // TYpe payment + print '\n"; + print ""; + + // Number + print ''."\n"; + + // Other attributes + $parameters=array('colspan' => ' colspan="1"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - print '
'.$langs->trans("DatePayment").''; - print $form->select_date($datep,"datep",'','','','add'); - print '
'.$langs->trans("DatePayment").''; + print $form->select_date($datep,"datep",'','','','add'); + print '
'.$langs->trans("DateValue").''; - print $form->select_date($datev,"datev",'','','','add'); - print '
'.$langs->trans("DateValue").''; + print $form->select_date($datev,"datev",'','','','add'); + print '
'.$langs->trans("Employee").''; - print $form->select_dolusers(GETPOST('fk_user','int'),'fk_user',1); - print '
'.$langs->trans("Employee").''; + print $form->select_dolusers(GETPOST('fk_user','int'),'fk_user',1); + print '
'.$langs->trans("Label").'trans("SalaryPayment")).'">
'.$langs->trans("Label").'trans("SalaryPayment")).'">
'.$langs->trans("DateStartPeriod").''; - print $form->select_date($datesp,"datesp",'','','','add'); - print '
'.$langs->trans("DateStartPeriod").''; + print $form->select_date($datesp,"datesp",'','','','add'); + print '
'.$langs->trans("DateEndPeriod").''; - print $form->select_date($dateep,"dateep",'','','','add'); - print '
'.$langs->trans("DateEndPeriod").''; + print $form->select_date($dateep,"dateep",'','','','add'); + print '
'.$langs->trans("Amount").'
'.$langs->trans("Amount").'
'.$langs->trans("Account").''; - $form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant - print '
'.$langs->trans("Account").''; + $form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant + print '
'.$langs->trans("PaymentMode").''; - $form->select_types_paiements($_POST["paiementtype"], "paiementtype"); - print "
'.$langs->trans("PaymentMode").''; + $form->select_types_paiements(GETPOST("paymenttype"), "paymenttype"); + print "
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'; + print ''; - print "
"; + print "
"; - print '
  '; - print '
'; + print '
  '; + print '
'; - print ''; + print ''; } @@ -265,17 +296,17 @@ if ($id) print $salpayment->ref; print ''; - // Person - print ''.$langs->trans("Person").''; - $usersal=new User($db); - $usersal->fetch($salpayment->fk_user); - print $usersal->getNomUrl(1); - print ''; + // Person + print ''.$langs->trans("Person").''; + $usersal=new User($db); + $usersal->fetch($salpayment->fk_user); + print $usersal->getNomUrl(1); + print ''; // Label print ''.$langs->trans("Label").''.$salpayment->label.''; - print ""; + print ""; print ''.$langs->trans("DateStartPeriod").''; print dol_print_date($salpayment->datesp,'day'); print ''; @@ -293,34 +324,34 @@ if ($id) print dol_print_date($salpayment->datev,'day'); print ''; - print ''.$langs->trans("Amount").''.price($salpayment->amount).''; + print ''.$langs->trans("Amount").''.price($salpayment->amount,0,$outputlangs,1,-1,-1,$conf->currency).''; if (! empty($conf->banque->enabled)) { if ($salpayment->fk_account > 0) { - $bankline=new AccountLine($db); - $bankline->fetch($salpayment->fk_bank); + $bankline=new AccountLine($db); + $bankline->fetch($salpayment->fk_bank); - print ''; - print ''.$langs->trans('BankTransactionLine').''; - print ''; - print $bankline->getNomUrl(1,0,'showall'); - print ''; - print ''; + print ''; + print ''.$langs->trans('BankTransactionLine').''; + print ''; + print $bankline->getNomUrl(1,0,'showall'); + print ''; + print ''; } } - // Other attributes - $parameters=array('colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$salpayment,$action); // Note that $action and $object may have been modified by hook + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$salpayment,$action); // Note that $action and $object may have been modified by hook print ''; print ''; /* - * Boutons d'actions + * Boutons d'actions */ print "
\n"; if ($salpayment->rappro == 0) @@ -342,7 +373,8 @@ if ($id) } -$db->close(); llxFooter(); -?> + +$db->close(); +?> \ No newline at end of file diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 7de22d79196..f32c1bad951 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -17,8 +17,8 @@ /** * \file htdocs/compta/salaries/index.php - * \ingroup tax - * \brief List of salaries payments + * \ingroup salaries + * \brief List of salaries payments */ require '../../main.inc.php'; @@ -26,6 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; $langs->load("compta"); $langs->load("salaries"); +$langs->load("bills"); // Security check $socid = isset($_GET["socid"])?$_GET["socid"]:''; @@ -46,8 +47,11 @@ $userstatic = new User($db); print_fiche_titre($langs->trans("SalariesPayments")); -$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm"; -$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u"; +$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.num_payment,"; +$sql.= " pst.code as payment_code"; +$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id,"; +$sql.= " ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE u.rowid = s.fk_user"; $sql.= " AND s.entity = ".$conf->entity; $sql.= " ORDER BY dm DESC"; @@ -65,6 +69,7 @@ if ($result) print "".$langs->trans("Person").""; print "".$langs->trans("Label").""; print ''.$langs->trans("DatePayment").''; + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"c.libelle","",$paramlist,"",$sortfield,$sortorder); print "".$langs->trans("PayedByThisPayment").""; print "\n"; $var=1; @@ -78,20 +83,23 @@ if ($result) $userstatic->lastname=$obj->lastname; $userstatic->firstname=$obj->firstname; $salstatic->id=$obj->rowid; - $salstatic->ref=$obj->rowid; + $salstatic->ref=$obj->rowid; print "".$salstatic->getNomUrl(1)."\n"; - print "".$userstatic->getNomUrl(1)."\n"; + print "".$userstatic->getNomUrl(1)."\n"; print "".dol_trunc($obj->label,40)."\n"; print ''.dol_print_date($db->jdate($obj->dm),'day')."\n"; - $total = $total + $obj->amount; - - print "".price($obj->amount).""; + // Type + print ''.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''; + // Amount + print "".price($obj->amount,0,$outputlangs,1,-1,-1,$conf->currency).""; print "\n"; + $total = $total + $obj->amount; + $i++; } - print ''.$langs->trans("Total").''; - print "".price($total).""; + print ''.$langs->trans("Total").''; + print ''.price($total,0,$outputlangs,1,-1,-1,$conf->currency).""; print ""; $db->free($result); diff --git a/htdocs/compta/sociales/charges.php b/htdocs/compta/sociales/charges.php index adc5fb8ae74..99268fe29f8 100644 --- a/htdocs/compta/sociales/charges.php +++ b/htdocs/compta/sociales/charges.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2013 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -32,6 +32,7 @@ $langs->load("bills"); $id=GETPOST('id','int'); $action=GETPOST("action"); +$confirm=GETPOST('confirm'); // Security check $socid = GETPOST('socid','int'); @@ -47,20 +48,16 @@ $result = restrictedArea($user, 'tax', $id, 'chargesociales','charges'); /* */ /* *************************************************************************** */ -/* - * Classify paid - */ -if ($action == 'confirm_paid' && $_REQUEST["confirm"] == 'yes') +// Classify paid +if ($action == 'confirm_paid' && $confirm == 'yes') { $chargesociales = new ChargeSociales($db); $chargesociales->fetch($id); $result = $chargesociales->set_paid($user); } -/* - * Delete social contribution - */ -if ($action == 'confirm_delete' && $_REQUEST["confirm"] == 'yes') +// Delete social contribution +if ($action == 'confirm_delete' && $confirm == 'yes') { $chargesociales=new ChargeSociales($db); $chargesociales->fetch($id); @@ -77,10 +74,7 @@ if ($action == 'confirm_delete' && $_REQUEST["confirm"] == 'yes') } -/* - * Add social contribution - */ - +// Add social contribution if ($action == 'add' && $user->rights->tax->charges->creer) { $dateech=@dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]); @@ -226,7 +220,7 @@ if ($action == 'create') print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1); print ''; - print ''; + print ''; print ''; print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1); @@ -303,8 +297,8 @@ if ($id > 0) print ''; /* - * Paiements - */ + * Paiements + */ $sql = "SELECT p.rowid, p.num_paiement, datep as dp, p.amount,"; $sql.= "c.libelle as paiement_type"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; @@ -325,7 +319,7 @@ if ($id > 0) echo ''; print ''; print ''; - print ''; + print ''; $var=True; while ($i < $num) @@ -336,7 +330,7 @@ if ($id > 0) print ''.img_object($langs->trans("Payment"),"payment").' '; print dol_print_date($db->jdate($objp->dp),'day')."\n"; print "\n"; - print '\n"; + print '\n"; print ""; $totalpaye += $objp->amount; $i++; @@ -363,7 +357,7 @@ if ($id > 0) print ""; - // Period end date + // Period end date print ""; print "'; + print ''; // Status - print ''; + print ''; print '
'.$langs->trans("Payments").''.$langs->trans("Type").''.$langs->trans("Amount").' 
'.$langs->trans("Amount").' 
".$objp->paiement_type.' '.$objp->num_paiement."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("PeriodEndDate").""; if ($action == 'edit') @@ -388,10 +382,10 @@ if ($id > 0) } // Amount - print '
'.$langs->trans("AmountTTC").''.price($object->amount).'
'.$langs->trans("AmountTTC").''.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("Status").''.$object->getLibStatut(4, $totalpaye).'
'; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 4efd90c10aa..8693ff31b70 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -102,7 +102,7 @@ class ChargeSociales extends CommonObject } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -1; } } @@ -317,28 +317,31 @@ class ChargeSociales extends CommonObject } /** - * Retourne le libelle du statut d'une charge (impaye, payee) + * Retourne le libelle du statut d'une charge (impaye, payee) * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long - * @return string Label + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @return string Label */ - function getLibStatut($mode=0) + function getLibStatut($mode=0,$alreadypayed=-1) { - return $this->LibStatut($this->paye,$mode); + return $this->LibStatut($this->paye,$mode,$alreadypayed); } /** - * Renvoi le libelle d'un statut donne + * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label + * @param int $statut Id statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @return string Label */ - function LibStatut($statut,$mode=0) + function LibStatut($statut,$mode=0,$alreadypayed=-1) { global $langs; $langs->load('customers'); - + $langs->load('bills'); + if ($mode == 0) { if ($statut == 0) return $langs->trans("Unpaid"); @@ -361,12 +364,14 @@ class ChargeSociales extends CommonObject } if ($mode == 4) { - if ($statut == 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); + if ($statut == 0 && $alreadypayed <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); + if ($statut == 0 && $alreadypayed > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); } if ($mode == 5) { - if ($statut == 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); + if ($statut == 0 && $alreadypayed <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); + if ($statut == 0 && $alreadypayed > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); } diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 88c888de62e..0647f0986d8 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2005 Simon TOSSER @@ -63,7 +63,7 @@ if (! $sortfield) $sortfield="name"; $object = new ChargeSociales($db); -$object->fetch($id); +if ($id > 0) $object->fetch($id); $upload_dir = $conf->tax->dir_output.'/'.dol_sanitizeFileName($object->ref); $modulepart='tax'; @@ -87,6 +87,8 @@ llxHeader("",$langs->trans("SocialContribution"),$help_url); if ($object->id) { + $alreadypayed=$object->getSommePaiement(); + $head=tax_prepare_head($object, $user); dol_fiche_head($head, 'documents', $langs->trans("SocialContribution"), 0, 'bill'); @@ -149,10 +151,10 @@ if ($object->id) } // Amount - print ''.$langs->trans("AmountTTC").''.price($object->amount).''; + print ''.$langs->trans("AmountTTC").''.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).''; // Status - print ''.$langs->trans("Status").''.$object->getLibStatut(4).''; + print ''.$langs->trans("Status").''.$object->getLibStatut(4,$alreadypayed).''; print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; print ''.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").''; diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 6ccc9943afa..89e2f84d7fb 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -78,12 +78,14 @@ llxHeader(); $sql = "SELECT cs.rowid as id, cs.fk_type as type, "; $sql.= " cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode,"; -$sql.= " c.libelle as type_lib"; -$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; -$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; +$sql.= " c.libelle as type_lib,"; +$sql.= " SUM(pc.amount) as alreadypayed"; +$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; +$sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; $sql.= " WHERE cs.fk_type = c.id"; $sql.= " AND cs.entity = ".$conf->entity; -if (GETPOST("search_label")) $sql.=" AND cs.libelle LIKE '%".GETPOST("search_label")."%'"; +if (GETPOST("search_label")) $sql.=" AND cs.libelle LIKE '%".$db->escape(GETPOST("search_label"))."%'"; if ($year > 0) { $sql .= " AND ("; @@ -100,6 +102,7 @@ if ($filtre) { if ($typeid) { $sql .= " AND cs.fk_type=".$typeid; } +$sql.= " GROUP BY cs.rowid, cs.fk_type, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, c.libelle"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1,$offset); @@ -207,7 +210,7 @@ if ($resql) // Due date print ''.dol_print_date($db->jdate($obj->date_ech), 'day').''; - print ''.$chargesociale_static->LibStatut($obj->paye,5).''; + print ''.$chargesociale_static->LibStatut($obj->paye,5,$obj->alreadypayed).''; print ''; $i++; diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index 81cba912dff..cc7464ec3e9 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -72,8 +72,10 @@ class box_ficheinter extends ModeleBoxes $sql.= ", ".MAIN_DB_PREFIX."fichinter as f"; $sql.= " WHERE f.fk_soc = s.rowid "; $sql.= " AND f.entity = ".$conf->entity; - if (! $user->rights->societe->client->voir) + if (! $user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + $sql.= " ORDER BY f.tms DESC"; $sql.= $db->plimit($max, 0); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index c35fad153b4..b522e811515 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -674,6 +674,7 @@ class ExtraFields $out = ''; if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT && ! $forcecombo) { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $out.= ajax_combobox('options_'.$key.$keyprefix, $event, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); } @@ -693,6 +694,7 @@ class ExtraFields $out = ''; if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT && ! $forcecombo) { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $out.= ajax_combobox('options_'.$key.$keyprefix, $event, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3574c841339..4b9f8c4cda0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -732,9 +732,9 @@ class Form * @return string HTML string with * @deprecated Use select_thirdparty instead */ - function select_company($selected='', $htmlname='socid', $filter='', $showempty=0, $showtype=0, $forcecombo=0, $events=array()) + function select_company($selected='', $htmlname='socid', $filter='', $showempty=0, $showtype=0, $forcecombo=0, $events=array(), $limit=0) { - return $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events); + return $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit); } /** @@ -752,7 +752,7 @@ class Form * @param int $limit Limit number of answers * @return string HTML string with */ - function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=20) + function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=0) { global $conf,$user,$langs; @@ -774,33 +774,33 @@ class Form $sql.=" AND ("; if (! empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) // Can use index { - $sql.="(s.name LIKE '".$filterkey."%'"; - $sql.=")"; + $sql.="(s.name LIKE '".$this->db->escape($filterkey)."%')"; } else { // For natural search $scrit = explode(' ', $filterkey); foreach ($scrit as $crit) { - $sql.=" AND (s.name LIKE '%".$crit."%'"; - $sql.=")"; + $sql.=" AND (s.name LIKE '%".$this->db->escape($crit)."%')"; } } if (! empty($conf->barcode->enabled)) { - $sql .= " OR s.barcode LIKE '".$filterkey."'"; + $sql .= " OR s.barcode LIKE '".$this->db->escape($filterkey)."%'"; } $sql.=")"; } - $sql.= " ORDER BY nom ASC"; - + $sql.=$this->db->order("nom","ASC"); + if ($limit > 0) $sql.=$this->db->plimit($limit); + dol_syslog(get_class($this)."::select_thirdparty_list sql=".$sql); $resql=$this->db->query($sql); if ($resql) { if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT && ! $forcecombo) { - $out.= ajax_combobox($htmlname, $events, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out.= ajax_combobox($htmlname, $events, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); } // Construct $out and $outarray diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4cb9f65f3b4..42c300ab56d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1162,7 +1162,7 @@ function dol_print_url($url,$target='_blank',$max=32) * @param string $email EMail to show (only email, without 'Name of recipient' before) * @param int $cid Id of contact if known * @param int $socid Id of third party if known - * @param int $addlink 0=no link to create action + * @param int $addlink 0=no link, 1=email has a html email link (+ link to create action if constant AGENDA_ADDACTIONFOREMAIL is on) * @param int $max Max number of characters to show * @param int $showinvalid Show warning if syntax email is wrong * @return string HTML Link diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 7838a3597d1..9316c2bcf68 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -342,12 +342,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Date start print ''; - print dol_print_date($lines[$i]->date_start,'day'); + print dol_print_date($lines[$i]->date_start,'dayhour'); print ''; // Date end print ''; - print dol_print_date($lines[$i]->date_end,'day'); + print dol_print_date($lines[$i]->date_end,'dayhour'); print ''; // Planned Workload (in working hours) @@ -500,12 +500,12 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr // Date start print ''; - print dol_print_date($lines[$i]->date_start,'day'); + print dol_print_date($lines[$i]->date_start,'dayhour'); print ''; // Date end print ''; - print dol_print_date($lines[$i]->date_end,'day'); + print dol_print_date($lines[$i]->date_end,'dayhour'); print ''; // Planned Workload diff --git a/htdocs/core/modules/modOpenSurvey.class.php b/htdocs/core/modules/modOpenSurvey.class.php index b8c38d1fb45..e780b235677 100644 --- a/htdocs/core/modules/modOpenSurvey.class.php +++ b/htdocs/core/modules/modOpenSurvey.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2014 Marcos García +/* Copyright (C) 2013-2014 Laurent Destailleur + * Copyright (C) 2014 Marcos García * * 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 @@ -76,7 +76,7 @@ class modOpenSurvey extends DolibarrModules $this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->phpmin = array(4,1); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(2,4); // Minimum version of Dolibarr required by module + $this->need_dolibarr_version = array(3,4,0); // Minimum version of Dolibarr required by module // Constants $this->const = array(); // List of parameters @@ -121,7 +121,7 @@ class modOpenSurvey extends DolibarrModules // Main menu entries $this->menus = array(); // List of menus to add $r=0; - + /* $this->menu[$r]=array( 'fk_menu'=>0, // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'top', 'titre'=>'Surveys', @@ -133,14 +133,14 @@ class modOpenSurvey extends DolibarrModules 'perms'=>'$user->rights->opensurvey->read', 'target'=>'', 'user'=>0); - $r++; + $r++;*/ - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', 'titre'=>'Survey', - 'mainmenu'=>'opensurvey', + 'mainmenu'=>'tools', 'leftmenu'=>'opensurvey', - 'url'=>'/opensurvey/index.php?mainmenu=opensurvey&leftmenu=opensurvey', + 'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey', 'langs'=>'opensurvey', 'position'=>200, 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. @@ -149,10 +149,10 @@ class modOpenSurvey extends DolibarrModules 'user'=>0); $r++; - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=opensurvey,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', 'titre'=>'NewSurvey', - 'mainmenu'=>'opensurvey', + 'mainmenu'=>'tools', 'leftmenu'=>'opensurvey_new', 'url'=>'/opensurvey/wizard/index.php', 'langs'=>'opensurvey', @@ -163,10 +163,10 @@ class modOpenSurvey extends DolibarrModules 'user'=>0); $r++; - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=opensurvey,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', 'titre'=>'List', - 'mainmenu'=>'opensurvey', + 'mainmenu'=>'tools', 'leftmenu'=>'opensurvey_list', 'url'=>'/opensurvey/list.php', 'langs'=>'opensurvey', diff --git a/htdocs/expedition/class/expeditionbatch.class.php b/htdocs/expedition/class/expeditionbatch.class.php index cf57929ca0f..e361548309d 100644 --- a/htdocs/expedition/class/expeditionbatch.class.php +++ b/htdocs/expedition/class/expeditionbatch.class.php @@ -17,7 +17,7 @@ */ /** - * \file expedtion/class/productbatch.class.php + * \file expedition/class/productbatch.class.php * \ingroup productbatch * \brief This file implements CRUD method for managing product's shipment * with batch record diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index bfc444faf56..7ed44102a4c 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -856,7 +856,7 @@ if ($action == 'create') if (($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) || $defaultqty < 0) $defaultqty=0; } - if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) { + if (empty($conf->productbatch->enabled) || ! ($product->hasbatch() and is_array($product->stock_warehouse[GETPOST('entrepot_id','int')] ))) { // Quantity to send print ''; if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) @@ -897,27 +897,27 @@ if ($action == 'create') print "\n"; // Show subproducts of product - if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) - { - $product->get_sousproduits_arbo(); - $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); - if(count($prods_arbo) > 0) - { - foreach($prods_arbo as $key => $value) - { - //print $value[0]; - $img=''; - if ($value['stock'] < $value['stock_alert']) - { - $img=img_warning($langs->trans("StockTooLow")); - } - print "      -> - ".$value['fullpath']." - (".$value['nb'].") ".$value['nb_total']."   - ".$value['stock']." ".$img.""; - } - } - } + if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) + { + $product->get_sousproduits_arbo(); + $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); + if(count($prods_arbo) > 0) + { + foreach($prods_arbo as $key => $value) + { + //print $value[0]; + $img=''; + if ($value['stock'] < $value['stock_alert']) + { + $img=img_warning($langs->trans("StockTooLow")); + } + print "      -> + ".$value['fullpath']." + (".$value['nb'].") ".$value['nb_total']."   + ".$value['stock']." ".$img.""; + } + } + } } else { print ''; $subj=0; diff --git a/htdocs/expedition/note.php b/htdocs/expedition/note.php index 0ef603a23f9..ad55c3bbe3e 100644 --- a/htdocs/expedition/note.php +++ b/htdocs/expedition/note.php @@ -24,10 +24,6 @@ * \brief Note card expedition */ -error_reporting(E_ALL); -ini_set('display_errors', true); -ini_set('html_errors', false); - require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php'; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 0deb13f8c15..d17ed94ef2a 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -28,10 +28,6 @@ * \brief Page for supplier invoice card (view, edit, validate) */ -error_reporting(E_ALL); -ini_set('display_errors', true); -ini_set('html_errors', false); - require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index 0e0023572d8..d6cd4090ddf 100644 --- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql +++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql @@ -1056,6 +1056,7 @@ CREATE TABLE llx_expeditiondet_batch ( ) ENGINE=InnoDB; --Salary payment in tax module +--DROP TABLE llx_payment_salary CREATE TABLE llx_payment_salary ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, @@ -1063,6 +1064,8 @@ CREATE TABLE llx_payment_salary ( datep date, datev date, amount real NOT NULL DEFAULT 0, + fk_typepayment integer NOT NULL, + num_payment varchar(50), label varchar(255), datesp date, -- date de début de la période dateep date, -- date de fin de la période @@ -1103,3 +1106,5 @@ ALTER TABLE llx_societe ADD INDEX idx_societe_barcode (barcode); ALTER TABLE llx_societe ADD UNIQUE INDEX uk_societe_barcode (barcode, fk_barcode_type, entity); +ALTER TABLE llx_tva ADD COLUMN fk_typepayment integer NULL; -- table may already contains data +ALTER TABLE llx_tva ADD COLUMN num_payment varchar(50); diff --git a/htdocs/install/mysql/tables/llx_payment_salary.sql b/htdocs/install/mysql/tables/llx_payment_salary.sql index 513eed2b943..b82ff66ecc1 100644 --- a/htdocs/install/mysql/tables/llx_payment_salary.sql +++ b/htdocs/install/mysql/tables/llx_payment_salary.sql @@ -24,6 +24,8 @@ create table llx_payment_salary datep date, -- date de paiement datev date, -- date de valeur amount real NOT NULL DEFAULT 0, + fk_typepayment integer NOT NULL, + num_payment varchar(50), label varchar(255), datesp date, -- date de début de la période dateep date, -- date de fin de la période diff --git a/htdocs/install/mysql/tables/llx_stock_mouvement.sql b/htdocs/install/mysql/tables/llx_stock_mouvement.sql index ed87b77def6..c3546ca3635 100644 --- a/htdocs/install/mysql/tables/llx_stock_mouvement.sql +++ b/htdocs/install/mysql/tables/llx_stock_mouvement.sql @@ -29,4 +29,6 @@ create table llx_stock_mouvement type_mouvement smallint, fk_user_author integer, label varchar(128) + fk_origin integer, + origintype varchar(32) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_tva.sql b/htdocs/install/mysql/tables/llx_tva.sql index 98d0ca6d575..c5b1542198c 100644 --- a/htdocs/install/mysql/tables/llx_tva.sql +++ b/htdocs/install/mysql/tables/llx_tva.sql @@ -24,6 +24,8 @@ create table llx_tva datep date, -- date de paiement datev date, -- date de valeur amount real NOT NULL DEFAULT 0, + fk_typepayment integer NULL, + num_payment varchar(50), label varchar(255), entity integer DEFAULT 1 NOT NULL, -- multi company id note text, diff --git a/htdocs/langs/fr_BE/main.lang b/htdocs/langs/fr_BE/main.lang index cc4d012cd2e..430736a6bca 100644 --- a/htdocs/langs/fr_BE/main.lang +++ b/htdocs/langs/fr_BE/main.lang @@ -1,6 +1,6 @@ # Dolibarr language file - fr_BE - main SeparatorDecimal=, -SeparatorThousand=None +SeparatorThousand= FormatDateShort=%d/%m/%Y FormatDateShortInput=%d/%m/%Y FormatDateShortJava=dd/MM/yyyy diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 3bf55fbe847..afbf0c2b92d 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -243,7 +243,7 @@ if (!$object->fk_user_creat) { { print ''; } - else print dol_print_email($object->mail_admin); + else print dol_print_email($object->mail_admin, 0, 0, 1); print ''; } @@ -382,6 +382,8 @@ if ($object->allow_comments) { print ''; +print '
'; + llxFooterSurvey(); $db->close(); diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 11826de4570..6df26f1a24f 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -745,7 +745,7 @@ else } } - print '
'; + print ''; print ''; print ''; print ''."\n"; @@ -784,8 +784,9 @@ else print $form->selectarray('statut_buy',$statutarray,GETPOST('statut_buy')); print ''; - // batch number management - if ($conf->productbatch->enabled) { + // Batch number management + if ($conf->productbatch->enabled) + { print ''.$langs->trans("Status").' ('.$langs->trans("Batch").')'; $statutarray=array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch")); print $form->selectarray('status_batch',$statutarray,GETPOST('status_batch')); @@ -891,14 +892,17 @@ else print ''; } - // Customs code - print ''.$langs->trans("CustomCode").''; - // Origin country - print ''.$langs->trans("CountryOrigin").''; - print $form->select_country(GETPOST('country_id','int'),'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); - print ''; - + // Custom code + if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) + { + print ''.$langs->trans("CustomCode").''; + // Origin country + print ''.$langs->trans("CountryOrigin").''; + print $form->select_country(GETPOST('country_id','int'),'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + print ''; + } + // Other attributes $parameters=array('colspan' => 3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -1156,14 +1160,17 @@ else print ''; } - // Customs code - print ''.$langs->trans("CustomCode").''; - // Origin country - print ''.$langs->trans("CountryOrigin").''; - print $form->select_country($object->country_id,'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); - print ''; - + // Custom code + if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) + { + print ''.$langs->trans("CustomCode").''; + // Origin country + print ''.$langs->trans("CountryOrigin").''; + print $form->select_country($object->country_id,'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + print ''; + } + // Other attributes $parameters=array('colspan' => ' colspan="2"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -1236,10 +1243,11 @@ else // Label print ''.$langs->trans("Label").''.$object->libelle.''; - $nblignes=8; + $nblignes=7; if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) $nblignes++; if ($showbarcode) $nblignes+=2; if ($object->type!=1) $nblignes++; + if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) $nblignes+=2; if ($object->isservice()) $nblignes++; else $nblignes+=4; @@ -1425,12 +1433,15 @@ else print "\n"; } - // Customs code - print ''.$langs->trans("CustomCode").''.$object->customcode.''; - - // Origin country code - print ''.$langs->trans("CountryOrigin").''.getCountry($object->country_id,0,$db).''; - + // Custom code + if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) + { + print ''.$langs->trans("CustomCode").''.$object->customcode.''; + + // Origin country code + print ''.$langs->trans("CountryOrigin").''.getCountry($object->country_id,0,$db).''; + } + // Other attributes $parameters=array('colspan' => ' colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index ee3f0b65639..9c6e9d80594 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -537,8 +537,8 @@ if ($resql) $productidselected=$key; $productlabelselected=$val; } - $datebefore=dol_get_first_day($year, $month?$month:1, true); - $dateafter=dol_get_last_day($year, $month?$month:12, true); + $datebefore=dol_get_first_day($year?$year:strftime("%Y",time()), $month?$month:1, true); + $dateafter=dol_get_last_day($year?$year:strftime("%Y",time()), $month?$month:12, true); $balancebefore=$movement->calculateBalanceForProductBefore($productidselected, $datebefore); $balanceafter=$movement->calculateBalanceForProductBefore($productidselected, $dateafter); diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index db473165d54..33520901f16 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -83,8 +83,8 @@ if ($action == 'createtask' && $user->rights->projet->creer) { $error=0; - $date_start = dol_mktime(0,0,0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear']); - $date_end = dol_mktime(0,0,0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear']); + $date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyeassskr'],'user'); + $date_end = dol_mktime($_POST['dateehour'],$_POST['dateemin'],0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear'],'user'); if (empty($_POST["cancel"])) { @@ -232,12 +232,12 @@ if ($id > 0 || ! empty($ref)) // Date start print ''.$langs->trans("DateStart").''; - print dol_print_date($object->date_start,'day'); + print dol_print_date($object->date_start,'dayhour'); print ''; // Date end print ''.$langs->trans("DateEnd").''; - print dol_print_date($object->date_end,'day'); + print dol_print_date($object->date_end,'dayhour'); print ''; // Other options @@ -302,12 +302,12 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie // Date start print ''.$langs->trans("DateStart").''; - print $form->select_date(($date_start?$date_start:''),'dateo',0,0,0,'',1,1); + print $form->select_date(($date_start?$date_start:''),'dateo',1,1,0,'',1,1); print ''; // Date end print ''.$langs->trans("DateEnd").''; - print $form->select_date(($date_end?$date_end:-1),'datee',0,0,0,'',1,1); + print $form->select_date(($date_end?$date_end:-1),'datee',1,1,0,'',1,1); print ''; // planned workload diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index bf2b20843a1..1dc4edf7ee8 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -23,10 +23,6 @@ * \brief Page of a project task */ -error_reporting(E_ALL); -ini_set('display_errors', true); -ini_set('html_errors', false); - require ("../../main.inc.php"); require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; @@ -87,8 +83,8 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) $object->description = $_POST['description']; $object->fk_task_parent = $task_parent; $object->planned_workload = $planned_workload; - $object->date_start = dol_mktime(0,0,0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear']); - $object->date_end = dol_mktime(0,0,0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear']); + $object->date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear'],'user'); + $object->date_end = dol_mktime($_POST['dateehour'],$_POST['dateemin'],0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear'],'user'); $object->progress = $_POST['progress']; // Fill array 'array_options' with data from add form @@ -326,12 +322,12 @@ if ($id > 0 || ! empty($ref)) // Date start print ''.$langs->trans("DateStart").''; - print $form->select_date($object->date_start,'dateo'); + print $form->select_date($object->date_start,'dateo',1,1); print ''; // Date end print ''.$langs->trans("DateEnd").''; - print $form->select_date($object->date_end?$object->date_end:-1,'datee'); + print $form->select_date($object->date_end?$object->date_end:-1,'datee',1,1); print ''; // Planned workload @@ -415,12 +411,12 @@ if ($id > 0 || ! empty($ref)) // Date start print ''.$langs->trans("DateStart").''; - print dol_print_date($object->date_start,'day'); + print dol_print_date($object->date_start,'dayhour'); print ''; // Date end print ''.$langs->trans("DateEnd").''; - print dol_print_date($object->date_end,'day'); + print dol_print_date($object->date_end,'dayhour'); print ''; // Planned workload