diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 6d5baa59a11..f738f303b33 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -84,7 +84,7 @@ $tablib[35]= "DictionaryAccountancyJournal"; // Requests to extract data $tabsql=array(); -$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a WHERE a.entity=".$conf->entity; +$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a"; // Criteria to sort dictionaries $tabsqlsort=array(); @@ -100,7 +100,7 @@ $tabfieldvalue[35]= "code,label,nature"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); -$tabfieldinsert[35]= "code,label,nature,entity"; +$tabfieldinsert[35]= "code,label,nature"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index d1870fabc38..34abbdec79f 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -84,7 +84,8 @@ class AccountingAccount extends CommonObject * @param int $limittocurrentchart 1=Do not load record if it is into another accounting system * @return int <0 if KO, 0 if not found, Id of record if OK and found */ - function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) { + function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) + { global $conf; if ($rowid || $account_number) { @@ -96,10 +97,10 @@ class AccountingAccount extends CommonObject if ($rowid) { $sql .= " a.rowid = '" . $rowid . "'"; } elseif ($account_number) { - $sql .= " a.account_number = '" . $account_number . "'"; + $sql .= " a.account_number = '" . $this->db->escape($account_number) . "'"; } if (! empty($limittocurrentchart)) { - $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; + $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $this->db->escape($conf->global->CHARTOFACCOUNTS) . ')'; } dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); @@ -203,7 +204,7 @@ class AccountingAccount extends CommonObject $sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->db->escape($this->account_number) . "'"); $sql .= ", " . (empty($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'"); $sql .= ", " . (empty($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'"); - $sql .= ", " . (empty($this->account_category) ? 'NULL' : "'" . $this->db->escape($this->account_category) . "'"); + $sql .= ", " . (empty($this->account_category) ? '0' : $this->db->escape($this->account_category)); $sql .= ", " . $user->id; $sql .= ", " . (! isset($this->active) ? 'NULL' : $this->db->escape($this->active)); $sql .= ")"; @@ -274,7 +275,7 @@ class AccountingAccount extends CommonObject $sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'"; $sql .= " , account_parent = '" . $this->db->escape($this->account_parent) . "'"; $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null"); - $sql .= " , fk_accounting_category = '" . $this->db->escape($this->account_category) . "'"; + $sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : $this->db->escape($this->account_category)); $sql .= " , fk_user_modif = " . $user->id; $sql .= " , active = " . $this->active; $sql .= " WHERE rowid = " . $this->id; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 76202c2df2b..3cef158c2ea 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -75,7 +75,7 @@ print '
'; $file_list = array('missing' => array(), 'updated' => array()); // Local file to compare to -$xmlshortfile = GETPOST('xmlshortfile')?GETPOST('xmlshortfile'):'/install/filelist-'.DOL_VERSION.'.xml'; +$xmlshortfile = GETPOST('xmlshortfile','alpha')?GETPOST('xmlshortfile','alpha'):'/install/filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX)?'':$conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).'.xml'; $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; // Remote file to compare to $xmlremote = GETPOST('xmlremote'); diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 25ddfd8c1f8..cdeeaf6c424 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -1,6 +1,7 @@ * Copyright (C) 2008-2010 Laurent Destailleur + * Copyright (C) 2018 Juanjo Menent * * 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 @@ -150,7 +151,8 @@ switch($action) $obj_facturation->id($ret['rowid']); $obj_facturation->ref($ret['ref']); $obj_facturation->stock($ret['reel']); - $obj_facturation->prix($ret['price']); + //$obj_facturation->prix($ret['price']); + $obj_facturation->prix($pu_ht); $vatrate = $tva_tx; diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index c9acc111dc4..5542218b18b 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Andreu Bisquerra Gaya * Copyright (C) 2012 David Rodriguez Martinez - * Copyright (C) 2012-2017 Juanjo Menent + * Copyright (C) 2012-2018 Juanjo Menent * Copyright (C) 2015 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -285,6 +285,13 @@ if (($action == 'create' || $action == 'add') && !$error) { $fk_parent_line = 0; } + + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + $lines[$i]->fetch_optionals($lines[$i]->rowid); + $array_options = $lines[$i]->array_options; + } + $result = $object->addline( $desc, $lines[$i]->subprice, @@ -309,7 +316,8 @@ if (($action == 'create' || $action == 'add') && !$error) $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, - $lines[$i]->label + $lines[$i]->label, + $array_options ); if ($result > 0) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 67b24b4d7b2..53d8bb981ce 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -16,6 +16,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2018 Alexandre Spangaro + * Copyright (C) 2018 Nicolas ZABOURI * * 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 @@ -1348,7 +1349,7 @@ class Facture extends CommonInvoice $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - + if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) { $this->fetchPreviousNextSituationInvoice(); @@ -1521,9 +1522,9 @@ class Facture extends CommonInvoice $invoice = new Facture($this->db); if ($invoice->fetch($objp->rowid) > 0) { - if ($objp->situation_counter < $this->situation_counter + if ($objp->situation_counter < $this->situation_counter || ($objp->situation_counter == $this->situation_counter && $objp->rowid < $this->id) // This case appear when there are credit notes - ) + ) { $this->tab_previous_situation_invoice[] = $invoice; } @@ -3501,7 +3502,7 @@ class Facture extends CommonInvoice $return = array(); - + $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, f.type, f.paye, pf.fk_paiement"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; @@ -3513,7 +3514,7 @@ class Facture extends CommonInvoice // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir - + if($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE){ // Select the last situation invoice $sqlSit = 'SELECT MAX(fs.rowid)'; @@ -3529,7 +3530,7 @@ class Facture extends CommonInvoice { $sql.= " AND f.type != ".self::TYPE_SITUATION ; // Type non 5 si facture non avoir } - + if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; $sql.= " ORDER BY f.facnumber"; @@ -3999,9 +4000,10 @@ class Facture extends CommonInvoice * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref + * @param null|array $moreparams Array to provide more information * @return int <0 if KO, >0 if OK */ - public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) + public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null) { global $conf,$langs; @@ -4020,7 +4022,7 @@ class Facture extends CommonInvoice $modelpath = "core/modules/facture/doc/"; - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } /** diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 371dd75a8e2..646be9a3f92 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1,6 +1,7 @@ * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2018 Juanjo Menent * * 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 @@ -610,6 +611,13 @@ if ($massaction == 'confirm_createbills') { $fk_parent_line = 0; } + + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + $lines[$i]->fetch_optionals($lines[$i]->rowid); + $array_options = $lines[$i]->array_options; + } + $result = $objecttmp->addline( $desc, $lines[$i]->subprice, @@ -634,7 +642,8 @@ if ($massaction == 'confirm_createbills') $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, - $lines[$i]->label + $lines[$i]->label, + $array_options ); if ($result > 0) { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index ae2d88d2b6f..dbdb7edf760 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -541,7 +541,7 @@ class FormFile $modellist=ModelePDFCards::liste_modeles($this->db); } } - elseif ($modulepart == 'agenda') + elseif ($modulepart == 'agenda' || $modulepart == 'actions') { if (is_array($genallowed)) $modellist=$genallowed; else @@ -581,7 +581,7 @@ class FormFile $modellist=ModelePDFUserGroup::liste_modeles($this->db); } } - else //if ($modulepart != 'agenda') + else { // For normalized standard modules $file=dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 03beab47323..2b54e444ca8 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -4,6 +4,7 @@ * Copyright (C) 2012-2015 Juanjo Menent * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Marcos García + * Copyright (C) 2018 Ferran Marcet * * 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 @@ -805,7 +806,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/compta/facture/card.php?action=create",$langs->trans("NewBill"),1,$user->rights->facture->creer); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("List"),1,$user->rights->facture->lire, '', $mainmenu, 'customers_bills_list'); - if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills(|draft|notpaid|paid|canceled)$/', $leftmenu)) + if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills(|_draft|_notpaid|_paid|_canceled)$/', $leftmenu)) { $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_draft&search_status=0",$langs->trans("BillShortStatusDraft"),2,$user->rights->facture->lire); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_notpaid&search_status=1",$langs->trans("BillShortStatusNotPaid"),2,$user->rights->facture->lire); diff --git a/htdocs/modulebuilder/template/dev/codesniffer/DolibarrPSR2.xml b/htdocs/modulebuilder/template/dev/codesniffer/DolibarrPSR2.xml deleted file mode 100644 index 48d3f5d8d1d..00000000000 --- a/htdocs/modulebuilder/template/dev/codesniffer/DolibarrPSR2.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - The PSR2 standard with Dolibarr quirks. - - - - - - - - - \ No newline at end of file diff --git a/htdocs/modulebuilder/template/dev/git-hooks/README b/htdocs/modulebuilder/template/dev/git-hooks/README deleted file mode 100644 index a5d024c1bf5..00000000000 --- a/htdocs/modulebuilder/template/dev/git-hooks/README +++ /dev/null @@ -1,15 +0,0 @@ -# Git hooks - -Optional [GIT hooks](https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks) are provided. -These are just wrappers calling composer scripts. -They ensure best practices are followed during module development. - -Install: -```sh -composer git_hooks_install -``` - -Remove: -```sh -composer git_hooks_remove -``` diff --git a/htdocs/modulebuilder/template/dev/git-hooks/post-commit b/htdocs/modulebuilder/template/dev/git-hooks/post-commit deleted file mode 100755 index d44ff23047c..00000000000 --- a/htdocs/modulebuilder/template/dev/git-hooks/post-commit +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -composer git_post_commit diff --git a/htdocs/modulebuilder/template/dev/git-hooks/pre-commit b/htdocs/modulebuilder/template/dev/git-hooks/pre-commit deleted file mode 100755 index d8bd735325c..00000000000 --- a/htdocs/modulebuilder/template/dev/git-hooks/pre-commit +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -composer git_pre_commit diff --git a/htdocs/modulebuilder/template/dev/git-hooks/pre-push b/htdocs/modulebuilder/template/dev/git-hooks/pre-push deleted file mode 100755 index 61848c24831..00000000000 --- a/htdocs/modulebuilder/template/dev/git-hooks/pre-push +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -composer git_pre_push diff --git a/htdocs/modulebuilder/template/dev/img/README.md b/htdocs/modulebuilder/template/dev/img/README.md deleted file mode 100644 index f44c37f30c6..00000000000 --- a/htdocs/modulebuilder/template/dev/img/README.md +++ /dev/null @@ -1,53 +0,0 @@ -Source images -============= - -Used to generate icons and publication assets. - -Icons ------ - -### Dolibarr - -These resides in the [/img](../../img) directory. - -#### Small - -Required. -Name must begin by ```object_```. - -- Sample: ![object_mymodule.png](../../img/object_mymodule.png) [object_mymodule.png](../../img/object_mymodule.png) -- Size: 14×14 pixels -- Type: PNG - -#### Large - -Optional. - -- Sample: ![mymodule.png](../../img/mymodule.png) [mymodule.png](../../img/mymodule.png) -- Size: 32×32 pixels -- Type: PNG - -### Dolistore - -Designed to fit a 512×512 icon + publisher branding. - -- Size: 704×704 -- Type: PNG - -Export to 512×512 - -### Transifex - -- Size: 96×96 -- Type: PNG - -### Others - -To be on the safe side, you may also want to generate all popular sizes: -- 16×16 -- 32×32 -- 48×48 -- 64×64 -- 128×128 -- 256×256 -- 512×512 diff --git a/htdocs/modulebuilder/template/dev/img/gfdl-129x44.png b/htdocs/modulebuilder/template/dev/img/gfdl-129x44.png deleted file mode 100644 index f2bacfd179a..00000000000 Binary files a/htdocs/modulebuilder/template/dev/img/gfdl-129x44.png and /dev/null differ diff --git a/htdocs/modulebuilder/template/dev/img/gfdl-66x23.png b/htdocs/modulebuilder/template/dev/img/gfdl-66x23.png deleted file mode 100644 index b43479bf3c8..00000000000 Binary files a/htdocs/modulebuilder/template/dev/img/gfdl-66x23.png and /dev/null differ diff --git a/htdocs/modulebuilder/template/dev/img/gfdl-logo.svg b/htdocs/modulebuilder/template/dev/img/gfdl-logo.svg deleted file mode 100644 index a0daca0ead8..00000000000 --- a/htdocs/modulebuilder/template/dev/img/gfdl-logo.svg +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - GFDL - - - - - - - diff --git a/htdocs/modulebuilder/template/dev/img/gpl-v3-logo.svg b/htdocs/modulebuilder/template/dev/img/gpl-v3-logo.svg deleted file mode 100644 index 6754c994bda..00000000000 --- a/htdocs/modulebuilder/template/dev/img/gpl-v3-logo.svg +++ /dev/null @@ -1,389 +0,0 @@ - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/htdocs/modulebuilder/template/dev/img/gplv3-127x51.png b/htdocs/modulebuilder/template/dev/img/gplv3-127x51.png deleted file mode 100644 index 3e9136e6266..00000000000 Binary files a/htdocs/modulebuilder/template/dev/img/gplv3-127x51.png and /dev/null differ diff --git a/htdocs/modulebuilder/template/dev/img/gplv3-88x31.png b/htdocs/modulebuilder/template/dev/img/gplv3-88x31.png deleted file mode 100644 index ba78d4c4941..00000000000 Binary files a/htdocs/modulebuilder/template/dev/img/gplv3-88x31.png and /dev/null differ diff --git a/htdocs/modulebuilder/template/dev/img/mymodule.svg b/htdocs/modulebuilder/template/dev/img/mymodule.svg deleted file mode 100644 index f51ead1a94e..00000000000 --- a/htdocs/modulebuilder/template/dev/img/mymodule.svg +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - M - - diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 61b6316ca01..bb7f0a5d6bd 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -153,7 +153,7 @@ if (empty($reshook)) $db->begin(); $resql = $object->update($object->id, $user); - if (! $resql) + if (! $resql || $resql < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index fde0ed45288..f162aa9db40 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -49,6 +49,7 @@ $socid=0; //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $id,'projet&project'); +$hookmanager->initHooks(array('projectcontactcard','globalcard')); /* * Actions diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 8b791b7a9c7..dd19ceeb263 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -146,7 +146,7 @@ $morehtmlref.=''; if (! $user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); - $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; + $object->next_prev_filter=" te.rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index c922ca0514b..1ff9e22041d 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -290,7 +290,10 @@ if ( $resql ) print $langs->trans("OthersNotLinkedToThirdParty"); } print ''; - print ''.$obj->nb.''; + print ''; + if ($obj->socid) print ''.$obj->nb.''; + else print ''.$obj->nb.''; + print ''; print "\n"; $i++; diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index a2db82fc0ed..fad5466cb7f 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -303,6 +303,7 @@ if ($id > 0 || ! empty($ref)) // Project if (empty($withproject)) { + $result=$projectstatic->fetch($object->fk_project); $morehtmlref.='
'; $morehtmlref.=$langs->trans("Project").': '; $morehtmlref.=$projectstatic->getNomUrl(1); @@ -310,7 +311,11 @@ if ($id > 0 || ! empty($ref)) // Third party $morehtmlref.=$langs->trans("ThirdParty").': '; - $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); + if($projectstatic->socid>0) { + $projectstatic->fetch_thirdparty(); + $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); + } + $morehtmlref.='
'; } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 86a2027b3b7..2d99e7453df 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -577,7 +577,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $contactsoftask=$object->getListContactId('internal'); if (count($contactsoftask)>0) { - $userid=$contactsoftask[0]; + if(in_array($user->id, $contactsoftask)) $userid = $user->id; + else $userid=$contactsoftask[0]; print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsoftask, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToTheTask"), 'maxwidth200'); } else diff --git a/test/phpunit/AccountingAccount.php b/test/phpunit/AccountingAccount.php new file mode 100644 index 00000000000..ba7f567b4a0 --- /dev/null +++ b/test/phpunit/AccountingAccount.php @@ -0,0 +1,225 @@ + + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file test/phpunit/AccountingAccount.php + * \ingroup test + * \brief PHPUnit test + * \remarks To run this script as CLI: phpunit filename.php + */ + +global $conf,$user,$langs,$db; +//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver +//require_once 'PHPUnit/Autoload.php'; +require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/accountancy/class/accountingaccount.class.php'; + +if (empty($user->id)) { + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); +} +$conf->global->MAIN_DISABLE_ALL_MAILS=1; + + +/** + * Class for PHPUnit tests + * + * @backupGlobals disabled + * @backupStaticAttributes enabled + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + */ +class AccountingAccountTest extends PHPUnit_Framework_TestCase +{ + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; + + /** + * Constructor + * We save global variables into local variables + * + * @return AccountingAccountTest + */ + function __construct() + { + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + if (empty($conf->accounting->enabled)) { print __METHOD__." module accouting must be enabled.\n"; die(); } + + print __METHOD__."\n"; + } + + // tear down after class + public static function tearDownAfterClass() + { + global $conf,$user,$langs,$db; + $db->rollback(); + + print __METHOD__."\n"; + } + + /** + * Init phpunit tests + * + * @return void + */ + protected function setUp() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + print __METHOD__."\n"; + //print $db->getVersion()."\n"; + } + + /** + * End phpunit tests + * + * @return void + */ + protected function tearDown() + { + print __METHOD__."\n"; + } + + /** + * testAccountingAccountCreate + * + * @return void + */ + public function testAccountingAccountCreate() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new AccountingAccount($this->savdb); + $localobject->fk_pcg_version = 'PCG99-ABREGE'; + $localobject->account_category = 0; + $localobject->pcg_type = 'XXXXX'; + $localobject->pcg_subtype = 'XXXXX'; + $localobject->account_parent = 0; + $localobject->label = 'Account specimen'; + $localobject->active = 0; + $result=$localobject->create($user); + + $this->assertLessThan($result, 0); + print __METHOD__." result=".$result."\n"; + return $result; + } + + /** + * testAccountingAccountFetch + * + * @param int $id Id order + * @return AccountingAccount + * + * @depends testAccountingAccountCreate + * The depends says test is run only if previous is ok + */ + public function testAccountingAccountFetch($id) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new AccountingAccount($this->savdb); + $result=$localobject->fetch($id); + + $this->assertLessThan($result, 0); + print __METHOD__." id=".$id." result=".$result."\n"; + return $localobject; + } + + /** + * testAccountingAccountUpdate + * + * @param Object $localobject AccountingAccount + * @return AccountingAccount + * + * @depends testAccountingAccountFetch + * The depends says test is run only if previous is ok + */ + public function testAccountingAccountUpdate($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject->label='New label'; + $result=$localobject->update($user); + + $this->assertLessThan($result, 0); + print __METHOD__." id=".$id." result=".$result."\n"; + return $localobject->id; + } + + /** + * testAccountingAccountDelete + * + * @param int $id Id of order + * @return void + * + * @depends testAccountingAccountUpdate + * The depends says test is run only if previous is ok + */ + public function testAccountingAccountDelete($id) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new AccountingAccount($this->savdb); + $result=$localobject->fetch($id); + $result=$localobject->delete($user); + + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); + return $result; + } + +} diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index a309f850fcf..2785005dd93 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -202,6 +202,9 @@ class AllTests require_once dirname(__FILE__).'/CategorieTest.php'; $suite->addTestSuite('CategorieTest'); + require_once dirname(__FILE__).'/AccountingAccountTest.php'; + $suite->addTestSuite('AccountingAccountTest'); + require_once dirname(__FILE__).'/RestAPIUserTest.php'; $suite->addTestSuite('RestAPIUserTest'); diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index 1d0e4fbf616..443bd1d1932 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -174,7 +174,7 @@ class CommandeTest extends PHPUnit_Framework_TestCase * @depends testCommandeFetch * The depends says test is run only if previous is ok */ - public function testCommandUpdate($localobject) + public function testCommandeUpdate($localobject) { global $conf,$user,$langs,$db; $conf=$this->savconf; @@ -196,7 +196,7 @@ class CommandeTest extends PHPUnit_Framework_TestCase * @param Object $localobject Order * @return Commande * - * @depends testCommandUpdate + * @depends testCommandeUpdate * The depends says test is run only if previous is ok */ public function testCommandeValid($localobject)