From e081653cef9cb616292ea029fef04cd235ccba88 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 30 Aug 2017 06:38:33 +0200 Subject: [PATCH 1/9] Add fk_projet in table various_payment --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 14 +++++++------- .../install/mysql/tables/llx_payment_various.sql | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 76517914c0e..b0ca503d938 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -64,24 +64,24 @@ CREATE TABLE IF NOT EXISTS llx_expensereport_ik ( datec datetime DEFAULT NULL, tms timestamp, fk_c_exp_tax_cat integer DEFAULT 0 NOT NULL, - fk_range integer DEFAULT 0 NOT NULL, - coef double DEFAULT 0 NOT NULL, - offset double DEFAULT 0 NOT NULL + fk_range integer DEFAULT 0 NOT NULL, + coef double DEFAULT 0 NOT NULL, + offset double DEFAULT 0 NOT NULL )ENGINE=innodb DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS llx_c_exp_tax_cat ( rowid integer AUTO_INCREMENT PRIMARY KEY, label varchar(48) NOT NULL, entity integer DEFAULT 1 NOT NULL, - active integer DEFAULT 1 NOT NULL + active integer DEFAULT 1 NOT NULL )ENGINE=innodb DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS llx_c_exp_tax_range ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_c_exp_tax_cat integer DEFAULT 1 NOT NULL, - range_ik double DEFAULT 0 NOT NULL, + range_ik double DEFAULT 0 NOT NULL, entity integer DEFAULT 1 NOT NULL, - active integer DEFAULT 1 NOT NULL + active integer DEFAULT 1 NOT NULL )ENGINE=innodb DEFAULT CHARSET=utf8; INSERT INTO llx_c_type_fees (code, label, active, accountancy_code) VALUES @@ -201,5 +201,5 @@ ALTER TABLE llx_extrafields ADD COLUMN tms timestamp; ALTER TABLE llx_holiday_config MODIFY COLUMN name varchar(128); ALTER TABLE llx_holiday_config ADD UNIQUE INDEX idx_holiday_config (name); - +ALTER TABLE llx_payment_various ADD COLUMN fk_projet integer DEFAULT NULL after accountancy_code; diff --git a/htdocs/install/mysql/tables/llx_payment_various.sql b/htdocs/install/mysql/tables/llx_payment_various.sql index abaf9fdab26..e92b244b009 100644 --- a/htdocs/install/mysql/tables/llx_payment_various.sql +++ b/htdocs/install/mysql/tables/llx_payment_various.sql @@ -28,7 +28,8 @@ create table llx_payment_various fk_typepayment integer NOT NULL, num_payment varchar(50), -- ref label varchar(255), - accountancy_code varchar(32), + accountancy_code varchar(32), + fk_projet integer DEFAULT NULL, entity integer DEFAULT 1 NOT NULL, -- multi company id note text, fk_bank integer, From c761eb592e344185b500346d5ba97307a81d946f Mon Sep 17 00:00:00 2001 From: Quentin Sutkowski Date: Thu, 31 Aug 2017 11:15:55 +0200 Subject: [PATCH 2/9] Fix barcode reader on POS Solve the keyboard emulation issue with a barcode reader on cashdesk module research area. --- htdocs/cashdesk/tpl/facturation1.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index 580012847f5..8cfe70638e3 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -42,9 +42,9 @@ $langs->load("cashdesk"); trans("FilterRefOrLabelOrBC"); ?>trans("Designation"); ?> + From 84fcbb724e24b37b5a9d3cbdb9d28979efa70cea Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 1 Sep 2017 07:21:27 +0200 Subject: [PATCH 3/9] Add project on various_payment --- .../bank/class/paymentvarious.class.php | 67 ++++++++++++++- htdocs/compta/bank/various_payment/card.php | 84 +++++++++++++++++-- htdocs/compta/bank/various_payment/index.php | 2 +- htdocs/langs/en_US/banks.lang | 3 +- htdocs/langs/en_US/projects.lang | 1 + htdocs/projet/element.php | 24 +++++- 6 files changed, 165 insertions(+), 16 deletions(-) diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 1d0568c8064..45ae8d5dd95 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -30,8 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; */ class PaymentVarious extends CommonObject { - //public $element='payment_various'; //!< Id that identify managed objects - //public $table_element='payment_various'; //!< Name of table without prefix where object is stored + public $element='variouspayment'; //!< Id that identify managed objects + public $table_element='payment_various'; //!< Name of table without prefix where object is stored + public $picto = 'bill'; var $tms; var $datep; @@ -42,6 +43,7 @@ class PaymentVarious extends CommonObject var $num_payment; var $label; var $accountancy_code; + var $fk_project; var $fk_bank; var $fk_user_author; var $fk_user_modif; @@ -96,6 +98,7 @@ class PaymentVarious extends CommonObject $sql.= " label='".$this->db->escape($this->label)."',"; $sql.= " note='".$this->db->escape($this->note)."',"; $sql.= " accountancy_code='".$this->db->escape($this->accountancy_code)."',"; + $sql.= " fk_projet='".$this->db->escape($this->fk_project)."',"; $sql.= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank:"null").","; $sql.= " fk_user_author=".$this->fk_user_author.","; $sql.= " fk_user_modif=".$this->fk_user_modif; @@ -154,6 +157,7 @@ class PaymentVarious extends CommonObject $sql.= " v.label,"; $sql.= " v.note,"; $sql.= " v.accountancy_code,"; + $sql.= " v.fk_projet as fk_project,"; $sql.= " v.fk_bank,"; $sql.= " v.fk_user_author,"; $sql.= " v.fk_user_modif,"; @@ -185,6 +189,7 @@ class PaymentVarious extends CommonObject $this->label = $obj->label; $this->note = $obj->note; $this->accountancy_code = $obj->accountancy_code; + $this->fk_project = $obj->fk_project; $this->fk_bank = $obj->fk_bank; $this->fk_user_author = $obj->fk_user_author; $this->fk_user_modif = $obj->fk_user_modif; @@ -317,6 +322,7 @@ class PaymentVarious extends CommonObject if ($this->note) $sql.= ", note"; $sql.= ", label"; $sql.= ", accountancy_code"; + $sql.= ", fk_projet"; $sql.= ", fk_user_author"; $sql.= ", datec"; $sql.= ", fk_bank"; @@ -451,6 +457,63 @@ class PaymentVarious extends CommonObject } + /** + * Retourne le libelle du statut + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @return string Libelle + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->statut,$mode); + } + + /** + * Renvoi le libelle d'un statut donne + * + * @param int $statut Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @return string Libelle + */ + function LibStatut($statut,$mode=0) + { + global $langs; + + if ($mode == 0) + { + return $langs->trans($this->statuts[$statut]); + } + if ($mode == 1) + { + return $langs->trans($this->statuts_short[$statut]); + } + if ($mode == 2) + { + if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts_short[$statut]); + if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]); + if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts_short[$statut]); + } + if ($mode == 3) + { + if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0'); + if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); + if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); + } + if ($mode == 4) + { + if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); + if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); + if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]); + } + if ($mode == 5) + { + if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0'); + if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); + if ($statut==2 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); + } + } + + /** * Send name clicable (with possibly the picto) * diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index e16c822db9b..4c57ab5f324 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -29,6 +29,11 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +if (! empty($conf->projet->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +} $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy")); @@ -44,6 +49,7 @@ $sens=GETPOST("sens","int"); $amount=GETPOST("amount"); $paymenttype=GETPOST("paymenttype"); $accountancy_code=GETPOST("accountancy_code","int"); +$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); // Security check $socid = GETPOST("socid","int"); @@ -67,6 +73,13 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { + // Link to a project + if ($action == 'classin' && $user->rights->banque->modifier) + { + $object->fetch($id); + $object->setProject(GETPOST('projectid')); + } + if ($cancel) { if ($action != 'addlink') @@ -98,6 +111,7 @@ if (empty($reshook)) $object->fk_user_author=$user->id; $object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : ""; $object->sens=GETPOST('sens'); + $object->fk_project= GETPOST('fk_project'); if (empty($datep) || empty($datev)) { @@ -205,6 +219,7 @@ llxHeader("",$langs->trans("VariousPayment")); $form = new Form($db); if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db); +if (! empty($conf->projet->enabled)) $formproject = new FormProjets($db); if ($id) { @@ -306,6 +321,21 @@ if ($action == 'create') print ''; } + // Project + if (! empty($conf->projet->enabled)) + { + $formproject=new FormProjets($db); + + // Associated project + $langs->load("projects"); + + print ''.$langs->trans("Project").''; + + $numproject=$formproject->select_projects(-1, $projectid,'fk_project',0,0,1,1); + + print ''; + } + // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -333,19 +363,52 @@ if ($action == 'create') if ($id) { - $head=various_payment_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("VariousPayment"), 0, 'payment'); - - print ''; + dol_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, 'payment'); + $morehtmlref='
'; + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.=$langs->trans('Project') . ' '; + if ($user->rights->tax->charges->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
'; $linkback = ''.$langs->trans("BackToList").''; - print ""; - print ''; + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + + print '
'; + print '
'; + + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); - print '
'; // Label print ''; @@ -404,6 +467,11 @@ if ($id) print '
'.$langs->trans("Label").''.$object->label.'
'; + print ''; + print ''; + + print '
'; + dol_fiche_end(); diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index 42558d11635..48f37d24235 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -243,7 +243,7 @@ if ($result) $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($obj->accountancy_journal); - $accountstatic->accountancy_journal = $accountingjournal->code; + $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1); } $accountstatic->label=$obj->blabel; diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 46222fca80c..d261fe8a53d 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -156,4 +156,5 @@ DocumentModelBan=Template to print a page with BAN information. NewVariousPayment=New miscellaneous payments VariousPayment=Miscellaneous payments VariousPayments=Miscellaneous payments -ShowVariousPayment=Show miscellaneous payments +ShowVariousPayment=Show miscellaneous payments +AddVariousPayment=Add miscellaneous payments \ No newline at end of file diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 8b380645f73..92282fd29f0 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -88,6 +88,7 @@ ListShippingAssociatedProject=List of shippings associated with the project ListFichinterAssociatedProject=List of interventions associated with the project ListExpenseReportsAssociatedProject=List of expense reports associated with the project ListDonationsAssociatedProject=List of donations associated with the project +ListVariousPaymentsAssociatedProject=List of various payments associated with the project ListActionsAssociatedProject=List of events associated with the project ListTaskTimeUserProject=List of time consumed on tasks of project ActivityOnProjectToday=Activity on project today diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index bda8d793840..0dcb710cfb5 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -51,6 +51,7 @@ if (! empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/d if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; if (! empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; $langs->load("projects"); $langs->load("companies"); @@ -439,6 +440,19 @@ $listofreferent=array( 'datefieldname'=>'datem', 'disableamount'=>0, 'test'=>($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))), +'variouspayment'=>array( + 'name'=>"VariousPayments", + 'title'=>"ListVariousPaymentsAssociatedProject", + 'class'=>'PaymentVarious', + 'table'=>'payment_various', + 'datefieldname'=>'datev', + 'margin'=>'minus', + 'disableamount'=>0, + 'urlnew'=>DOL_URL_ROOT.'/compta/bank_various_payment/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'lang'=>'banks', + 'buttonnew'=>'AddVariousPayment', + 'testnew'=>$user->rights->banque->modifier, + 'test'=>$conf->banque->enabled && $user->rights->banque->lire), /* No need for this, available on dedicated tab "Agenda/Events" 'agenda'=>array( 'name'=>"Agenda", @@ -769,6 +783,7 @@ foreach ($listofreferent as $key => $value) // Thirdparty or user print ''; if (in_array($tablename, array('projet_task')) && $key == 'project_task') print ''; // if $key == 'project_task', we don't want details per user + elseif (in_array($tablename, array('payment_various'))) print ''; // if $key == 'payment_various', we don't have any thirdparty elseif (in_array($tablename, array('expensereport_det','don','projet_task','stock_mouvement'))) print $langs->trans("User"); else print $langs->trans("ThirdParty"); print ''; @@ -898,7 +913,8 @@ foreach ($listofreferent as $key => $value) $date=''; $total_time_by_line = null; if ($tablename == 'expensereport_det') $date = $element->date; // No draft status on lines elseif ($tablename == 'stock_mouvement') $date = $element->datem; - if ($tablename == 'chargesociales') $date = $element->date_ech; + elseif ($tablename == 'payment_various') $date = $element->datev; + elseif ($tablename == 'chargesociales') $date = $element->date_ech; elseif (! empty($element->status) || ! empty($element->statut) || ! empty($element->fk_status)) { if ($tablename == 'don') $date = $element->datedon; @@ -909,7 +925,7 @@ foreach ($listofreferent as $key => $value) elseif ($tablename == 'supplier_proposal') $date=$element->date_validation; // There is no other date for this elseif ($tablename == 'fichinter') $date=$element->datev; // There is no other date for this elseif ($tablename == 'projet_task') $date=''; // We show no date. Showing date of beginning of task make user think it is date of time consumed - else + else { $date=$element->date; // invoice, ... if (empty($date)) $date=$element->date_contrat; @@ -963,7 +979,7 @@ foreach ($listofreferent as $key => $value) { $total_ht_by_line=null; $othermessage=''; - if ($tablename == 'don' || $tablename == 'chargesociales') $total_ht_by_line=$element->amount; + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various') $total_ht_by_line=$element->amount; else if($tablename == 'fichinter') $total_ht_by_line=$element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ht_by_line=$element->price*abs($element->qty); elseif (in_array($tablename, array('projet_task'))) @@ -1004,7 +1020,7 @@ foreach ($listofreferent as $key => $value) if (empty($value['disableamount'])) { $total_ttc_by_line=null; - if ($tablename == 'don' || $tablename == 'chargesociales') $total_ttc_by_line=$element->amount; + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various') $total_ttc_by_line=$element->amount; else if($tablename == 'fichinter') $total_ttc_by_line=$element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ttc_by_line=$element->price*abs($element->qty); elseif ($tablename == 'projet_task') From 9443cb0c1baf322f0a9dc6491f897ec705de2014 Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Fri, 1 Sep 2017 15:53:06 +0100 Subject: [PATCH 4/9] NEW Added Region name to state/province form field --- htdocs/core/class/html.formcompany.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 131cdae3952..ef4a3cb739e 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -217,7 +217,7 @@ class FormCompany $out=''; // On recherche les departements/cantons/province active d'une region et pays actif - $sql = "SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code FROM"; + $sql = "SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.nom as region_name FROM"; $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; @@ -265,7 +265,15 @@ class FormCompany $out.= ''; } $i++; From cd8362498f292b3a3e881e2f74cf10ce72a27d57 Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Fri, 1 Sep 2017 16:07:07 +0100 Subject: [PATCH 5/9] NEW Added regions to third party/societe lists, can be filtered --- htdocs/societe/list.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index c7ede7c5e3f..00ff84d6bfe 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -7,6 +7,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2016 Josep Lluis Amador * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2017 Rui Strecht * * 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 @@ -63,6 +64,7 @@ $search_account_supplier_code=trim(GETPOST('search_account_supplier_code')); $search_town=trim(GETPOST("search_town")); $search_zip=trim(GETPOST("search_zip")); $search_state=trim(GETPOST("search_state")); +$search_region=trim(GETPOST("search_region")); $search_email=trim(GETPOST('search_email')); $search_phone=trim(GETPOST('search_phone')); $search_url=trim(GETPOST('search_url')); @@ -168,6 +170,7 @@ $arrayfields=array( 's.town'=>array('label'=>"Town", 'checked'=>1), 's.zip'=>array('label'=>"Zip", 'checked'=>1), 'state.nom'=>array('label'=>"State", 'checked'=>0), + 'region.nom'=>array('label'=>"Region", 'checked'=>0), 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), 's.email'=>array('label'=>"Email", 'checked'=>0), 's.url'=>array('label'=>"Url", 'checked'=>0), @@ -387,7 +390,8 @@ $sql.= " s.email, s.phone, s.url, s.siren as idprof1, s.siret as idprof2, s.ape $sql.= " s.tms as date_update, s.datec as date_creation,"; $sql.= " s.code_compta,s.code_compta_fournisseur,"; $sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name"; +$sql.= " state.code_departement as state_code, state.nom as state_name,"; +$sql.= " region.code_region as region_code, region.nom as region_name"; // We'll need these fields in order to filter by sale (including the case where the user can only see his prospects) if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; // We'll need these fields in order to filter by categ @@ -404,6 +408,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region = state.fk_region)"; // We'll need this table joined to the select in order to filter by categ if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ if (! empty($search_categ_sup)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ @@ -436,6 +441,7 @@ if ($search_account_supplier_code) $sql.= natural_search("s.code_compta_fourniss if ($search_town) $sql.= natural_search("s.town",$search_town); if (strlen($search_zip)) $sql.= natural_search("s.zip",$search_zip); if ($search_state) $sql.= natural_search("state.nom",$search_state); +if ($search_region) $sql.= natural_search("region.nom",$search_region); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_email) $sql.= natural_search("s.email",$search_email); if (strlen($search_phone)) $sql.= natural_search("s.phone", $search_phone); @@ -728,6 +734,13 @@ if (! empty($arrayfields['state.nom']['checked'])) print ''; print ''; } +// Region +if (! empty($arrayfields['region.nom']['checked'])) +{ + print ''; + print ''; + print ''; +} // Country if (! empty($arrayfields['country.code_iso']['checked'])) { @@ -937,6 +950,7 @@ if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_f if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.email","",$param,'',$sortfield,$sortorder); @@ -1068,6 +1082,12 @@ while ($i < min($num, $limit)) print "".$obj->state_name."\n"; if (! $i) $totalarray['nbfield']++; } + // Region + if (! empty($arrayfields['region.nom']['checked'])) + { + print "".$obj->region_name."\n"; + if (! $i) $totalarray['nbfield']++; + } // Country if (! empty($arrayfields['country.code_iso']['checked'])) { From 1ee0077e4ee9b91a47285e495f6fb383b0b2078b Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Fri, 1 Sep 2017 16:10:19 +0100 Subject: [PATCH 6/9] Fix: Added name to contributors --- htdocs/core/class/html.formcompany.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index ef4a3cb739e..6389733f72c 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2008-2012 Laurent Destailleur * Copyright (C) 2008-2012 Regis Houssin * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2017 Rui Strecht * * 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 From 407febc14134f02b3efe44e1af5bf55293efd7c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2017 22:49:33 +0200 Subject: [PATCH 7/9] Fix travis --- htdocs/websites/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index f763c8dd39b..0d4763f5dc3 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -169,7 +169,7 @@ if ($action == 'addsite') { $db->begin(); - if (! $error && empty(GETPOST('WEBSITE_REF','alpha'))) + if (! $error && ! GETPOST('WEBSITE_REF','alpha')) { $error++; setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); From 58b08c7de8a1c7e0bcd39cf542d3b381c364fe18 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2017 23:56:59 +0200 Subject: [PATCH 8/9] Clean code --- htdocs/admin/dolistore/ajax/image.php | 2 +- .../admin/dolistore/class/dolistore.class.php | 268 +++++++++--------- htdocs/admin/dolistore/class/init.php | 2 +- htdocs/cashdesk/css/style.css | 4 - htdocs/cashdesk/javascript/dhtml.js | 16 +- htdocs/cashdesk/tpl/facturation1.tpl.php | 3 +- 6 files changed, 141 insertions(+), 154 deletions(-) diff --git a/htdocs/admin/dolistore/ajax/image.php b/htdocs/admin/dolistore/ajax/image.php index 10ce4656c40..6d63dd3e08b 100644 --- a/htdocs/admin/dolistore/ajax/image.php +++ b/htdocs/admin/dolistore/ajax/image.php @@ -42,7 +42,7 @@ if (!$res) die("Include of main fails"); global $lang, $user, $conf; -dol_include_once('/dolistore/class/dolistore.class.php'); +require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php'; $dolistore = new Dolistore(); $id_product = GETPOST('id_product', 'int'); diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index 5e0aa546cc0..0c5a7f08568 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -19,9 +19,145 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class.php'; + + /** * Class DolistoreModel */ +class DolistoreModel +{ + + function get_categories($parent = 0) + { + if (!isset($this->categories)) die('not possible'); + if ($parent != 0) { + $html = '
    '; + } else { + $html = ''; + } + + $nbofcateg = count($this->categories); + for ($i = 0; $i < $nbofcateg; $i++) + { + $cat = $this->categories[$i]; + if ($cat->is_root_category == 1 && $parent == 0) { + $html .= '
  • '.$cat->name->language[$this->lang].' '.$cat->nb_products_recursive.'

    '; + $html .= self::get_categories($cat->id); + $html .= "
  • \n"; + } elseif (trim($cat->id_parent) == $parent && $cat->active == 1 && trim($cat->id_parent) != 0) { // si cat est de ce niveau + $select = ($cat->id == $this->categorie) ? ' selected' : ''; + $html .= '
  • '.$cat->name->language[$this->lang].' '.$cat->nb_products_recursive.''; + $html .= self::get_categories($cat->id); + $html .= "
  • \n"; + } else { + + } + } + + if ($html == '
      ') { + return ''; + } + if ($parent != 0) { + return $html.'
    '; + } else { + return $html; + } + } + + function get_products() + { + global $langs, $conf; + $html = ""; + $parity = "pair"; + $last_month = time() - (30 * 24 * 60 * 60); + foreach ($this->products as $product) { + $parity = ($parity == "impair") ? 'pair' : 'impair'; + + // check new product ? + $newapp = ''; + if ($last_month < strtotime($product->date_add)) { + $newapp .= ''.$langs->trans('New').' '; + } + + // check updated ? + if ($last_month < strtotime($product->date_upd) && $newapp == '') { + $newapp .= ''.$langs->trans('Updated').' '; + } + + // add image or default ? + if ($product->id_default_image != '') { + $image_url = dol_buildPath('/dolistore/ajax/image.php?id_product=', 2).$product->id.'&id_image='.$product->id_default_image; + $images = ''. + ''; + } else { + $images = ''; + } + + // free or pay ? + if ($product->price > 0) { + $price = '

    '.price(round((float) $product->price * $this->vat_rate, 2)).' €

    '; + $download_link = ''; + } else { + $price = $langs->trans('Free'); + $download_link = ''; + } + + //checking versions + if ($this->version_compare($product->dolibarr_min, DOL_VERSION) <= 0) { + if ($this->version_compare($product->dolibarr_max, DOL_VERSION) >= 0) { + //compatible + $version = ''.$langs->trans('CompatibleUpTo', $product->dolibarr_max, + $product->dolibarr_min, $product->dolibarr_max).''; + $compatible = ''; + } else { + //never compatible, module expired + $version = ''.$langs->trans('NotCompatible', DOL_VERSION, + $product->dolibarr_min, $product->dolibarr_max).''; + $compatible = 'NotCompatible'; + } + } else { + //need update + $version = ''.$langs->trans('CompatibleAfterUpdate', DOL_VERSION, + $product->dolibarr_min, $product->dolibarr_max).''; + $compatible = 'NotCompatible'; + } + + //output template + $html .= ' +
    '.$newapp.$images.'
    +

    '.$product->name->language[$this->lang].'Details' + .'
    '.$version.'

    + '.dol_print_date(strtotime($product->date_upd)).' - '.$langs->trans('Référence').': '.$product->reference.' - '.$langs->trans('Id').': '.$product->id.'

    '.$product->description_short->language[$this->lang].' + '.$product->description->language[$this->lang].' + '.$price.' + '.$download_link.' + '; + } + return $html; + } + + function get_previous_link($text = '<<') + { + return ''.$text.''; + } + + function get_next_link($text = '>>') + { + return ''.$text.''; + } +} + + + +/** + * Class Dolistore + */ class Dolistore extends DolistoreModel { // params @@ -182,135 +318,3 @@ class Dolistore extends DolistoreModel } } - -/** - * Class DolistoreModel - */ -class DolistoreModel -{ - - function get_categories($parent = 0) - { - if (!isset($this->categories)) die('not possible'); - if ($parent != 0) { - $html = '
      '; - } else { - $html = ''; - } - - $nbofcateg = count($this->categories); - for ($i = 0; $i < $nbofcateg; $i++) - { - $cat = $this->categories[$i]; - if ($cat->is_root_category == 1 && $parent == 0) { - $html .= '
    • '.$cat->name->language[$this->lang].' '.$cat->nb_products_recursive.'

      '; - $html .= self::get_categories($cat->id); - $html .= "
    • \n"; - } elseif (trim($cat->id_parent) == $parent && $cat->active == 1 && trim($cat->id_parent) != 0) { // si cat est de ce niveau - $select = ($cat->id == $this->categorie) ? ' selected' : ''; - $html .= '
    • '.$cat->name->language[$this->lang].' '.$cat->nb_products_recursive.''; - $html .= self::get_categories($cat->id); - $html .= "
    • \n"; - } else { - - } - } - - if ($html == '
        ') { - return ''; - } - if ($parent != 0) { - return $html.'
      '; - } else { - return $html; - } - } - - function get_products() - { - global $langs, $conf; - $html = ""; - $parity = "pair"; - $last_month = time() - (30 * 24 * 60 * 60); - foreach ($this->products as $product) { - $parity = ($parity == "impair") ? 'pair' : 'impair'; - - // check new product ? - $newapp = ''; - if ($last_month < strtotime($product->date_add)) { - $newapp .= ''.$langs->trans('New').' '; - } - - // check updated ? - if ($last_month < strtotime($product->date_upd) && $newapp == '') { - $newapp .= ''.$langs->trans('Updated').' '; - } - - // add image or default ? - if ($product->id_default_image != '') { - $image_url = dol_buildPath('/dolistore/ajax/image.php?id_product=', 2).$product->id.'&id_image='.$product->id_default_image; - $images = ''. - ''; - } else { - $images = ''; - } - - // free or pay ? - if ($product->price > 0) { - $price = '

      '.price(round((float) $product->price * $this->vat_rate, 2)).' €

      '; - $download_link = ''; - } else { - $price = $langs->trans('Free'); - $download_link = ''; - } - - //checking versions - if ($this->version_compare($product->dolibarr_min, DOL_VERSION) <= 0) { - if ($this->version_compare($product->dolibarr_max, DOL_VERSION) >= 0) { - //compatible - $version = ''.$langs->trans('CompatibleUpTo', $product->dolibarr_max, - $product->dolibarr_min, $product->dolibarr_max).''; - $compatible = ''; - } else { - //never compatible, module expired - $version = ''.$langs->trans('NotCompatible', DOL_VERSION, - $product->dolibarr_min, $product->dolibarr_max).''; - $compatible = 'NotCompatible'; - } - } else { - //need update - $version = ''.$langs->trans('CompatibleAfterUpdate', DOL_VERSION, - $product->dolibarr_min, $product->dolibarr_max).''; - $compatible = 'NotCompatible'; - } - - //output template - $html .= ' -
      '.$newapp.$images.'
      -

      '.$product->name->language[$this->lang].'Details' - .'
      '.$version.'

      - '.dol_print_date(strtotime($product->date_upd)).' - '.$langs->trans('Référence').': '.$product->reference.' - '.$langs->trans('Id').': '.$product->id.'

      '.$product->description_short->language[$this->lang].' - '.$product->description->language[$this->lang].' - '.$price.' - '.$download_link.' - '; - } - return $html; - } - - function get_previous_link($text = '<<') - { - return ''.$text.''; - } - - function get_next_link($text = '>>') - { - return ''.$text.''; - } -} diff --git a/htdocs/admin/dolistore/class/init.php b/htdocs/admin/dolistore/class/init.php index df5773d9e7d..4a94e08002c 100644 --- a/htdocs/admin/dolistore/class/init.php +++ b/htdocs/admin/dolistore/class/init.php @@ -29,7 +29,7 @@ // Here we define constants /!\ You need to replace this parameters //https://dolistorecatalogpublickey1234567@vmdevwww.dolistore.com/api/ define('DEBUG', true); // Debug mode -define('PS_SHOP_PATH', 'http://vmdevwww.dolistore.com/'); // Root path of your PrestaShop store +define('PS_SHOP_PATH', 'https://www.dolistore.com/'); // Root path of your PrestaShop store define('PS_WS_AUTH_KEY', 'dolistorecatalogpublickey1234567'); // Auth key (Get it in your Back Office) require_once('./PSWebServiceLibrary.php'); // Here we make the WebService Call diff --git a/htdocs/cashdesk/css/style.css b/htdocs/cashdesk/css/style.css index c34e8596f01..d4149619aae 100644 --- a/htdocs/cashdesk/css/style.css +++ b/htdocs/cashdesk/css/style.css @@ -260,10 +260,6 @@ p.titre { padding: 0; } -.resultats_dhtml { - width: 400px; - position: absolute; -} /* --------------------- Combo lists ------------------- */ .select_design { diff --git a/htdocs/cashdesk/javascript/dhtml.js b/htdocs/cashdesk/javascript/dhtml.js index 7f5df55a767..db05855a3b2 100644 --- a/htdocs/cashdesk/javascript/dhtml.js +++ b/htdocs/cashdesk/javascript/dhtml.js @@ -51,26 +51,14 @@ function file(fichier) { } -// Affichage des donnees aTexte dans le bloc identifie par aId -function afficheDonnees(aId, aTexte) { - - document.getElementById(aId).innerHTML = aTexte; - -} - - // aCible : id du bloc de destination; aCode : argument a passer a la page php chargee du traitement et de l'affichage function verifResultat(aCible, aCode, iLimit) { if (aCode != '' && aCode.length >= iLimit) { if (texte = file('facturation_dhtml.php?code='+escape(aCode))) { - - afficheDonnees (aCible, texte); - + document.getElementById(aCible).innerHTML = texte; } else - - afficheDonnees (aCible, ''); - + document.getElementById(aCible).innerHTML = ''; } } diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index 8cfe70638e3..3f0a0f4c371 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -45,8 +45,7 @@ $langs->load("cashdesk"); + onfocus="javascript: this.select();" /> Date: Sat, 2 Sep 2017 00:33:18 +0200 Subject: [PATCH 9/9] Fix double translation --- htdocs/compta/resultat/clientfourn.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 195292e6471..927774e82d9 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Dourseanud @@ -197,7 +197,7 @@ if ($date_endyear) $param.='&date_endyear='.$date_startyear; print ''; print ''; print_liste_field_titre(''); -print_liste_field_titre($langs->trans("Groups"), $_SERVER["PHP_SELF"],'s.nom, s.rowid','',$param,'',$sortfield,$sortorder); +print_liste_field_titre("Groups", $_SERVER["PHP_SELF"],'s.nom, s.rowid','',$param,'',$sortfield,$sortorder); if ($modecompta == 'BOOKKEEPING') { print_liste_field_titre("Amount", $_SERVER["PHP_SELF"],'amount','',$param,'align="right"',$sortfield,$sortorder);