From a23994055aafb2993102678a0a9b2dabd597d805 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 16 Jun 2015 05:45:00 +0200 Subject: [PATCH 01/14] Add field and table in database & migration script --- .../install/mysql/migration/3.7.0-3.8.0.sql | 16 +++++++++ .../tables/llx_payment_expensereport.sql | 33 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_payment_expensereport.sql diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 1b3633c9ae5..be91c24cb92 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -285,6 +285,22 @@ CREATE TABLE llx_expensereport_det ALTER TABLE llx_expensereport_det MODIFY COLUMN fk_projet integer NULL; ALTER TABLE llx_expensereport_det MODIFY COLUMN fk_c_tva integer NULL; +create table llx_payment_expensereport +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_expensereport integer, + datec datetime, -- date de creation + tms timestamp, + datep datetime, -- payment date + amount real DEFAULT 0, + fk_typepayment integer NOT NULL, + num_payment varchar(50), + note text, + fk_bank integer NOT NULL, + fk_user_creat integer, -- creation user + fk_user_modif integer -- last modification user +)ENGINE=innodb; + ALTER TABLE llx_projet ADD COLUMN budget_amount double(24,8); diff --git a/htdocs/install/mysql/tables/llx_payment_expensereport.sql b/htdocs/install/mysql/tables/llx_payment_expensereport.sql new file mode 100644 index 00000000000..55d10289348 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_payment_expensereport.sql @@ -0,0 +1,33 @@ +-- =================================================================== +-- Copyright (C) 2015 Alexandre Spangaro +-- +-- 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 . +-- +-- =================================================================== + +create table llx_payment_expensereport +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_expensereport integer, + datec datetime, -- date de creation + tms timestamp, + datep datetime, -- payment date + amount real DEFAULT 0, + fk_typepayment integer NOT NULL, + num_payment varchar(50), + note text, + fk_bank integer NOT NULL, + fk_user_creat integer, -- creation user + fk_user_modif integer -- last modification user +)ENGINE=innodb; From 2fb27b50eca1245fb1aa762098618bf3a69ee354 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 16 Jun 2015 05:45:47 +0200 Subject: [PATCH 02/14] Add payment page & class --- .../class/paymentexpensereport.class.php | 592 ++++++++++++++++++ htdocs/expensereport/payment/card.php | 303 +++++++++ htdocs/expensereport/payment/index.html | 0 htdocs/expensereport/payment/payment.php | 314 ++++++++++ 4 files changed, 1209 insertions(+) create mode 100644 htdocs/expensereport/class/paymentexpensereport.class.php create mode 100644 htdocs/expensereport/payment/card.php create mode 100644 htdocs/expensereport/payment/index.html create mode 100644 htdocs/expensereport/payment/payment.php diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php new file mode 100644 index 00000000000..c7e152466fe --- /dev/null +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -0,0 +1,592 @@ + + * + * 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/expensereport/class/paymentexpensereport.class.php + * \ingroup Expense Report + * \brief File of class to manage payment of expense report + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; + + +/** \class PaymentExpenseReport + * \brief Class to manage payments of expense report + */ +class PaymentExpenseReport extends CommonObject +{ + public $element='payment_expensereport'; //!< Id that identify managed objects + public $table_element='payment_expensereport'; //!< Name of table without prefix where object is stored + + var $id; + var $rowid; + var $ref; + + var $fk_expensereport; + var $datec=''; + var $tms=''; + var $datep=''; + var $amount; // Total amount of payment + var $amounts=array(); // Array of amounts + var $fk_typepayment; + var $num_payment; + 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; + } + + /** + * Create payment of expense report into database. + * Use this->amounts to have list of lines for the payment + * + * @param User $user User making payment + * @return int <0 if KO, id of payment if OK + */ + function create($user) + { + global $conf, $langs; + + $error=0; + + $now=dol_now(); + + // Validate parameters + if (! $this->datepaid) + { + $this->error='ErrorBadValueForParameterCreatePaymentExpenseReport'; + return -1; + } + + // Clean parameters + if (isset($this->fk_expensereport)) $this->fk_expensereport=trim($this->fk_expensereport); + if (isset($this->amount)) $this->amount=trim($this->amount); + if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); + if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); + if (isset($this->note)) $this->note=trim($this->note); + if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); + if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); + if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); + + $totalamount = 0; + foreach ($this->amounts as $key => $value) // How payment is dispatch + { + $newvalue = price2num($value,'MT'); + $this->amounts[$key] = $newvalue; + $totalamount += $newvalue; + } + $totalamount = price2num($totalamount); + + // Check parameters + if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null + + + $this->db->begin(); + + if ($totalamount != 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_expensereport (fk_expensereport, datec, datep, amount,"; + $sql.= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; + $sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',"; + $sql.= " '".$this->db->idate($this->datepaid)."',"; + $sql.= " ".$totalamount.","; + $sql.= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.","; + $sql.= " 0)"; + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_expensereport"); + } + else + { + $error++; + } + + } + + if ($totalamount != 0 && ! $error) + { + $this->amount=$totalamount; + $this->db->commit(); + return $this->id; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from database + * + * @param int $id Id object + * @return int <0 if KO, >0 if OK + */ + function fetch($id) + { + global $langs; + $sql = "SELECT"; + $sql.= " t.rowid,"; + $sql.= " t.fk_expensereport,"; + $sql.= " t.datec,"; + $sql.= " t.tms,"; + $sql.= " t.datep,"; + $sql.= " t.amount,"; + $sql.= " t.fk_typepayment,"; + $sql.= " t.num_payment,"; + $sql.= " t.note,"; + $sql.= " t.fk_bank,"; + $sql.= " t.fk_user_creat,"; + $sql.= " t.fk_user_modif,"; + $sql.= " pt.code as type_code, pt.libelle as type_libelle,"; + $sql.= ' b.fk_account'; + $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."payment_expensereport as t)"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; + $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id"; + + dol_syslog(get_class($this)."::fetch", 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->fk_expensereport = $obj->fk_expensereport; + $this->datec = $this->db->jdate($obj->datec); + $this->tms = $this->db->jdate($obj->tms); + $this->datep = $this->db->jdate($obj->datep); + $this->amount = $obj->amount; + $this->fk_typepayment = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; + $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->type_code = $obj->type_code; + $this->type_libelle = $obj->type_libelle; + + $this->bank_account = $obj->fk_account; + $this->bank_line = $obj->fk_bank; + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function update($user=null, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + + if (isset($this->fk_expensereport)) $this->fk_expensereport=trim($this->fk_expensereport); + if (isset($this->amount)) $this->amount=trim($this->amount); + if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); + if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); + if (isset($this->note)) $this->note=trim($this->note); + if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); + if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); + if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); + + + + // Check parameters + // Put here code to add control on parameters values + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_expensereport SET"; + + $sql.= " fk_expensereport=".(isset($this->fk_expensereport)?$this->fk_expensereport:"null").","; + $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; + $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; + $sql.= " amount=".(isset($this->amount)?$this->amount:"null").","; + $sql.= " fk_typepayment=".(isset($this->fk_typepayment)?$this->fk_typepayment:"null").","; + $sql.= " num_payment=".(isset($this->num_payment)?"'".$this->db->escape($this->num_payment)."'":"null").","; + $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").","; + $sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").","; + $sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").","; + $sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null").""; + + + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + $this->db->begin(); + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; + $sql.= " WHERE type='payment_expensereport' AND url_id=".$this->id; + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + } + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_expensereport"; + $sql.= " WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + + /** + * Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * @return int New id of clone + */ + function createFromClone($fromid) + { + global $user,$langs; + + $error=0; + + $object=new PaymentExpenseReport($this->db); + + $object->context['createfromclone'] = 'createfromclone'; + + $this->db->begin(); + + // Load source object + $object->fetch($fromid); + $object->id=0; + $object->statut=0; + + // Clear fields + // ... + + // Create clone + $result=$object->create($user); + + // Other options + if ($result < 0) + { + $this->error=$object->error; + $error++; + } + + if (! $error) + { + + + + } + + unset($this->context['createfromclone']); + + // End + if (! $error) + { + $this->db->commit(); + return $object->id; + } + else + { + $this->db->rollback(); + 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 + */ + function initAsSpecimen() + { + $this->id=0; + + $this->fk_expensereport=''; + $this->datec=''; + $this->tms=''; + $this->datep=''; + $this->amount=''; + $this->fk_typepayment=''; + $this->num_payment=''; + $this->note=''; + $this->fk_bank=''; + $this->fk_user_creat=''; + $this->fk_user_modif=''; + + + } + + + /** + * Add record into bank for payment with links between this bank record and invoices of payment. + * All payment properties must have been set first like after a call to create(). + * + * @param User $user Object of user making payment + * @param string $mode 'payment_expensereport' + * @param string $label Label to use in bank record + * @param int $accountid Id of bank account to do link with + * @param string $emetteur_nom Name of transmitter + * @param string $emetteur_banque Name of bank + * @return int <0 if KO, >0 if OK + */ + function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque) + { + global $conf; + + $error=0; + + if (! empty($conf->banque->enabled)) + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + + $acc = new Account($this->db); + $acc->fetch($accountid); + + $total=$this->total; + if ($mode == 'payment_expensereport') $amount=$total; + + // Insert payment into llx_bank + $bank_line_id = $acc->addline( + $this->datepaid, + $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") + $label, + $amount, + $this->num_payment, + '', + $user, + $emetteur_nom, + $emetteur_banque + ); + + // Update fk_bank in llx_paiement. + // On connait ainsi le paiement qui a genere l'ecriture bancaire + if ($bank_line_id > 0) + { + $result=$this->update_fk_bank($bank_line_id); + if ($result <= 0) + { + $error++; + dol_print_error($this->db); + } + + // Add link 'payment', 'payment_supplier', 'payment_expensereport' in bank_url between payment and bank transaction + $url=''; + if ($mode == 'payment_expensereport') $url=DOL_URL_ROOT.'/expensereport/payment/card.php?rowid='; + if ($url) + { + $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); + if ($result <= 0) + { + $error++; + dol_print_error($this->db); + } + } + } + else + { + $this->error=$acc->error; + $error++; + } + } + + if (! $error) + { + return 1; + } + else + { + return -1; + } + } + + + /** + * Update link between the expense report payment and the generated line in llx_bank + * + * @param int $id_bank Id if bank + * @return int >0 if OK, <=0 if KO + */ + function update_fk_bank($id_bank) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_expensereport SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + return 1; + } + else + { + $this->error=$this->db->error(); + return 0; + } + } + + /** + * Return clicable name (with picto eventually) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen Longueur max libelle + * @return string Chaine avec URL + */ + function getNomUrl($withpicto=0,$maxlen=0) + { + global $langs; + + $result=''; + + if (empty($this->ref)) $this->ref=$this->lib; + $label = $langs->trans("ShowPayment").': '.$this->ref; + + if (!empty($this->id)) + { + $link = ''; + $linkend=''; + + if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); + if ($withpicto && $withpicto != 2) $result.=' '; + if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend; + } + + return $result; + } +} diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php new file mode 100644 index 00000000000..8d4ce687cfc --- /dev/null +++ b/htdocs/expensereport/payment/card.php @@ -0,0 +1,303 @@ + + * + * 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/expensereport/payment/card.php + * \ingroup Expense Report + * \brief Tab payment of an expense report + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; +if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + +$langs->load('bills'); +$langs->load('banks'); +$langs->load('companies'); + +// Security check +$id=GETPOST('rowid')?GETPOST('rowid','int'):GETPOST('id','int'); +$action=GETPOST("action"); +$confirm=GETPOST('confirm'); +if ($user->societe_id) $socid=$user->societe_id; +// TODO Add rule to restrict access payment +//$result = restrictedArea($user, 'facture', $id,''); + +$payment = new PaymentExpenseReport($db); +if ($id > 0) +{ + $result=$payment->fetch($id); + if (! $result) dol_print_error($db,'Failed to get payment id '.$id); +} + + +/* + * Actions + */ + +// Delete payment +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expensereport->supprimer) +{ + $db->begin(); + + $result = $payment->delete($user); + if ($result > 0) + { + $db->commit(); + header("Location: ".DOL_URL_ROOT."/expensereport/index.php"); + exit; + } + else + { + setEventMessage($payment->error, 'errors'); + $db->rollback(); + } +} + +// Create payment +if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->expensereport->creer) +{ + $db->begin(); + + $result=$payment->valide(); + + if ($result > 0) + { + $db->commit(); + + $factures=array(); // TODO Get all id of invoices linked to this payment + foreach($factures as $id) + { + $fac = new Facture($db); + $fac->fetch($id); + + $outputlangs = $langs; + if (! empty($_REQUEST['lang_id'])) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $fac->generateDocument($fac->modelpdf, $outputlangs); + } + } + + header('Location: card.php?id='.$payment->id); + exit; + } + else + { + setEventMessage($payment->error); + $db->rollback(); + } +} + + +/* + * View + */ + +llxHeader(); + +$expensereport = new ExpenseReport($db); +$form = new Form($db); + +$h=0; + +$head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$id; +$head[$h][1] = $langs->trans("Card"); +$hselected = $h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ExpenseReportPayment"), 0, 'payment'); + +/* + * Confirm deleting of the payment + */ +if ($action == 'delete') +{ + print $form->formconfirm('card.php?id='.$payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2); + +} + +/* + * Confirm validation of the payment + */ +if ($action == 'valide') +{ + $facid = $_GET['facid']; + print $form->formconfirm('card.php?id='.$payment->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2); + +} + + +print ''; + +// Ref +print ''; +print ''; + +// Date +print ''; + +// Mode +print ''; + +// Number +print ''; + +// Amount +print ''; + +// Note +print ''; + +// Bank account +if (! empty($conf->banque->enabled)) +{ + if ($payment->bank_account) + { + $bankline=new AccountLine($db); + $bankline->fetch($payment->bank_line); + + print ''; + print ''; + print ''; + print ''; + } +} + +print '
'.$langs->trans('Ref').''; +print $form->showrefnav($payment,'id','',1,'rowid','id'); +print '
'.$langs->trans('Date').''.dol_print_date($payment->datep,'day').'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$payment->type_code).'
'.$langs->trans('Number').''.$payment->num_payment.'
'.$langs->trans('Amount').''.price($payment->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($payment->note).'
'.$langs->trans('BankTransactionLine').''; + print $bankline->getNomUrl(1,0,'showall'); + print '
'; + + +/* + * List of donations paid + */ + +$disable_delete = 0; +$sql = 'SELECT er.rowid as did, er.paid, er.amount as er_amount, per.amount'; +$sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as per,'.MAIN_DB_PREFIX.'expensereport as er'; +$sql.= ' WHERE per.fk_expensereport = er.rowid'; +$sql.= ' AND er.entity = '.$conf->entity; +$sql.= ' AND per.rowid = '.$id; + +dol_syslog("expensereport/payment/card.php", LOG_DEBUG); +$resql=$db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + + $i = 0; + $total = 0; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + if ($num > 0) + { + $var=True; + + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + $var=!$var; + print ''; + // Ref + print '\n"; + // Expected to pay + print ''; + // Status + print ''; + // Amount paid + print ''; + print "\n"; + if ($objp->paid == 1) // If at least one invoice is paid, disable delete + { + $disable_delete = 1; + } + $total = $total + $objp->amount; + $i++; + } + } + $var=!$var; + + print "
'.$langs->trans('ExpenseReport').''.$langs->trans('ExpectedToPay').''.$langs->trans('Status').''.$langs->trans('PayedByThisPayment').'
'; + $expensereport->fetch($objp->did); + print $expensereport->getNomUrl(1); + print "'.price($objp->d_amount).''.$expensereport->getLibStatut(4,$objp->amount).''.price($objp->amount).'
\n"; + $db->free($resql); +} +else +{ + dol_print_error($db); +} + +print ''; + + +/* + * Actions buttons + */ +print '
'; + +/* +if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) +{ + if ($user->societe_id == 0 && $payment->statut == 0 && $_GET['action'] == '') + { + if ($user->rights->facture->paiement) + { + print ''.$langs->trans('Valid').''; + } + } +} +*/ + +if ($_GET['action'] == '') +{ + if ($user->rights->expensereport->supprimer) + { + if (! $disable_delete) + { + print ''.$langs->trans('Delete').''; + } + else + { + print ''.$langs->trans('Delete').''; + } + } +} + +print '
'; + + + +llxFooter(); + +$db->close(); diff --git a/htdocs/expensereport/payment/index.html b/htdocs/expensereport/payment/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php new file mode 100644 index 00000000000..e8c2ef8a26e --- /dev/null +++ b/htdocs/expensereport/payment/payment.php @@ -0,0 +1,314 @@ + + * + * 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/expensereport/payment/payment.php + * \ingroup Expense Report + * \brief Page to add payment of an expense report + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + +$langs->load("bills"); + +$chid=GETPOST("rowid"); +$action=GETPOST('action'); +$amounts = array(); + +// Security check +$socid=0; +if ($user->societe_id > 0) +{ + $socid = $user->societe_id; +} + + +/* + * Actions + */ + +if ($action == 'add_payment') +{ + $error=0; + + if ($_POST["cancel"]) + { + $loc = DOL_URL_ROOT.'/expensereport/card.php?rowid='.$chid; + header("Location: ".$loc); + exit; + } + + $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + + if (! $_POST["paymenttype"] > 0) + { + $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); + $error++; + } + if ($datepaid == '') + { + $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date")); + $error++; + } + if (! empty($conf->banque->enabled) && ! $_POST["accountid"] > 0) + { + $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToCredit")); + $error++; + } + + if (! $error) + { + $paymentid = 0; + + // Read possible payments + foreach ($_POST as $key => $value) + { + if (substr($key,0,7) == 'amount_') + { + $other_chid = substr($key,7); + $amounts[$other_chid] = price2num($_POST[$key]); + } + } + + if (count($amounts) <= 0) + { + $error++; + $errmsg='ErrorNoPaymentDefined'; + } + + if (! $error) + { + $db->begin(); + + // Create a line of payments + $payment = new PaymentExpenseReport($db); + $payment->chid = $chid; + $payment->datepaid = $datepaid; + $payment->amounts = $amounts; // Tableau de montant + $payment->paymenttype = $_POST["paymenttype"]; + $payment->num_payment = $_POST["num_payment"]; + $payment->note = $_POST["note"]; + + if (! $error) + { + $paymentid = $payment->create($user); + if ($paymentid < 0) + { + $errmsg=$payment->error; + $error++; + } + } + + if (! $error) + { + $result=$payment->addPaymentToBank($user,'payment_expensereport','(ExpenseReportPayment)',$_POST['accountid'],'',''); + if (! $result > 0) + { + $errmsg=$payment->error; + $error++; + } + } + + if (! $error) + { + $db->commit(); + $loc = DOL_URL_ROOT.'/expensereport/card.php?rowid='.$chid; + header('Location: '.$loc); + exit; + } + else + { + $db->rollback(); + } + } + } + + $_GET["action"]='create'; +} + + +/* + * View + */ + +llxHeader(); + +$form=new Form($db); + + +// Form to create expense report payment +if (GETPOST("action") == 'create') +{ + + $expensereport = new ExpenseReport($db); + $expensereport->fetch($chid); + + $total = $expensereport->amount; + + print_fiche_titre($langs->trans("DoPayment")); + + if ($mesg) + { + print "
$mesg
"; + } + + print '
'; + print ''; + print ''; + print ''; + print ''; + + dol_fiche_head(); + + print ''; + + print ''; + + print ''; + print '\n"; + print ''; + + $sql = "SELECT sum(p.amount) as total"; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p"; + $sql.= " WHERE p.fk_expensereport = ".$chid; + $resql = $db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + $sumpaid = $obj->total; + $db->free(); + } + print ''; + print ''; + + print ''; + print "'; + print ''; + + print '"; + print ''; + + print '\n"; + print ''; + + print ''; + print ''; + print ''; + + // Number + print ''; + print ''."\n"; + + print ''; + print ''; + print ''; + print ''; + + print '
'.$langs->trans("ExpenseReport").'
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("Date")."".dol_print_date($expensereport->date,'day')."
'.$langs->trans("Amount")."".price($expensereport->amount,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
".$langs->trans("Payment").'
'.$langs->trans("Date").''; + $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaid):0; + $form->select_date($datepayment,'','','','',"add_payment",1,1); + print "
'.$langs->trans("PaymentMode").''; + $form->select_types_paiements(isset($_POST["paymenttype"])?$_POST["paymenttype"]:$expensereport->paymenttype, "paymenttype"); + print "
'.$langs->trans('AccountToCredit').''; + $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$expensereport->accountid, "accountid", 0, '',1); // Show open bank account list + print '
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'.$langs->trans("Comments").'
'; + + dol_fiche_end(); + + /* + * Autres charges impayees + */ + $num = 1; + $i = 0; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $var=true; + $total=0; + $totalrecu=0; + + while ($i < $num) + { + $objp = $expensereport; + + $var=!$var; + + print ""; + + print '"; + + print '"; + + print '"; + + print '"; + + print "\n"; + $total+=$objp->total; + $total_ttc+=$objp->total_ttc; + $totalrecu+=$objp->am; + $i++; + } + if ($i > 1) + { + // Print total + print ""; + print ''; + print ""; + print ""; + print ""; + print ''; + print "\n"; + } + + print "
'.$langs->trans("Amount").''.$langs->trans("AlreadyPaid").''.$langs->trans("RemainderToPay").''.$langs->trans("Amount").'
'.price($objp->amount)."'.price($sumpaid)."'.price($objp->amount - $sumpaid)."'; + if ($sumpaid < $objp->amount) + { + $namef = "amount_".$objp->id; + print ''; + } + else + { + print '-'; + } + print "
'.$langs->trans("Total").':".price($total_ttc)."".price($totalrecu)."".price($total_ttc - $totalrecu)." 
"; + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print "
\n"; +} + + +$db->close(); + +llxFooter(); From d92eab49de534ff85eb111a6e861770b3f519714 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 16 Jun 2015 05:46:53 +0200 Subject: [PATCH 03/14] Add the payment in bank module --- htdocs/compta/bank/account.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 7dffc753bc4..f2a7649166a 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -39,6 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -50,6 +51,7 @@ $langs->load("companies"); $langs->load("salaries"); $langs->load("loan"); $langs->load("donations"); +$langs->load("trips"); $id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int')); $ref = GETPOST('ref','alpha'); @@ -188,6 +190,7 @@ $paymentsupplierstatic=new PaiementFourn($db); $paymentvatstatic=new TVA($db); $paymentsalstatic=new PaymentSalary($db); $donstatic=new Don($db); +$expensereportstatic=new ExpenseReport($db); $bankstatic=new Account($db); $banklinestatic=new AccountLine($db); @@ -732,6 +735,12 @@ if ($id > 0 || ! empty($ref)) print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; print ''; } + elseif ($links[$key]['type']=='payment_expensereport') + { + print ''; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + print ''; + } elseif ($links[$key]['type']=='banktransfert') { // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. From 2979815223f31422af5cf946c1d782e65f41358b Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 16 Jun 2015 06:56:58 +0200 Subject: [PATCH 04/14] Update work on expensereport card --- htdocs/expensereport/card.php | 109 ++++++++++++++++++++++++++++------ 1 file changed, 92 insertions(+), 17 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 0b688790af7..6dc25efef4f 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -36,9 +36,11 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/modules/expensereport/modules_expensereport.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; $langs->load("trips"); +$langs->load("bills"); $action=GETPOST('action'); $cancel=GETPOST('cancel'); @@ -1391,13 +1393,13 @@ else $linkback = ''.$langs->trans("BackToList").''; // Ref - print ''.$langs->trans("Ref").''; + print ''.$langs->trans("Ref").''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); print ''; print ''; print ''.$langs->trans("Period").''; - print ''; + print ''; print get_date_range($object->date_debut,$object->date_fin,'',$langs,0); print ''; print ''; @@ -1405,25 +1407,90 @@ else { print ''; print ''.$langs->trans("ModePaiement").''; - print ''.$object->libelle_paiement.''; + print ''.$object->libelle_paiement.''; print ''; } // Status print ''; print ''.$langs->trans("Statut").''; - print ''.$object->getLibStatut(4).''; + print ''.$object->getLibStatut(4).''; print ''; print ''; print ''.$langs->trans("NotePublic").''; - print ''.$object->note_public.''; + print ''.$object->note_public.''; print ''; print ''; print ''.$langs->trans("NotePrivate").''; - print ''.$object->note_private.''; + print ''.$object->note_private.''; print ''; print ''; print ''.$langs->trans("AmountHT").''; print ''.price($object->total_ht).''; + print ''; + /* + * Payments + */ + $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,"; + $sql.= "c.code as type_code,c.libelle as paiement_type"; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p"; + $sql.= ", ".MAIN_DB_PREFIX."c_paiement as c "; + $sql.= ", ".MAIN_DB_PREFIX."expensereport as e"; + $sql.= " WHERE e.rowid = '".$id."'"; + $sql.= " AND p.fk_expensereport = e.rowid"; + $sql.= " AND e.entity = ".$conf->entity; + $sql.= " AND p.fk_typepayment = c.id"; + $sql.= " ORDER BY dp"; + + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; $total = 0; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print "'; + print '\n"; + $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->paiement_type; + print "\n"; + print '\n"; + print ""; + $totalpaid += $objp->total_ttc; + $i++; + } + + if ($object->paid == 0) + { + print "\n"; + print "\n"; + + $remaintopay = $object->total_ttc - $totalpaid; + + print ""; + print "\n"; + } + print "
'.$langs->trans("RefPayment").''.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("Amount").' 
"; + print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."".$labeltype.' '.$object->num_payment."'.price($objp->total_ttc)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AlreadyPaid")." :".price($totalpaid)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AmountExpected")." :".price($object->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("RemainderToPay")." :".price($remaintopay)." ".$langs->trans("Currency".$conf->currency)."
"; + $db->free($resql); + } + else + { + dol_print_error($db); + } + print ""; + print ''; print ''; print ''.$langs->trans("AmountVAT").''; @@ -1643,7 +1710,7 @@ else { //modif ligne!!!!! print ''; - // Sélection date + // Select date print ''; $form->select_date($objp->date,'date'); print ''; @@ -1872,9 +1939,9 @@ if ($action != 'create' && $action != 'edit') /* Si l'état est "En attente d'approbation" * ET user à droit de "approve" - * ET fk_user_validator == user courant - * Afficher : "Valider" / "Refuser" / "Supprimer" - */ + * ET fk_user_validator == user courant + * Afficher : "Valider" / "Refuser" / "Supprimer" + */ if ($object->fk_statut == 2) { if ($object->fk_user_author == $user->id) @@ -1906,14 +1973,22 @@ if ($action != 'create' && $action != 'edit') print 'id.'">'.$langs->trans('Delete').''; } } - + /* Si l'état est "A payer" * ET user à droit de "to_paid" - * Afficher : "Annuler" / "Payer" / "Supprimer" - */ - if ($user->rights->expensereport->to_paid && $object->fk_statut == 5) + * Afficher : "Annuler" / "Payer" / "Supprimer" + */ + if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && round($remaintopay) == 0 && $object->paid == 0 && $object->fk_statut == 5) { // Pay + if ($remaintopay == 0) + { + print '
' . $langs->trans('DoPayment') . '
'; + } + else + { + print ''; + } print 'id.'">'.$langs->trans('TO_PAID').''; // Cancel @@ -1931,9 +2006,9 @@ if ($action != 'create' && $action != 'edit') /* Si l'état est "Payée" * ET user à droit "approve" - * ET user à droit "to_paid" - * Afficher : "Annuler" - */ + * ET user à droit "to_paid" + * Afficher : "Annuler" + */ if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && $object->fk_statut==6) { // Cancel From 1e0526288463b864caaa9c1f54be7a3a3bd311b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 26 May 2015 12:01:28 +0200 Subject: [PATCH 05/14] Corrected Timezone detection by using jstz external library --- COPYRIGHT | 1 + htdocs/core/js/dst.js | 12 ++++++------ htdocs/core/tpl/login.tpl.php | 6 +++++- htdocs/includes/jstz/jstz.min.js | 2 ++ 4 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 htdocs/includes/jstz/jstz.min.js diff --git a/COPYRIGHT b/COPYRIGHT index 73d5a03572e..b7778986e35 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -47,6 +47,7 @@ jQuery TableDnD 0.6 GPL and MIT License Yes jQuery Timepicker 1.1.0 GPL and MIT License Yes JS library Timepicker addon for Datepicker jQuery Tiptip 1.3 GPL and MIT License Yes JS library for tooltips jsGantt 1.2 BSD License Yes JS library (to build Gantt reports) +JsTimezoneDetect 1.0.4 MIT Licence Yes JS library to detect user timezone For licenses compatibility informations: http://www.fsf.org/licensing/licenses/index_html diff --git a/htdocs/core/js/dst.js b/htdocs/core/js/dst.js index c22f83aec21..486e7027b43 100644 --- a/htdocs/core/js/dst.js +++ b/htdocs/core/js/dst.js @@ -1,5 +1,6 @@ // Copyright (C) 2011-2014 Laurent Destailleur // Copyright (C) 2011-2012 Regis Houssin +// Copyright (C) 2015 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 @@ -23,7 +24,10 @@ // $(document).ready(function () { - // Detect and save TZ and DST + + var timezone = jstz.determine(); + + // Detect and save TZ and DST var rightNow = new Date(); var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); var temp = jan1.toGMTString(); @@ -40,16 +44,12 @@ $(document).ready(function () { dst = "1"; // daylight savings time is observed } var now=new Date(); - var tz=now.toTimeString().match(/\(.*\)/); // now.toTimeString may return "12:39:59 GMT+0200 (CEST)" //alert('date=' + now + ' string=' + now.toTimeString()); var dst_first=DisplayDstSwitchDates('first'); var dst_second=DisplayDstSwitchDates('second'); //alert(dst); $('#tz').val(std_time_offset); // returns TZ - // tz is null with IE - if (tz != null) { - $('#tz_string').val(tz[0].replace('(','').replace(')','')); // returns TZ string - } + $('#tz_string').val(timezone.name()); // returns TZ string $('#dst_observed').val(dst); // returns if DST is observed on summer $('#dst_first').val(dst_first); // returns DST first switch in year $('#dst_second').val(dst_second); // returns DST second switch in year diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 3eb9f907d8a..f130ac9f7ef 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -28,7 +28,11 @@ if (GETPOST('dol_use_jmobile')) $conf->dol_use_jmobile=1; // If we force to use jmobile, then we reenable javascript if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1; -$arrayofjs=array('/core/js/dst.js'.(empty($conf->dol_use_jmobile)?'':'?version='.urlencode(DOL_VERSION))); // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second +// Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second +$arrayofjs=array( + '/includes/jstz/jstz.min.js'.(empty($conf->dol_use_jmobile)?'':'?version='.urlencode(DOL_VERSION)), + '/core/js/dst.js'.(empty($conf->dol_use_jmobile)?'':'?version='.urlencode(DOL_VERSION)) +); $titleofloginpage=$langs->trans('Login').' @ '.$title; // title is defined by dol_loginfunction in security2.lib.php. We must keep the @, some tools use it to know it is login page. print top_htmlhead('',$titleofloginpage,0,0,$arrayofjs); diff --git a/htdocs/includes/jstz/jstz.min.js b/htdocs/includes/jstz/jstz.min.js new file mode 100644 index 00000000000..96e3dd8ae72 --- /dev/null +++ b/htdocs/includes/jstz/jstz.min.js @@ -0,0 +1,2 @@ +/*! jstz - v1.0.4 - 2012-12-12 */ +(function(e){var t=function(){"use strict";var e="s",n=function(e){var t=-e.getTimezoneOffset();return t!==null?t:0},r=function(e,t,n){var r=new Date;return e!==undefined&&r.setFullYear(e),r.setDate(n),r.setMonth(t),r},i=function(e){return n(r(e,0,2))},s=function(e){return n(r(e,5,2))},o=function(e){var t=e.getMonth()>7?s(e.getFullYear()):i(e.getFullYear()),r=n(e);return t-r!==0},u=function(){var t=i(),n=s(),r=i()-s();return r<0?t+",1":r>0?n+",1,"+e:t+",0"},a=function(){var e=u();return new t.TimeZone(t.olson.timezones[e])};return{determine:a,date_is_dst:o}}();t.TimeZone=function(e){"use strict";var n=null,r=function(){return n},i=function(){var e=t.olson.ambiguity_list[n],r=e.length,i=0,s=e[0];for(;i Date: Tue, 16 Jun 2015 21:20:42 +0200 Subject: [PATCH 06/14] Updated changelog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 7a3da54652c..fca13478c08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,7 @@ For users: - [ task #1793 ] Create new permission to restrict commercial agent margin to logged user. - Add experimental module ask supplier price to request supplier quotation. - Add experimental module batch management. +- Fix: Corrected user timezone detection For translators: - Update language files. From 8d0e7261f5b5821170178b01b2dc8356289a4204 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 17 Jun 2015 07:19:25 +0200 Subject: [PATCH 07/14] Debug --- htdocs/expensereport/card.php | 24 +++++++++---------- .../class/expensereport.class.php | 17 ++++++++----- .../class/paymentexpensereport.class.php | 6 ++--- htdocs/expensereport/payment/card.php | 4 ++-- htdocs/expensereport/payment/payment.php | 24 +++++++++---------- .../install/mysql/migration/3.7.0-3.8.0.sql | 1 + .../mysql/tables/llx_expensereport.sql | 1 + 7 files changed, 41 insertions(+), 36 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 6dc25efef4f..8766aca3412 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1388,7 +1388,7 @@ else if ($ret == 'html') print '
'; } - print ''; + print '
'; $linkback = ''.$langs->trans("BackToList").''; @@ -1431,7 +1431,7 @@ else * Payments */ $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,"; - $sql.= "c.code as type_code,c.libelle as paiement_type"; + $sql.= "c.code as type_code,c.libelle as payment_type"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p"; $sql.= ", ".MAIN_DB_PREFIX."c_paiement as c "; $sql.= ", ".MAIN_DB_PREFIX."expensereport as e"; @@ -1464,18 +1464,18 @@ else print "'; print '\n"; - $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->paiement_type; - print "\n"; - print '\n"; + $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->payment_type; + print "\n"; + print '\n"; print ""; - $totalpaid += $objp->total_ttc; + $totalpaid += $objp->amount; $i++; } if ($object->paid == 0) { print "\n"; - print "\n"; + print "\n"; $remaintopay = $object->total_ttc - $totalpaid; @@ -1863,8 +1863,6 @@ else } - - /* * Barre d'actions */ @@ -1978,7 +1976,7 @@ if ($action != 'create' && $action != 'edit') * ET user à droit de "to_paid" * Afficher : "Annuler" / "Payer" / "Supprimer" */ - if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && round($remaintopay) == 0 && $object->paid == 0 && $object->fk_statut == 5) + if ($user->rights->expensereport->to_paid && $object->fk_statut == 5) { // Pay if ($remaintopay == 0) @@ -1987,7 +1985,7 @@ if ($action != 'create' && $action != 'edit') } else { - print ''; + print ''; } print 'id.'">'.$langs->trans('TO_PAID').''; @@ -1996,10 +1994,10 @@ if ($action != 'create' && $action != 'edit') { print 'id.'">'.$langs->trans('Cancel').''; } - + + // Delete if($user->rights->expensereport->supprimer) { - // Delete print 'id.'">'.$langs->trans('Delete').''; } } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 98a6aea00e7..7dede6d11a9 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -50,12 +50,13 @@ class ExpenseReport extends CommonObject var $status; var $fk_statut; // -- 1=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied var $fk_c_paiement; + var $paid; var $user_author_infos; var $user_validator_infos; - var $libelle_paiement; - var $libelle_statut; + var $modepayment; + var $modepaymentid; var $code_paiement; var $code_statut; @@ -107,6 +108,7 @@ class ExpenseReport extends CommonObject $this->total_ht = 0; $this->total_ttc = 0; $this->total_tva = 0; + $this->modepaymentid = 0; // List of language codes for status $this->statuts_short = array(0 => 'Draft', 2 => 'Validated', 4 => 'Canceled', 5 => 'Approved', 6 => 'Paid', 99 => 'Refused'); @@ -142,6 +144,7 @@ class ExpenseReport extends CommonObject $sql.= ",fk_user_validator"; $sql.= ",fk_statut"; $sql.= ",fk_c_paiement"; + $sql.= ",paid"; $sql.= ",note_public"; $sql.= ",note_private"; $sql.= ") VALUES("; @@ -155,7 +158,8 @@ class ExpenseReport extends CommonObject $sql.= ", ".($user->id > 0 ? $user->id:"null"); $sql.= ", ".($this->fk_user_validator > 0 ? $this->fk_user_validator:"null"); $sql.= ", ".($this->fk_statut > 1 ? $this->fk_statut:0); - $sql.= ", ".($this->fk_c_paiement > 0 ? $this->fk_c_paiement:"null"); + $sql.= ", ".($this->modepaymentid?$this->modepaymentid:"null"); + $sql.= ", 0"; $sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ")"; @@ -325,9 +329,10 @@ class ExpenseReport extends CommonObject if ($this->fk_user_validator > 0) $user_approver->fetch($this->fk_user_validator); $this->user_validator_infos = dolGetFirstLastname($user_approver->firstname, $user_approver->lastname); - $this->fk_statut = $obj->status; - $this->status = $obj->status; - $this->fk_c_paiement = $obj->fk_c_paiement; + $this->fk_statut = $obj->status; + $this->status = $obj->status; + $this->fk_c_paiement = $obj->fk_c_paiement; + $this->paid = $obj->paid; if ($this->fk_statut==5 || $this->fk_statut==6) { diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index c7e152466fe..51a196057cf 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -42,7 +42,7 @@ class PaymentExpenseReport extends CommonObject var $datep=''; var $amount; // Total amount of payment var $amounts=array(); // Array of amounts - var $fk_typepayment; + var $paymenttype; var $num_payment; var $note; var $fk_bank; @@ -84,7 +84,7 @@ class PaymentExpenseReport extends CommonObject // Clean parameters if (isset($this->fk_expensereport)) $this->fk_expensereport=trim($this->fk_expensereport); if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); + if (isset($this->fk_typepayment)) $this->paymenttype=trim($this->paymenttype); if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); if (isset($this->note)) $this->note=trim($this->note); if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); @@ -109,7 +109,7 @@ class PaymentExpenseReport extends CommonObject if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_expensereport (fk_expensereport, datec, datep, amount,"; - $sql.= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; + $sql.= " fk_c_typepayment, num_payment, note, fk_user_creat, fk_bank)"; $sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',"; $sql.= " '".$this->db->idate($this->datepaid)."',"; $sql.= " ".$totalamount.","; diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index 8d4ce687cfc..5b62b138356 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -196,7 +196,7 @@ print '
"; print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."".$labeltype.' '.$object->num_payment."'.price($objp->total_ttc)." ".$langs->trans("Currency".$conf->currency)."".$labeltype.' '.$object->num_payment."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AlreadyPaid")." :".price($totalpaid)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AmountExpected")." :".price($object->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AmountExpected")." :".price($object->total_ttc)." ".$langs->trans("Currency".$conf->currency)."
'; */ $disable_delete = 0; -$sql = 'SELECT er.rowid as did, er.paid, er.amount as er_amount, per.amount'; +$sql = 'SELECT er.rowid as did, er.paid, er.total_ttc, per.amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as per,'.MAIN_DB_PREFIX.'expensereport as er'; $sql.= ' WHERE per.fk_expensereport = er.rowid'; $sql.= ' AND er.entity = '.$conf->entity; @@ -234,7 +234,7 @@ if ($resql) print $expensereport->getNomUrl(1); print "\n"; // Expected to pay - print ''.price($objp->d_amount).''; + print ''.price($objp->total_ttc).''; // Status print ''.$expensereport->getLibStatut(4,$objp->amount).''; // Amount paid diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index e8c2ef8a26e..8a8d29aa8cf 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("bills"); -$chid=GETPOST("rowid"); +$chid=GETPOST("id"); $action=GETPOST('action'); $amounts = array(); @@ -50,7 +50,7 @@ if ($action == 'add_payment') if ($_POST["cancel"]) { - $loc = DOL_URL_ROOT.'/expensereport/card.php?rowid='.$chid; + $loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$chid; header("Location: ".$loc); exit; } @@ -129,7 +129,7 @@ if ($action == 'add_payment') if (! $error) { $db->commit(); - $loc = DOL_URL_ROOT.'/expensereport/card.php?rowid='.$chid; + $loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$chid; header('Location: '.$loc); exit; } @@ -160,7 +160,7 @@ if (GETPOST("action") == 'create') $expensereport = new ExpenseReport($db); $expensereport->fetch($chid); - $total = $expensereport->amount; + $total = $expensereport->total_ttc; print_fiche_titre($langs->trans("DoPayment")); @@ -171,7 +171,7 @@ if (GETPOST("action") == 'create') print '
'; print ''; - print ''; + print ''; print ''; print ''; @@ -181,9 +181,9 @@ if (GETPOST("action") == 'create') print ''.$langs->trans("ExpenseReport").''; - print ''.$langs->trans("Ref").''.$chid.''; - print ''.$langs->trans("Date")."".dol_print_date($expensereport->date,'day')."\n"; - print ''.$langs->trans("Amount")."".price($expensereport->amount,0,$outputlangs,1,-1,-1,$conf->currency).''; + print ''.$langs->trans("Ref").''.$expensereport->ref.''; + print ''.$langs->trans("Period").''.get_date_range($expensereport->date_debut,$expensereport->date_fin,"",$langs,0).''; + print ''.$langs->trans("Amount").''.price($expensereport->total_ttc,0,$outputlangs,1,-1,-1,$conf->currency).''; $sql = "SELECT sum(p.amount) as total"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p"; @@ -215,7 +215,7 @@ if (GETPOST("action") == 'create') print ''; print ''; - print ''.$langs->trans('AccountToCredit').''; + print ''.$langs->trans('AccountToDebit').''; print ''; $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$expensereport->accountid, "accountid", 0, '',1); // Show open bank account list print ''; @@ -261,14 +261,14 @@ if (GETPOST("action") == 'create') print ""; - print ''.price($objp->amount).""; + print ''.price($objp->total_ttc).""; print ''.price($sumpaid).""; - print ''.price($objp->amount - $sumpaid).""; + print ''.price($objp->total_ttc - $sumpaid).""; print ''; - if ($sumpaid < $objp->amount) + if ($sumpaid < $objp->total_ttc) { $namef = "amount_".$objp->id; print ''; diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index be91c24cb92..1bd3a473fd1 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -243,6 +243,7 @@ CREATE TABLE llx_expensereport ( fk_user_paid integer DEFAULT NULL, fk_statut integer NOT NULL, -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé fk_c_paiement integer DEFAULT NULL, + paid smallint default 0 NOT NULL, note_public text, note_private text, detail_refuse varchar(255) DEFAULT NULL, diff --git a/htdocs/install/mysql/tables/llx_expensereport.sql b/htdocs/install/mysql/tables/llx_expensereport.sql index 657d8f9e278..879623b6b7e 100755 --- a/htdocs/install/mysql/tables/llx_expensereport.sql +++ b/htdocs/install/mysql/tables/llx_expensereport.sql @@ -46,6 +46,7 @@ CREATE TABLE llx_expensereport ( fk_user_paid integer DEFAULT NULL, fk_statut integer NOT NULL, -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé fk_c_paiement integer DEFAULT NULL, + paid smallint default 0 NOT NULL, note_public text, note_private text, detail_refuse varchar(255) DEFAULT NULL, From f8cf0fa6792836c91ad082aa757fd24fda412c49 Mon Sep 17 00:00:00 2001 From: zachary Date: Wed, 17 Jun 2015 19:58:34 -0400 Subject: [PATCH 08/14] Adds dockerfile --- .dockerignore | 16 ++++++++++++++++ Dockerfile | 9 +++++++++ 2 files changed, 25 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000000..e5908c26ac0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +build +build.xml +ChangeLog +composer.json +CONTRIBUTING.md +COPYING +COPYRIGHT +dev +doc +Dockerfile +INSTALL +README-FR.md +README.md +robots.txt +scripts +test \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000000..6c70913f8b7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM php:5.6-apache + +RUN apt-get update && apt-get install -y php5-gd php5-mysql + +COPY htdocs/ /var/www/html/ + +RUN chown -hR www-data:www-data /var/www/html + +EXPOSE 80 \ No newline at end of file From 0ef8ea269b682b78938d86bdf79123fdc0a7d48f Mon Sep 17 00:00:00 2001 From: zachary Date: Wed, 17 Jun 2015 20:20:58 -0400 Subject: [PATCH 09/14] Adds php-gd and mysqli to dockerfile --- Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6c70913f8b7..a5eb941c781 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,11 @@ FROM php:5.6-apache -RUN apt-get update && apt-get install -y php5-gd php5-mysql +RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev \ + && rm -rf /var/lib/apt/lists/* \ + && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ + && docker-php-ext-install gd + +RUN docker-php-ext-install mysqli COPY htdocs/ /var/www/html/ From 9cf06ec21c8a98cdfac096386c17c6ffae1aa13d Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 18 Jun 2015 06:12:05 +0200 Subject: [PATCH 10/14] Add function set_paid --- htdocs/expensereport/card.php | 18 ++++++++++- .../class/expensereport.class.php | 30 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 54bdc279098..8e382fb4285 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -827,6 +827,18 @@ if ($action == "confirm_brouillonner" && GETPOST('confirm')=="yes" && $id > 0 && } } +if ($action == 'set_paid') +{ + if ($object->set_paid($id) >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + exit; + } + else { + setEventMessage($object->error, 'errors'); + } +} + if ($action == "addline") { $error = 0; @@ -1988,7 +2000,11 @@ if ($action != 'create' && $action != 'edit') { print ''; } - print 'id.'">'.$langs->trans('TO_PAID').''; + + if ($object->statut == 1 && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer) + { + print '"; + } // Cancel if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 7dede6d11a9..168b4580a62 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -372,6 +372,36 @@ class ExpenseReport extends CommonObject } } + /** + * Classify the expense report as paid + * + * @param int $id id of expense report + * @param int $modepayment mode of payment + * @return int <0 if KO, >0 if OK + */ + function set_paid($id) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."expensereport SET fk_statut = 6"; + $sql.= " WHERE rowid = $id AND fk_statut = 5"; + + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->affected_rows($resql)) + { + return 1; + } + else + { + return 0; + } + } + else + { + dol_print_error($this->db); + return -1; + } + } /** * Returns the label status From 7539ad88fafc4899e2314a67b236c31a1822b1ca Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 18 Jun 2015 06:30:48 +0200 Subject: [PATCH 11/14] Debug --- htdocs/don/class/paymentdonation.class.php | 4 ++-- htdocs/expensereport/card.php | 2 +- .../class/paymentexpensereport.class.php | 12 ++++++------ htdocs/expensereport/payment/payment.php | 16 ++++++++-------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index 2d75cd392fc..27784446e4b 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -42,7 +42,7 @@ class PaymentDonation extends CommonObject var $datep=''; var $amount; // Total amount of payment var $amounts=array(); // Array of amounts - var $fk_typepayment; + var $typepayment; var $num_payment; var $note; var $fk_bank; @@ -90,7 +90,7 @@ class PaymentDonation extends CommonObject // Clean parameters if (isset($this->fk_donation)) $this->fk_donation=trim($this->fk_donation); if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); + if (isset($this->typepayment)) $this->typepayment=trim($this->typepayment); if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); if (isset($this->note)) $this->note=trim($this->note); if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 8e382fb4285..1a52f0dc194 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1477,7 +1477,7 @@ else print ""; print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; print ''.dol_print_date($db->jdate($objp->dp),'day')."\n"; - $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->payment_type; + $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->fk_typepayment; print "".$labeltype.' '.$object->num_payment."\n"; print ''.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."\n"; print ""; diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 51a196057cf..0c46943de49 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -42,7 +42,7 @@ class PaymentExpenseReport extends CommonObject var $datep=''; var $amount; // Total amount of payment var $amounts=array(); // Array of amounts - var $paymenttype; + var $fk_typepayment; var $num_payment; var $note; var $fk_bank; @@ -84,7 +84,7 @@ class PaymentExpenseReport extends CommonObject // Clean parameters if (isset($this->fk_expensereport)) $this->fk_expensereport=trim($this->fk_expensereport); if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepayment)) $this->paymenttype=trim($this->paymenttype); + if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); if (isset($this->note)) $this->note=trim($this->note); if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); @@ -109,11 +109,11 @@ class PaymentExpenseReport extends CommonObject if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_expensereport (fk_expensereport, datec, datep, amount,"; - $sql.= " fk_c_typepayment, num_payment, note, fk_user_creat, fk_bank)"; + $sql.= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; $sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',"; $sql.= " '".$this->db->idate($this->datepaid)."',"; $sql.= " ".$totalamount.","; - $sql.= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.","; + $sql.= " ".$this->fk_typepayment.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.","; $sql.= " 0)"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -187,7 +187,7 @@ class PaymentExpenseReport extends CommonObject $this->tms = $this->db->jdate($obj->tms); $this->datep = $this->db->jdate($obj->datep); $this->amount = $obj->amount; - $this->fk_typepayment = $obj->fk_typepayment; + $this->fk_typepayment = $obj->fk_typepayment; $this->num_payment = $obj->num_payment; $this->note = $obj->note; $this->fk_bank = $obj->fk_bank; @@ -486,7 +486,7 @@ class PaymentExpenseReport extends CommonObject // Insert payment into llx_bank $bank_line_id = $acc->addline( $this->datepaid, - $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") + $this->fk_typepayment, // Payment mode id or code ("CHQ or VIR for example") $label, $amount, $this->num_payment, diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index 8a8d29aa8cf..7b867609f4f 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -57,7 +57,7 @@ if ($action == 'add_payment') $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - if (! $_POST["paymenttype"] > 0) + if (! $_POST["fk_typepayment"] > 0) { $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); $error++; @@ -99,12 +99,12 @@ if ($action == 'add_payment') // Create a line of payments $payment = new PaymentExpenseReport($db); - $payment->chid = $chid; - $payment->datepaid = $datepaid; - $payment->amounts = $amounts; // Tableau de montant - $payment->paymenttype = $_POST["paymenttype"]; - $payment->num_payment = $_POST["num_payment"]; - $payment->note = $_POST["note"]; + $payment->chid = $chid; + $payment->datepaid = $datepaid; + $payment->amounts = $amounts; // Tableau de montant + $payment->fk_typepayment = $_POST["fk_typepayment"]; + $payment->num_payment = $_POST["num_payment"]; + $payment->note = $_POST["note"]; if (! $error) { @@ -210,7 +210,7 @@ if (GETPOST("action") == 'create') print ''; print ''.$langs->trans("PaymentMode").''; - $form->select_types_paiements(isset($_POST["paymenttype"])?$_POST["paymenttype"]:$expensereport->paymenttype, "paymenttype"); + $form->select_types_paiements(isset($_POST["fk_typepayment"])?$_POST["fk_typepayment"]:$expensereport->fk_typepayment, "fk_typepayment"); print "\n"; print ''; From c96c528d3e2c229e7ae650dc2c72573cfe727911 Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Thu, 18 Jun 2015 15:16:28 +0200 Subject: [PATCH 12/14] Correction complete_head Ajout de la fonction complete_head_from_modules() pour supprimer les onglets si besoin. --- htdocs/core/lib/fourn.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index d350fbce175..fdeece84d52 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -153,7 +153,7 @@ function ordersupplier_prepare_head($object) $head[$h][1] = $langs->trans("OrderFollow"); $head[$h][2] = 'info'; $h++; - + complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order', 'remove'); return $head; } From 21f0fc82299d38f8611adf53f08cc92c151903d1 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Thu, 18 Jun 2015 19:49:19 +0200 Subject: [PATCH 13/14] FIX can receive new batch product on supplier order --- htdocs/fourn/commande/dispatch.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index a678aa343c7..27ddcf9cdb1 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -154,7 +154,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) if (! $error) { - $result = $commande->DispatchProduct($user, GETPOST($prod,'int'), GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST("comment"), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger); + $result = $commande->DispatchProduct($user, GETPOST($prod,'int'), GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST('comment'), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger); if ($result < 0) { setEventMessages($commande->error, $commande->errors, 'errors'); @@ -170,16 +170,17 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) //eat-by date dispatch //$numline=$reg[2] + 1; // line of product $numline=$pos; - $prod = "product_".$reg[1]."_".$reg[2]; - $qty = "qty_".$reg[1]."_".$reg[2]; - $ent = "entrepot_".$reg[1]."_".$reg[2]; - $pu = "pu_".$reg[1]."_".$reg[2]; - $fk_commandefourndet = "fk_commandefourndet_".$reg[1]."_".$reg[2]; - $lot = "lot_number_".$reg[1]."_".$reg[2]; - $dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_'.$reg[1]."_".$reg[2].'month'], $_POST['dluo_'.$reg[1]."_".$reg[2].'day'], $_POST['dluo_'.$reg[1]."_".$reg[2].'year']); - $dDLC = dol_mktime(12, 0, 0, $_POST['dlc_'.$reg[1]."_".$reg[2].'month'], $_POST['dlc_'.$reg[1]."_".$reg[2].'day'], $_POST['dlc_'.$reg[1]."_".$reg[2].'year']); + $prod = 'product_'.$reg[1].'_'.$reg[2]; + $qty = 'qty_'.$reg[1].'_'.$reg[2]; + $ent = 'entrepot_'.$reg[1].'_'.$reg[2]; + $pu = 'pu_'.$reg[1].'_'.$reg[2]; + $fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2]; + $lot = 'lot_number_'.$reg[1].'_'.$reg[2]; + $dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_'.$reg[1].'_'.$reg[2].'month'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'day'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'year']); + $dDLC = dol_mktime(12, 0, 0, $_POST['dlc_'.$reg[1].'_'.$reg[2].'month'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'day'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'year']); - $fk_commandefourndet = "fk_commandefourndet_".$reg[1]."_".$reg[2]; + $fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2]; + if (GETPOST($qty) > 0) // We ask to move a qty { if (! (GETPOST($ent,'int') > 0)) @@ -200,7 +201,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) if (! $error) { - $result = $commande->dispatchProduct($user, GETPOST($prod,'int'), GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST("comment"), $dDLC, $dDLUO, GETPOST($lot, 'alpha'), GETPOST($fk_commandefourndet, 'int'), $notrigger); + $result = $commande->dispatchProduct($user, GETPOST($prod,'int'), GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST('comment'), $dDLC, $dDLUO, GETPOST($lot, 'alpha'), GETPOST($fk_commandefourndet, 'int'), $notrigger); if ($result < 0) { setEventMessages($commande->error, $commande->errors, 'errors'); @@ -225,7 +226,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) } } - if ($result > 0 && ! $error) + if ($result >= 0 && ! $error) { $db->commit(); From f60ca031402312e21ec6f901a77db2fb17f3d284 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 19 Jun 2015 06:11:32 +0200 Subject: [PATCH 14/14] Fix travis --- htdocs/expensereport/class/expensereport.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 168b4580a62..914ff34043d 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -376,7 +376,6 @@ class ExpenseReport extends CommonObject * Classify the expense report as paid * * @param int $id id of expense report - * @param int $modepayment mode of payment * @return int <0 if KO, >0 if OK */ function set_paid($id)