From 74e46b2de3c6b8dc021f1922ae509d5000b4b95b Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 23 Sep 2015 05:47:49 +0200 Subject: [PATCH 1/2] Salaries : Add label for accessibility --- htdocs/compta/salaries/card.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index f96531b059c..6509eb00d5e 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2011-2015 Alexandre Spangaro * Copyright (C) 2014 Laurent Destailleur * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Charlie BENKE @@ -232,45 +232,45 @@ if ($action == 'create') print ''; print ""; - print ''; - print ''; // Employee print ""; - print ''; // Label - print ''; + print ''; print ""; - print ''; - print ''; // Amount - print ''; + print ''; // Bank if (! empty($conf->banque->enabled)) { - print ''; } // Type payment - print '\n"; print ""; @@ -278,9 +278,10 @@ if ($action == 'create') if (! empty($conf->banque->enabled)) { // Number - print ''."\n"; + print ''; + print ''."\n"; } // Other attributes From 918c323f8f1e1622404ac3d2ecd7e0dee6b60d82 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 23 Sep 2015 06:37:14 +0200 Subject: [PATCH 2/2] Salaries : Add info card / add field datec / rename field user_creat to user_author --- htdocs/compta/salaries/card.php | 3 +- .../salaries/class/paymentsalary.class.php | 58 ++++++++++++++++--- htdocs/core/lib/salaries.lib.php | 2 - .../install/mysql/migration/3.8.0-3.9.0.sql | 3 + .../mysql/tables/llx_payment_salary.sql | 3 +- 5 files changed, 55 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 6509eb00d5e..6301a3025ec 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -83,7 +83,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $object->note=GETPOST("note"); $object->type_payment=GETPOST("paymenttype"); $object->num_payment=GETPOST("num_payment"); - $object->fk_user_creat=$user->id; + $object->fk_user_author=$user->id; // Set user current salary as ref salaray for the payment $fuser=new User($db); @@ -315,7 +315,6 @@ if ($id) dol_fiche_head($head, 'card', $langs->trans("SalaryPayment"), 0, 'payment'); - print '
'.$langs->trans("DatePayment").''; + print ''; print $form->select_date((empty($datep)?-1:$datep),"datep",'','','','add',1,1); print '
'.$langs->trans("DateValue").''; + print '
'; print $form->select_date((empty($datev)?-1:$datev),"datev",'','','','add',1,1); print '
'.$langs->trans("Employee").''; + print ''; print $form->select_dolusers(GETPOST('fk_user','int'),'fk_user',1); print '
'.$langs->trans("Label").'trans("SalaryPayment")).'">
trans("SalaryPayment")).'">
'.$langs->trans("DateStartPeriod").''; + print ''; print $form->select_date($datesp,"datesp",'','','','add'); print '
'.$langs->trans("DateEndPeriod").''; + print '
'; print $form->select_date($dateep,"dateep",'','','','add'); print '
'.$langs->trans("Amount").'
'.$langs->trans("Account").''; + print '
'; $form->select_comptes($_POST["accountid"],"accountid",0,'',1); // Affiche liste des comptes courant print '
'.$langs->trans("PaymentMode").''; + print '
'; $form->select_types_paiements(GETPOST("paymenttype"), "paymenttype"); print "
'.$langs->trans('Numero'); + print '
'; print ""; diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index cc0029620cb..c30e0749ca2 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2011-2015 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -49,7 +49,7 @@ class PaymentSalary extends CommonObject var $dateep; var $note; var $fk_bank; - var $fk_user_creat; + var $fk_user_author; var $fk_user_modif; @@ -85,7 +85,7 @@ class PaymentSalary extends CommonObject $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_author=trim($this->fk_user_author); $this->fk_user_modif=trim($this->fk_user_modif); // Check parameters @@ -112,7 +112,7 @@ class PaymentSalary extends CommonObject $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_author='".$this->fk_user_author."',"; $sql.= " fk_user_modif='".$this->fk_user_modif."'"; $sql.= " WHERE rowid=".$this->id; @@ -171,7 +171,7 @@ class PaymentSalary extends CommonObject $sql.= " s.dateep,"; $sql.= " s.note,"; $sql.= " s.fk_bank,"; - $sql.= " s.fk_user_creat,"; + $sql.= " s.fk_user_author,"; $sql.= " s.fk_user_modif,"; $sql.= " b.fk_account,"; $sql.= " b.fk_type,"; @@ -203,7 +203,7 @@ class PaymentSalary extends CommonObject $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_author = $obj->fk_user_author; $this->fk_user_modif = $obj->fk_user_modif; $this->fk_account = $obj->fk_account; $this->fk_type = $obj->fk_type; @@ -275,7 +275,7 @@ class PaymentSalary extends CommonObject $this->dateep=''; $this->note=''; $this->fk_bank=''; - $this->fk_user_creat=''; + $this->fk_user_author=''; $this->fk_user_modif=''; } @@ -290,13 +290,14 @@ class PaymentSalary extends CommonObject global $conf,$langs; $error=0; + $now=dol_now(); // Clean parameters $this->amount=price2num(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_author=trim($this->fk_user_author); $this->fk_user_modif=trim($this->fk_user_modif); // Check parameters @@ -340,7 +341,8 @@ class PaymentSalary extends CommonObject $sql.= ", label"; $sql.= ", datesp"; $sql.= ", dateep"; - $sql.= ", fk_user_creat"; + $sql.= ", fk_user_author"; + $sql.= ", datec"; $sql.= ", fk_bank"; $sql.= ", entity"; $sql.= ") "; @@ -357,6 +359,7 @@ class PaymentSalary extends CommonObject $sql.= ", '".$this->db->idate($this->datesp)."'"; $sql.= ", '".$this->db->idate($this->dateep)."'"; $sql.= ", '".$user->id."'"; + $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", NULL"; $sql.= ", ".$conf->entity; $sql.= ")"; @@ -511,4 +514,41 @@ class PaymentSalary extends CommonObject return $result; } + /** + * Information on record + * + * @param int $id Id of record + * @return void + */ + function info($id) + { + $sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_salary as ps'; + $sql.= ' WHERE ps.rowid = '.$id; + + dol_syslog(get_class($this).'::info', LOG_DEBUG); + $result = $this->db->query($sql); + + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + $this->date_creation = $this->db->jdate($obj->datec); + } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } + } diff --git a/htdocs/core/lib/salaries.lib.php b/htdocs/core/lib/salaries.lib.php index 7c104b4da82..6b25de4b656 100644 --- a/htdocs/core/lib/salaries.lib.php +++ b/htdocs/core/lib/salaries.lib.php @@ -51,12 +51,10 @@ function salaries_prepare_head($object) { $head[$h][2] = 'documents'; $h++; - /* $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; - */ complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries', 'remove'); diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index c2a1d7eb5ec..6375a9296dc 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -42,3 +42,6 @@ create table llx_overwrite_trans transvalue text )ENGINE=innodb; +ALTER TABLE llx_payment_salary ADD COLUMN datec datetime after tms; +ALTER TABLE llx_payment_salary CHANGE COLUMN fk_user_creat fk_user_author integer; + diff --git a/htdocs/install/mysql/tables/llx_payment_salary.sql b/htdocs/install/mysql/tables/llx_payment_salary.sql index bce4da9904a..38364c6812e 100644 --- a/htdocs/install/mysql/tables/llx_payment_salary.sql +++ b/htdocs/install/mysql/tables/llx_payment_salary.sql @@ -20,6 +20,7 @@ create table llx_payment_salary ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, + datec datetime, -- Create date fk_user integer NOT NULL, datep date, -- date de paiement datev date, -- date de valeur (this field should not be here, only into bank tables) @@ -33,6 +34,6 @@ create table llx_payment_salary entity integer DEFAULT 1 NOT NULL, -- multi company id note text, fk_bank integer, - fk_user_creat integer, -- utilisateur qui a cree l'info + fk_user_author integer, -- utilisateur qui a cree l'info fk_user_modif integer -- utilisateur qui a modifié l'info )ENGINE=innodb; \ No newline at end of file