diff --git a/ChangeLog b/ChangeLog index 8d8ff361b59..0aaf9c1feb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -69,6 +69,7 @@ For users: - New: [ task #741 ] Add intervention box. - New: [ task #826 ] Optionnal increase stock when deleting an invoice already validated. - New: [ task #823 ] Shipping_validate email notification. +- New: [ task #900 ] Review code of ficheinter.class.php For translators: - Update language files. @@ -112,6 +113,7 @@ WARNING: If you used external modules, some of them may need to be upgraded due - Fix: Can't reset payment due date - Fix: Orderstoinvoice didn't act as expected when no order was checked - Fix: Bad link to all proposals into Third party card if customer is prospect +- Fix: Some bugs on withdrawal rejects - Fix: [ bug #774 ] Bug on creating event with box "all day" crossed - Fix: [ bug #787 ] Invoice supplier box incorrect tooltip when delay on payment - Fix: [ bug #789 ] VAT not being calculated in POS @@ -131,7 +133,7 @@ WARNING: If you used external modules, some of them may need to be upgraded due - Fix: [ bug #865 ] Dolibarr navigation array in project/task do not work - Fix: [ bug #866 ] Standing order from an invoice suggests invoice total amount instead of remaining to pay - Fix: [ bug #788 ] Date of linked interventions are not shown - +- Fix: external users should not see costprice and margin infos ***** ChangeLog for 3.3.1 compared to 3.3 ***** diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index d02db671ed6..04f9b61d5a5 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -455,7 +455,7 @@ print '
'; print ''; print ''; print ''; -print $langs->trans("FreeLegalTextOnInvoices").' ('.$langs->trans("AddCRIfTooLong").')
'; +print $langs->trans("FreeLegalTextOnOrders").' ('.$langs->trans("AddCRIfTooLong").')
'; print ''; print ''; print ''; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index f39cbd9059b..5fbb94a5517 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1,34 +1,34 @@ * Copyright (C) 2004-2013 Laurent Destailleur -* Copyright (C) 2004 Eric Seigne -* Copyright (C) 2005 Marc Barilley / Ocebo -* Copyright (C) 2005-2012 Regis Houssin -* Copyright (C) 2006 Andre Cianfarani -* Copyright (C) 2010-2013 Juanjo Menent -* Copyright (C) 2010-2011 Philippe Grand -* Copyright (C) 2012 Christophe Battarel -* Copyright (C) 2013 Florian Henry -* -* 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 . -*/ + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2010-2013 Juanjo Menent + * Copyright (C) 2010-2011 Philippe Grand + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2013 Florian Henry + * + * 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/comm/propal.php -* \ingroup propale -* \brief Page of commercial proposals card and list -*/ + * \ingroup propale + * \brief Page of commercial proposals card and list + */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -638,6 +638,7 @@ else if ($action == "addline" && $user->rights->propal->creer) $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):''))); $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx')?GETPOST('tva_tx'):0); + $predef=((! empty($idprod) && $conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : ''); if (empty($idprod) && GETPOST('type') < 0) { @@ -1968,7 +1969,7 @@ else // Show object lines $result = $object->getLinesArray(); if (! empty($object->lines)) - $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid); + $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1); // Form to add new line if ($object->statut == 0 && $user->rights->propal->creer) diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index 5911058cdbc..54ddc846272 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -26,6 +26,7 @@ include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; +include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; /** @@ -49,14 +50,14 @@ class PropaleStats extends Stats * * @param DoliDB $db Database handler * @param int $socid Id third party - * @param int $userid Id user for filter + * @param int $userid Id user for filter (creation user) */ function __construct($db, $socid=0, $userid=0) { global $user, $conf; $this->db = $db; - $this->socid = $socid; + $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; $object=new Propal($this->db); @@ -66,7 +67,7 @@ class PropaleStats extends Stats $this->field='total_ht'; - $this->where.= " fk_statut > 0"; + $this->where.= " p.fk_statut > 0"; $this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if($this->socid) @@ -79,7 +80,7 @@ class PropaleStats extends Stats /** * Return propals number by month for a year - * + * * @param int $year year for stats * @return array array with number by month */ @@ -90,7 +91,7 @@ class PropaleStats extends Stats $sql = "SELECT date_format(p.datep,'%m') as dm, count(*)"; $sql.= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(p.datep,'%Y') = '".$year."'"; + $sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -100,7 +101,7 @@ class PropaleStats extends Stats /** * Return propals number by year - * + * * @return array array with number by year * */ @@ -117,7 +118,7 @@ class PropaleStats extends Stats return $this->_getNbByYear($sql); } - + /** * Return the propals amount by month for a year * @@ -131,14 +132,14 @@ class PropaleStats extends Stats $sql = "SELECT date_format(p.datep,'%m') as dm, sum(p.".$this->field.")"; $sql.= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(p.datep,'%Y') = '".$year."'"; + $sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); return $this->_getAmountByMonth($year, $sql); } - + /** * Return the propals amount average by month for a year * @@ -152,7 +153,7 @@ class PropaleStats extends Stats $sql = "SELECT date_format(p.datep,'%m') as dm, avg(p.".$this->field.")"; $sql.= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(p.datep,'%Y') = '".$year."'"; + $sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -162,7 +163,7 @@ class PropaleStats extends Stats /** * Return nb, total and average - * + * * @return array Array of values */ function getAllByYear() diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index ef979275101..a4b7ad69d24 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -31,8 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); -$userid=GETPOST('userid','int'); if ($userid < 0) $userid=0; -$socid=GETPOST('socid','int'); if ($socid < 0) $socid=0; +$userid=GETPOST('userid','int'); +$socid=GETPOST('socid','int'); // Security check if ($user->societe_id > 0) { @@ -63,7 +63,7 @@ $dir=$conf->propal->dir_temp; dol_mkdir($dir); -$stats = new PropaleStats($db, $socid, $userid); +$stats = new PropaleStats($db, $socid, ($userid>0?$userid:0)); // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear); @@ -233,12 +233,13 @@ print '
'; print $form->select_company($socid,'socid',$filter,1); print ''; // User - print ''.$langs->trans("User").'/'.$langs->trans("SalesRepresentative").''; + print ''.$langs->trans("CreatedBy").''; print $form->select_users($userid,'userid',1); print ''; // Year print ''.$langs->trans("Year").''; if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; + if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear; arsort($arrayyears); print $form->selectarray('year',$arrayyears,$year,0); print ''; diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index fba88538145..56c69d84541 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -26,6 +26,7 @@ include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; +include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; /** @@ -49,7 +50,7 @@ class CommandeStats extends Stats * @param DoliDB $db Database handler * @param int $socid Id third party for filter * @param string $mode Option - * @param int $userid Id user for filter + * @param int $userid Id user for filter (creation user) */ function __construct($db, $socid, $mode, $userid=0) { @@ -57,7 +58,7 @@ class CommandeStats extends Stats $this->db = $db; - $this->socid = $socid; + $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; if ($mode == 'customer') @@ -100,7 +101,7 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%m') as dm, count(*) nb"; $sql.= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(c.date_commande,'%Y') = '".$year."'"; + $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -143,7 +144,7 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%m') as dm, sum(c.".$this->field.")"; $sql.= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(c.date_commande,'%Y') = '".$year."'"; + $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -165,7 +166,7 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%m') as dm, avg(c.".$this->field.")"; $sql.= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(c.date_commande,'%Y') = '".$year."'"; + $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index cb7e2034275..07dfb674c74 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -36,8 +36,8 @@ $mode=GETPOST("mode")?GETPOST("mode"):'customer'; if ($mode == 'customer' && ! $user->rights->commande->lire) accessforbidden(); if ($mode == 'supplier' && ! $user->rights->fournisseur->commande->lire) accessforbidden(); -$userid=GETPOST('userid','int'); if ($userid < 0) $userid=0; -$socid=GETPOST('socid','int'); if ($socid < 0) $socid=0; +$userid=GETPOST('userid','int'); +$socid=GETPOST('socid','int'); // Security check if ($user->societe_id > 0) { @@ -77,7 +77,7 @@ print_fiche_titre($title); dol_mkdir($dir); -$stats = new CommandeStats($db, $socid, $mode, $userid); +$stats = new CommandeStats($db, $socid, $mode, ($userid>0?$userid:0)); // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear); @@ -255,12 +255,13 @@ print '
'; print $form->select_company($socid,'socid',$filter,1); print ''; // User - print ''.$langs->trans("User").'/'.$langs->trans("SalesRepresentative").''; + print ''.$langs->trans("CreatedBy").''; print $form->select_users($userid,'userid',1); print ''; // Year print ''.$langs->trans("Year").''; if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; + if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear; arsort($arrayyears); print $form->selectarray('year',$arrayyears,$year,0); print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 4e25703535c..250605f386b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3292,7 +3292,7 @@ else if ($id > 0 || ! empty($ref)) foreach($extrafields->attribute_label as $key=>$label) { if ($action == 'edit_extras') { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); } else { $value=$object->array_options["options_".$key]; } diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index f99b8f3bb27..0fe45fc6c66 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -48,12 +48,12 @@ class FactureStats extends Stats * @param DoliDB $db Database handler * @param int $socid Id third party * @param string $mode Option - * @param int $userid Id user for filter + * @param int $userid Id user for filter (creation user) * @return FactureStats */ function __construct($db, $socid, $mode, $userid=0) { - global $conf; + global $user, $conf; $this->db = $db; $this->socid = ($socid > 0 ? $socid : 0); @@ -62,41 +62,25 @@ class FactureStats extends Stats if ($mode == 'customer') { $object=new Facture($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element; + $this->from = MAIN_DB_PREFIX.$object->table_element." as f"; $this->field='total'; } if ($mode == 'supplier') { $object=new FactureFournisseur($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element; + $this->from = MAIN_DB_PREFIX.$object->table_element." as f"; $this->field='total_ht'; } - $this->where = " fk_statut > 0"; - $this->where.= " AND entity = ".$conf->entity; - if ($mode == 'customer') $this->where.=" AND (fk_statut <> 3 OR close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons) + $this->where = " f.fk_statut > 0"; + $this->where.= " AND f.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($mode == 'customer') $this->where.=" AND (f.fk_statut <> 3 OR f.close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons) if ($this->socid) { - $this->where.=" AND fk_soc = ".$this->socid; + $this->where.=" AND f.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; - } - - - /** - * Renvoie le nombre de facture par annee - * - * @return array Array of values - */ - function getNbByYear() - { - $sql = "SELECT YEAR(datef) as dm, COUNT(*)"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm','DESC'); - - return $this->_getNbByYear($sql); + if ($this->userid > 0) $this->where.=' AND f.fk_user_author = '.$this->userid; } @@ -108,9 +92,10 @@ class FactureStats extends Stats */ function getNbByMonth($year) { - $sql = "SELECT MONTH(datef) as dm, COUNT(*)"; + $sql = "SELECT MONTH(f.datef) as dm, COUNT(*)"; $sql.= " FROM ".$this->from; - $sql.= " WHERE datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -121,6 +106,24 @@ class FactureStats extends Stats } + /** + * Renvoie le nombre de facture par annee + * + * @return array Array of values + */ + function getNbByYear() + { + $sql = "SELECT YEAR(f.datef) as dm, COUNT(*)"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY dm"; + $sql.= $this->db->order('dm','DESC'); + + return $this->_getNbByYear($sql); + } + + /** * Renvoie le montant de facture par mois pour une annee donnee * @@ -129,9 +132,10 @@ class FactureStats extends Stats */ function getAmountByMonth($year) { - $sql = "SELECT date_format(datef,'%m') as dm, SUM(".$this->field.")"; + $sql = "SELECT date_format(datef,'%m') as dm, SUM(f.".$this->field.")"; $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(datef,'%Y') = '".$year."'"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -149,9 +153,10 @@ class FactureStats extends Stats */ function getAverageByMonth($year) { - $sql = "SELECT date_format(datef,'%m') as dm, AVG(".$this->field.")"; + $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")"; $sql.= " FROM ".$this->from; - $sql.= " WHERE datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -166,8 +171,9 @@ class FactureStats extends Stats */ function getAllByYear() { - $sql = "SELECT date_format(datef,'%Y') as year, COUNT(*) as nb, SUM(".$this->field.") as total, AVG(".$this->field.") as avg"; + $sql = "SELECT date_format(datef,'%Y') as year, COUNT(*) as nb, SUM(f.".$this->field.") as total, AVG(f.".$this->field.") as avg"; $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE ".$this->where; $sql.= " GROUP BY year"; $sql.= $this->db->order('year','DESC'); diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 0b4a341e1c2..4abff5b63be 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -233,12 +233,13 @@ print '
'; print $form->select_company($socid,'socid',$filter,1); print ''; // User - print ''.$langs->trans("User").'/'.$langs->trans("SalesRepresentative").''; + print ''.$langs->trans("CreatedBy").''; print $form->select_users($userid,'userid',1); print ''; // Year print ''.$langs->trans("Year").''; if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; + if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear; arsort($arrayyears); print $form->selectarray('year',$arrayyears,$year,0); print ''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index dcbd404a3e0..a325d7aa2d6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -44,7 +44,7 @@ abstract class CommonObject public $civility_id; public $array_options=array(); - + public $linkedObjectsIds; public $linkedObjects; @@ -2027,7 +2027,7 @@ abstract class CommonObject $optionsArray = $extrafields->fetch_name_optionals_label($this->table_element); } - + // Request to get complementary values if (count($optionsArray) > 0) { @@ -2057,7 +2057,7 @@ abstract class CommonObject } } } - + $this->db->free($resql); } else @@ -2712,7 +2712,7 @@ abstract class CommonObject */ function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) { - global $conf,$langs,$hookmanager; + global $conf,$langs,$user,$hookmanager; print ''; @@ -2735,7 +2735,8 @@ abstract class CommonObject // Reduction short print ''.$langs->trans('ReductionShort').''; - if (! empty($conf->margin->enabled)) { + if (! empty($conf->margin->enabled) && empty($user->societe_id)) + { if ($conf->global->MARGIN_TYPE == "1") print ''.$langs->trans('BuyingPrice').''; else @@ -3159,11 +3160,16 @@ abstract class CommonObject } /** + * displayMarginInfos * - * @param string $force_price + * @param string $force_price Force price + * @return void */ - function displayMarginInfos($force_price=false) { - global $langs, $conf; + function displayMarginInfos($force_price=false) + { + global $langs, $conf, $user; + + if (! empty($user->societe_id)) return; $marginInfo = $this->getMarginInfos($force_price); @@ -3215,6 +3221,5 @@ abstract class CommonObject print ''; print ''; } - } ?> diff --git a/htdocs/core/modules/modMargin.class.php b/htdocs/core/modules/modMargin.class.php index e6235572c1a..47ae79bf7df 100644 --- a/htdocs/core/modules/modMargin.class.php +++ b/htdocs/core/modules/modMargin.class.php @@ -80,7 +80,7 @@ class modMargin extends DolibarrModules // New pages on tabs $this->tabs = array( 'product:+margin:Margins:margins:$conf->margin->enabled:/margin/tabs/productMargins.php?id=__ID__', - 'thirdparty:+margin:Margins:margins:$conf->margin->enabled:/margin/tabs/thirdpartyMargins.php?socid=__ID__' + 'thirdparty:+margin:Margins:margins:$conf->margin->enabled && empty($user->societe_id):/margin/tabs/thirdpartyMargins.php?socid=__ID__' ); diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php index 328b8d9a69b..1ee1a63ea78 100644 --- a/htdocs/core/tpl/freeproductline_create.tpl.php +++ b/htdocs/core/tpl/freeproductline_create.tpl.php @@ -26,7 +26,7 @@ $usemargins=0; if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1; - + ?> @@ -118,13 +118,13 @@ if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($ob -service->enabled) && $dateSelector) +service->enabled) && $dateSelector) { if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; else $colspan = 9; - - if (! empty($usemargins)) + + if (! empty($usemargins)) { $colspan++; // For the buying price if($conf->global->DISPLAY_MARGIN_RATES) $colspan++; @@ -142,7 +142,7 @@ if (! empty($conf->service->enabled) && $dateSelector) $form->select_date('',"date_end_sl",$usehm,$usehm,1,"addline_sl"); } else - { + { echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; echo $form->select_date('','date_start',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addproduct"); echo ' '.$langs->trans('to').' '; @@ -151,9 +151,9 @@ if (! empty($conf->service->enabled) && $dateSelector) ?> - - \ No newline at end of file + diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index bef263763de..58710d9f0e4 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -136,22 +136,19 @@ if ($forgetpasslink || $helpcenterlink) if ($forgetpasslink) { echo '('; echo $langs->trans('PasswordForgotten'); - if (! $helpcenterlink) { - echo ')'; - } + if (! $helpcenterlink) echo ')'; echo ''; } + if ($forgetpasslink && $helpcenterlink) echo ' - '; + if ($helpcenterlink) { $url=DOL_URL_ROOT.'/support/index.php'.$moreparam; if (! empty($conf->global->MAIN_HELPCENTER_LINKTOUSE)) $url=$conf->global->MAIN_HELPCENTER_LINKTOUSE; echo ''; - if ($forgetpasslink) { - echo ' - '; - } else { - echo '('; - } - echo $langs->trans('NeedHelpCenter').')'; + if (! $forgetpasslink) echo '('; + echo $langs->trans('NeedHelpCenter'); + echo ')'; } echo '
'; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 4fd05e4679c..b2e777660f7 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -119,7 +119,7 @@   margin->enabled)) { + if (! empty($conf->margin->enabled) && empty($user->societe_id)) { ?> pa_ht); ?> global->DISPLAY_MARGIN_RATES)) {?> diff --git a/htdocs/core/tpl/predefinedproductline_create.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php index b435d40be64..32d3366f8ad 100644 --- a/htdocs/core/tpl/predefinedproductline_create.tpl.php +++ b/htdocs/core/tpl/predefinedproductline_create.tpl.php @@ -60,7 +60,7 @@ jQuery(document).ready(function() { trans('ReductionShort'); ?> global->DISPLAY_MARGIN_RATES)) $colspan++; if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; @@ -74,7 +74,7 @@ if (! empty($usemargins)) ?>   @@ -110,7 +110,7 @@ if (! empty($usemargins)) % global->DISPLAY_MARGIN_RATES)) $colspan++; if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; @@ -127,8 +127,8 @@ if (! empty($usemargins)) -service->enabled) && $dateSelector) +service->enabled) && $dateSelector) { if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; else $colspan = 9; @@ -148,7 +148,7 @@ if (! empty($conf->service->enabled) && $dateSelector) print $langs->trans("DateStartPlanned").' '; $form->select_date('',"date_start",$usehm,$usehm,1,"addline"); print '   '.$langs->trans("DateEndPlanned").' '; - $form->select_date('',"date_end",$usehm,$usehm,1,"addline"); + $form->select_date('',"date_end",$usehm,$usehm,1,"addline"); } else { @@ -161,13 +161,13 @@ if (! empty($conf->service->enabled) && $dateSelector) - \ No newline at end of file + diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index c54575efde8..476e4f3c0a3 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1,28 +1,28 @@ * Copyright (C) 2004-2010 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011-2013 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 - * 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 . - */ +* Copyright (C) 2005-2012 Regis Houssin +* Copyright (C) 2011-2013 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 +* 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/fichinter/class/fichinter.class.php - * \ingroup ficheinter - * \brief Fichier de la classe des gestion des fiches interventions - */ +* \ingroup ficheinter +* \brief Fichier de la classe des gestion des fiches interventions +*/ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; @@ -61,7 +61,7 @@ class Fichinter extends CommonObject * Constructor * * @param DoliDB $db Database handler - */ + */ function __construct($db) { $this->db = $db; @@ -160,22 +160,23 @@ class Fichinter extends CommonObject if ($result) { $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter"); - + if ($this->id) { $this->ref='(PROV'.$this->id.')'; $sql = 'UPDATE '.MAIN_DB_PREFIX."fichinter SET ref='".$this->ref."' WHERE rowid=".$this->id; - + dol_syslog(get_class($this)."::create sql=".$sql); $resql=$this->db->query($sql); if (! $resql) $error++; } - // Add linked object - if (! $error && $this->origin && $this->origin_id) - { - $ret = $this->add_object_linked(); - if (! $ret) dol_print_error($this->db); - } + // Add linked object + if (! $error && $this->origin && $this->origin_id) + { + $ret = $this->add_object_linked(); + if (! $ret) dol_print_error($this->db); + } + if (! $notrigger) { @@ -240,7 +241,7 @@ class Fichinter extends CommonObject dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); if ($this->db->query($sql)) { - + if (! $notrigger) { // Appel des triggers @@ -252,7 +253,7 @@ class Fichinter extends CommonObject } // Fin appel triggers } - + $this->db->commit(); return 1; } @@ -318,7 +319,7 @@ class Fichinter extends CommonObject /* * Lines - */ + */ $result=$this->fetch_lines(); if ($result < 0) { @@ -389,7 +390,7 @@ class Fichinter extends CommonObject $this->db->begin(); $now=dol_now(); - + // Define new ref if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) { @@ -669,8 +670,8 @@ class Fichinter extends CommonObject $this->db->begin(); // Delete linked object - $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; // Delete linked contacts $res = $this->delete_linked_contact(); @@ -735,8 +736,9 @@ class Fichinter extends CommonObject if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Fin appel triggers } + $this->db->commit(); return 1; } @@ -865,11 +867,11 @@ class Fichinter extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void */ function initAsSpecimen() { @@ -894,7 +896,7 @@ class Fichinter extends CommonObject $line->desc=$langs->trans("Description")." ".$xnbp; $line->datei=($now-3600*(1+$xnbp)); $line->duration=600; - $line->fk_fichinter=0; + $line->fk_fichinter=0; $this->lines[$xnbp]=$line; $xnbp++; @@ -1021,7 +1023,7 @@ class FichinterLigne function insert($user, $notrigger=0) { global $langs,$conf; - + dol_syslog("FichinterLigne::insert rang=".$this->rang); $this->db->begin(); @@ -1064,7 +1066,7 @@ class FichinterLigne if ($result > 0) { $this->rang=$rangToUse; - + if (! $notrigger) { // Appel des triggers @@ -1077,7 +1079,7 @@ class FichinterLigne // Fin appel triggers } } - + if (!$error) { $this->db->commit(); return $result; @@ -1108,7 +1110,7 @@ class FichinterLigne function update($user,$notrigger=0) { global $langs,$conf; - + $this->db->begin(); // Mise a jour ligne en base @@ -1126,7 +1128,7 @@ class FichinterLigne $result=$this->update_total(); if ($result > 0) { - + if (! $notrigger) { // Appel des triggers @@ -1139,9 +1141,9 @@ class FichinterLigne // Fin appel triggers } } - + if (!$error) - { + { $this->db->commit(); return $result; } @@ -1224,7 +1226,7 @@ class FichinterLigne function deleteline($user,$notrigger=0) { global $langs,$conf; - + if ($this->statut == 0) { dol_syslog(get_class($this)."::deleteline lineid=".$this->rowid); @@ -1240,7 +1242,7 @@ class FichinterLigne if ($result > 0) { $this->db->commit(); - + if (! $notrigger) { // Appel des triggers @@ -1252,7 +1254,7 @@ class FichinterLigne } // Fin appel triggers } - + return $result; } else diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index bf781349549..67b3a93b4ee 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -1,29 +1,29 @@ * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011-2013 Juanjo Menent - * Copyright (C) 2013 Florian Henry - * - * 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 . - */ +* Copyright (C) 2005-2012 Regis Houssin +* Copyright (C) 2011-2013 Juanjo Menent +* Copyright (C) 2013 Florian Henry +* +* 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/fichinter/fiche.php - * \brief Fichier fiche intervention - * \ingroup ficheinter - */ +* \brief Fichier fiche intervention +* \ingroup ficheinter +*/ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -33,12 +33,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } if (! empty($conf->global->FICHEINTER_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.".php")) { - require_once DOL_DOCUMENT_ROOT ."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.'.php'; + require_once DOL_DOCUMENT_ROOT ."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.'.php'; } require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -74,62 +74,62 @@ $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); /* * Actions - */ +*/ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); + $object->fetch($id); + $object->fetch_thirdparty(); - $result = $object->setValid($user); - if ($result >= 0) - { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result=fichinter_create($db, $object, GETPOST('model','alpha'), $outputlangs); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - else - { - $mesg='
'.$object->error.'
'; - } + $result = $object->setValid($user); + if ($result >= 0) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result=fichinter_create($db, $object, GETPOST('model','alpha'), $outputlangs); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + else + { + $mesg='
'.$object->error.'
'; + } } else if ($action == 'confirm_modify' && $confirm == 'yes' && $user->rights->ficheinter->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); + $object->fetch($id); + $object->fetch_thirdparty(); - $result = $object->setDraft($user); - if ($result >= 0) - { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result=fichinter_create($db, $object, (!GETPOST('model','alpha'))?$object->model:GETPOST('model','apha'), $outputlangs); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - else - { - $mesg='
'.$object->error.'
'; - } + $result = $object->setDraft($user); + if ($result >= 0) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result=fichinter_create($db, $object, (!GETPOST('model','alpha'))?$object->model:GETPOST('model','apha'), $outputlangs); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + else + { + $mesg='
'.$object->error.'
'; + } } else if ($action == 'add' && $user->rights->ficheinter->creer) @@ -137,26 +137,27 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) $object->socid = $socid; $object->duree = GETPOST('duree','int'); $object->fk_project = GETPOST('projectid','int'); + $object->author = $user->id; $object->description = GETPOST('description'); $object->ref = $ref; $object->modelpdf = GETPOST('model','alpha'); $object->note_private = GETPOST('note_private'); $object->note_public = GETPOST('note_public'); - if ($object->socid > 0) - { - // If creation from another object of another module (Example: origin=propal, originid=1) - if (!empty($origin) && !empty($originid) ) - { - // Parse element/subelement (ex: project_task) - $element = $subelement = $_POST['origin']; - if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs)) - { - $element = $regs[1]; - $subelement = $regs[2]; - } + if ($object->socid > 0) + { + // If creation from another object of another module (Example: origin=propal, originid=1) + if (!empty($origin) && !empty($originid) ) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = $_POST['origin']; + if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } - // For compatibility + // For compatibility if ($element == 'order') { $element = $subelement = 'commande'; } @@ -167,39 +168,39 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) $element = $subelement = 'contrat'; } - $object->origin = $origin; - $object->origin_id = $originid; + $object->origin = $origin; + $object->origin_id = $originid; - // Possibility to add external linked objects with hooks - $object->linked_objects[$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) - { - $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); - } + // Possibility to add external linked objects with hooks + $object->linked_objects[$object->origin] = $object->origin_id; + if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) + { + $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); + } - $id = $object->create($user); + $id = $object->create(); - if ($id > 0) - { - dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); + if ($id > 0) + { + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); - $classname = ucfirst($subelement); - $srcobject = new $classname($db); + $classname = ucfirst($subelement); + $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); - $result=$srcobject->fetch($object->origin_id); - if ($result > 0) - { - $srcobject->fetch_thirdparty(); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); + $result=$srcobject->fetch($object->origin_id); + if ($result > 0) + { + $srcobject->fetch_thirdparty(); $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); + if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); - $fk_parent_line=0; - $num=count($lines); + $fk_parent_line=0; + $num=count($lines); - for ($i=0;$i<$num;$i++) - { - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + for ($i=0;$i<$num;$i++) + { + $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); if ($product_type == 1) { //only services // service prédéfini @@ -240,11 +241,11 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) $desc .= ($lines[$i]->desc && $lines[$i]->desc!=$lines[$i]->libelle)?'
'.dol_htmlentitiesbr($lines[$i]->desc):''; } else { - $desc = dol_htmlentitiesbr($lines[$i]->desc); - $desc .= ' ('.$langs->trans('Quantity').': '.$lines[$i]->qty.')'; - } + $desc = dol_htmlentitiesbr($lines[$i]->desc); + $desc .= ' ('.$langs->trans('Quantity').': '.$lines[$i]->qty.')'; + } $timearray=dol_getdate(mktime()); - $date_intervention=dol_mktime(0,0,0,$timearray['mon'],$timearray['mday'],$timearray['year']); + $date_intervention=dol_mktime(0,0,0,$timearray['mon'],$timearray['mday'],$timearray['year']); $duration = 3600; $result = $object->addline( @@ -255,14 +256,14 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) $duration ); - if ($result < 0) - { - $error++; - break; - } + if ($result < 0) + { + $error++; + break; + } } - } + } } else @@ -301,13 +302,13 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) else if ($action == 'update' && $user->rights->ficheinter->creer) { - $object->fetch($id); + $object->fetch($id); - $object->socid = $socid; - $object->fk_project = GETPOST('projectid','int'); - $object->author = $user->id; - $object->description = GETPOST('description','alpha'); - $object->ref = $ref; + $object->socid = $socid; + $object->fk_project = GETPOST('projectid','int'); + $object->author = $user->id; + $object->description = GETPOST('description','alpha'); + $object->ref = $ref; $result=$object->update($user); if ($result<0) { @@ -317,34 +318,34 @@ else if ($action == 'update' && $user->rights->ficheinter->creer) /* * Build doc - */ +*/ else if ($action == 'builddoc' && $user->rights->ficheinter->creer) // En get ou en post { - $object->fetch($id); - $object->fetch_thirdparty(); - $object->fetch_lines(); + $object->fetch($id); + $object->fetch_thirdparty(); + $object->fetch_lines(); - if (GETPOST('model','alpha')) - { - $object->setDocModel($user, GETPOST('model','alpha')); - } + if (GETPOST('model','alpha')) + { + $object->setDocModel($user, GETPOST('model','alpha')); + } - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result=fichinter_create($db, $object, GETPOST('model','alpha'), $outputlangs); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result=fichinter_create($db, $object, GETPOST('model','alpha'), $outputlangs); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } } // Remove file in doc form @@ -368,9 +369,9 @@ else if ($action == 'remove_file') // Set into a project else if ($action == 'classin' && $user->rights->ficheinter->creer) { - $object->fetch($id); - $result=$object->setProject(GETPOST('projectid','int')); - if ($result < 0) dol_print_error($db,$object->error); + $object->fetch($id); + $result=$object->setProject(GETPOST('projectid','int')); + if ($result < 0) dol_print_error($db,$object->error); } else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer) @@ -382,52 +383,52 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fich setEventMessage($object->error,'errors'); } - header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter'); - exit; + header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter'); + exit; } else if ($action == 'setdescription' && $user->rights->ficheinter->creer) { - $object->fetch($id); - $result=$object->set_description($user,GETPOST('description')); - if ($result < 0) dol_print_error($db,$object->error); + $object->fetch($id); + $result=$object->set_description($user,GETPOST('description')); + if ($result < 0) dol_print_error($db,$object->error); } else if ($action == 'setnote_public' && $user->rights->ficheinter->creer) { - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); + if ($result < 0) dol_print_error($db,$object->error); } else if ($action == 'setnote_private' && $user->rights->ficheinter->creer) { - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES), '_private'); - if ($result < 0) dol_print_error($db,$object->error); + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES), '_private'); + if ($result < 0) dol_print_error($db,$object->error); } // Add line else if ($action == "addline" && $user->rights->ficheinter->creer) { - if (!GETPOST('np_desc')) - { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'
'; - $error++; - } - if (!GETPOST('durationhour','int') && !GETPOST('durationmin','int')) - { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Duration")).'
'; - $error++; - } - if (! $error) - { + if (!GETPOST('np_desc')) + { + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'
'; + $error++; + } + if (!GETPOST('durationhour','int') && !GETPOST('durationmin','int')) + { + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Duration")).'
'; + $error++; + } + if (! $error) + { $db->begin(); - $ret=$object->fetch($id); - $object->fetch_thirdparty(); + $ret=$object->fetch($id); + $object->fetch_thirdparty(); - $desc=GETPOST('np_desc'); - $date_intervention = dol_mktime(GETPOST('dihour','int'), GETPOST('dimin','int'), 0, GETPOST('dimonth','int'), GETPOST('diday','int'), GETPOST('diyear','int')); - $duration = convertTime2Seconds(GETPOST('durationhour','int'), GETPOST('durationmin','int')); + $desc=GETPOST('np_desc'); + $date_intervention = dol_mktime(GETPOST('dihour','int'), GETPOST('dimin','int'), 0, GETPOST('dimonth','int'), GETPOST('diday','int'), GETPOST('diyear','int')); + $duration = convertTime2Seconds(GETPOST('durationhour','int'), GETPOST('durationmin','int')); $result=$object->addline( $user, @@ -437,71 +438,71 @@ else if ($action == "addline" && $user->rights->ficheinter->creer) $duration ); - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } if ($result >= 0) { $db->commit(); - fichinter_create($db, $object, $object->modelpdf, $outputlangs); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; + fichinter_create($db, $object, $object->modelpdf, $outputlangs); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; } else { $mesg=$object->error; $db->rollback(); } - } + } } // Classify Billed else if ($action == 'classifybilled' && $user->rights->ficheinter->creer) { - $object->fetch($id); + $object->fetch($id); $result=$object->setBilled(); if ($result > 0) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; } else { - $mesg='
'.$object->error.'
'; + $mesg='
'.$object->error.'
'; } } /* * Mise a jour d'une ligne d'intervention - */ +*/ else if ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST('save','alpha') == $langs->trans("Save")) { - $objectline = new FichinterLigne($db); - if ($objectline->fetch(GETPOST('line_id','int')) <= 0) - { - dol_print_error($db); - exit; - } + $objectline = new FichinterLigne($db); + if ($objectline->fetch(GETPOST('line_id','int')) <= 0) + { + dol_print_error($db); + exit; + } - if ($object->fetch($objectline->fk_fichinter) <= 0) - { - dol_print_error($db); - exit; - } - $object->fetch_thirdparty(); + if ($object->fetch($objectline->fk_fichinter) <= 0) + { + dol_print_error($db); + exit; + } + $object->fetch_thirdparty(); - $desc = GETPOST('np_desc'); - $date_inter = dol_mktime(GETPOST('dihour','int'), GETPOST('dimin','int'), 0, GETPOST('dimonth','int'), GETPOST('diday','int'), GETPOST('diyear','int')); - $duration = convertTime2Seconds(GETPOST('durationhour','int'),GETPOST('durationmin','int')); + $desc = GETPOST('np_desc'); + $date_inter = dol_mktime(GETPOST('dihour','int'), GETPOST('dimin','int'), 0, GETPOST('dimonth','int'), GETPOST('diday','int'), GETPOST('diyear','int')); + $duration = convertTime2Seconds(GETPOST('durationhour','int'),GETPOST('durationmin','int')); $objectline->datei = $date_inter; $objectline->desc = $desc; @@ -513,25 +514,25 @@ else if ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST( exit; } - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - fichinter_create($db, $object, $object->modelpdf, $outputlangs); + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + fichinter_create($db, $object, $object->modelpdf, $outputlangs); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; } /* * Supprime une ligne d'intervention AVEC confirmation - */ +*/ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->ficheinter->creer) { $objectline = new FichinterLigne($db); @@ -563,180 +564,180 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> /* * Ordonnancement des lignes - */ +*/ else if ($action == 'up' && $user->rights->ficheinter->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); - $object->line_up(GETPOST('line_id','int')); + $object->fetch($id); + $object->fetch_thirdparty(); + $object->line_up(GETPOST('line_id','int')); - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - fichinter_create($db, $object, $object->modelpdf, $outputlangs); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('line_id','int')); - exit; + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + fichinter_create($db, $object, $object->modelpdf, $outputlangs); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('line_id','int')); + exit; } else if ($action == 'down' && $user->rights->ficheinter->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); - $object->line_down(GETPOST('line_id','int')); + $object->fetch($id); + $object->fetch_thirdparty(); + $object->line_down(GETPOST('line_id','int')); - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - fichinter_create($db, $object, $object->modelpdf, $outputlangs); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('line_id','int')); - exit; + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + fichinter_create($db, $object, $object->modelpdf, $outputlangs); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('line_id','int')); + exit; } /* * Add file in email form - */ +*/ if (GETPOST('addfile','alpha')) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - // Set tmp user directory TODO Use a dedicated directory for temp mails files - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; + // Set tmp user directory TODO Use a dedicated directory for temp mails files + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; - dol_add_file_process($upload_dir_tmp,0,0); - $action='presend'; + dol_add_file_process($upload_dir_tmp,0,0); + $action='presend'; } /* * Remove file in email form - */ +*/ if (GETPOST('removedfile','alpha')) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - // Set tmp user directory - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; + // Set tmp user directory + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; // TODO Delete only files that was uploaded from email form - dol_remove_file_process(GETPOST('removedfile','alpha'),0); - $action='presend'; + dol_remove_file_process(GETPOST('removedfile','alpha'),0); + $action='presend'; } /* * Send mail - */ +*/ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send)) { - $langs->load('mails'); + $langs->load('mails'); - if ($object->fetch($id) > 0) { + if ($object->fetch($id) > 0) + { + $object->fetch_thirdparty(); - $object->fetch_thirdparty(); + if (GETPOST('sendto','alpha')) + { + // Le destinataire a ete fourni via le champ libre + $sendto = GETPOST('sendto','alpha'); + $sendtoid = 0; + } + elseif (GETPOST('receiver','alpha') != '-1') + { + // Recipient was provided from combo list + if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } + else // Id du contact + { + $sendto = $object->client->contact_get_property(GETPOST('receiver'),'email'); + $sendtoid = GETPOST('receiver','alpha'); + } + } - if (GETPOST('sendto','alpha')) - { - // Le destinataire a ete fourni via le champ libre - $sendto = GETPOST('sendto','alpha'); - $sendtoid = 0; - } - elseif (GETPOST('receiver','alpha') != '-1') - { - // Recipient was provided from combo list - if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; - $sendtoid = 0; - } - else // Id du contact - { - $sendto = $object->client->contact_get_property(GETPOST('receiver'),'email'); - $sendtoid = GETPOST('receiver','alpha'); - } - } + if (dol_strlen($sendto)) + { + $langs->load("commercial"); - if (dol_strlen($sendto)) - { - $langs->load("commercial"); + $from = GETPOST('fromname','alpha') . ' <' . GETPOST('frommail','alpha') .'>'; + $replyto = GETPOST('replytoname','alpha'). ' <' . GETPOST('replytomail','alpha').'>'; + $message = GETPOST('message'); + $sendtocc = GETPOST('sendtocc','alpha'); + $deliveryreceipt = GETPOST('deliveryreceipt','alpha'); - $from = GETPOST('fromname','alpha') . ' <' . GETPOST('frommail','alpha') .'>'; - $replyto = GETPOST('replytoname','alpha'). ' <' . GETPOST('replytomail','alpha').'>'; - $message = GETPOST('message'); - $sendtocc = GETPOST('sendtocc','alpha'); - $deliveryreceipt = GETPOST('deliveryreceipt','alpha'); + if ($action == 'send') + { + if (strlen(GETPOST('subject','alphs'))) $subject = GETPOST('subject','alpha'); + else $subject = $langs->transnoentities('Intervention').' '.$object->ref; + $actiontypecode='AC_OTH_AUTO'; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + if ($message) + { + $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; + $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; + $actionmsg.=$message; + } + $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); + } - if ($action == 'send') - { - if (strlen(GETPOST('subject','alphs'))) $subject = GETPOST('subject','alpha'); - else $subject = $langs->transnoentities('Intervention').' '.$object->ref; - $actiontypecode='AC_OTH_AUTO'; - $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; - if ($message) - { - $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; - $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; - $actionmsg.=$message; - } - $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - } + // Create form object + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); - // Create form object - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); + $attachedfiles=$formmail->get_attached_files(); + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; - $attachedfiles=$formmail->get_attached_files(); - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; + // Envoi de la propal + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1); + if ($mailfile->error) + { + $mesg='
'.$mailfile->error.'
'; + } + else + { + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); + setEventMessage($mesg); + $error=0; - // Envoi de la propal - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1); - if ($mailfile->error) - { - $mesg='
'.$mailfile->error.'
'; - } - else - { - $result=$mailfile->sendfile(); - if ($result) - { - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); - setEventMessage($mesg); - $error=0; + // Initialisation donnees + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; - // Initialisation donnees - $object->sendtoid = $sendtoid; - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; - $object->actionmsg2 = $actionmsg2; - $object->fk_element = $object->id; - $object->elementtype = $object->element; - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('FICHINTER_SENTBYMAIL',$object,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $result=$interface->run_triggers('FICHINTER_SENTBYMAIL',$object,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers if ($error) { @@ -874,7 +875,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheint /* * View - */ +*/ $form = new Form($db); $formfile = new FormFile($db); @@ -883,35 +884,35 @@ llxHeader(); if ($action == 'create') { - /* - * Mode creation - * Creation d'une nouvelle fiche d'intervention - */ + /* + * Mode creation + * Creation d'une nouvelle fiche d'intervention + */ - $soc=new Societe($db); + $soc=new Societe($db); - print_fiche_titre($langs->trans("AddIntervention")); + print_fiche_titre($langs->trans("AddIntervention")); - dol_htmloutput_mesg($mesg); + dol_htmloutput_mesg($mesg); - if ($socid) $res=$soc->fetch($socid); + if ($socid) $res=$soc->fetch($socid); - if (GETPOST('origin') && GETPOST('originid')) - { - // Parse element/subelement (ex: project_task) - $element = $subelement = GETPOST('origin'); - if (preg_match('/^([^_]+)_([^_]+)/i',GETPOST('origin'),$regs)) - { - $element = $regs[1]; - $subelement = $regs[2]; - } + if (GETPOST('origin') && GETPOST('originid')) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = GETPOST('origin'); + if (preg_match('/^([^_]+)_([^_]+)/i',GETPOST('origin'),$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } if ($element == 'project') { $projectid=GETPOST('originid'); } else - { + { // For compatibility if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; @@ -923,72 +924,72 @@ if ($action == 'create') $element = $subelement = 'contrat'; } - dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); - $classname = ucfirst($subelement); - $objectsrc = new $classname($db); - $objectsrc->fetch(GETPOST('originid')); - if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines(); - $objectsrc->fetch_thirdparty(); + $classname = ucfirst($subelement); + $objectsrc = new $classname($db); + $objectsrc->fetch(GETPOST('originid')); + if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines(); + $objectsrc->fetch_thirdparty(); - $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); + $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); - $soc = $objectsrc->client; + $soc = $objectsrc->client; - $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : '')); - $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : ''); + $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : '')); + $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : ''); - // Object source contacts list - $srccontactslist = $objectsrc->liste_contact(-1,'external',1); - } - } - else { + // Object source contacts list + $srccontactslist = $objectsrc->liste_contact(-1,'external',1); + } + } + else { $projectid = GETPOST('projectid','int'); $note_private = ''; $note_public = ''; } - if (! $conf->global->FICHEINTER_ADDON) - { - dol_print_error($db,$langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined")); - exit; - } + if (! $conf->global->FICHEINTER_ADDON) + { + dol_print_error($db,$langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined")); + exit; + } - $object->date = dol_now(); + $object->date = dol_now(); - $obj = $conf->global->FICHEINTER_ADDON; - $obj = "mod_".$obj; + $obj = $conf->global->FICHEINTER_ADDON; + $obj = "mod_".$obj; - //$modFicheinter = new $obj; - //$numpr = $modFicheinter->getNextValue($soc, $object); + //$modFicheinter = new $obj; + //$numpr = $modFicheinter->getNextValue($soc, $object); - if ($socid > 0) - { - $soc->fetch($socid); + if ($socid > 0) + { + $soc->fetch($socid); - print '
'; - print ''; + print ''; + print ''; - print ''; + print '
'; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; - // Ref + // Ref print ''; - // Description (must be a textarea and not html must be allowed (used in list view) - print ''; - print ''; + // Description (must be a textarea and not html must be allowed (used in list view) + print ''; + print ''; - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("project"); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("project"); print ''; + print ''; + print '"; - print ''; - } - else - { - print ''; - print '
'.$langs->trans("ThirdParty").''.$soc->getNomUrl(1).'
'.$langs->trans("ThirdParty").''.$soc->getNomUrl(1).'
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans("Description").''; - print ''; - print '
'.$langs->trans("Description").''; + print ''; + print '
'.$langs->trans("Project").''; /* Fix: If a project must be linked to any companies (suppliers or not), project must be not be set as limited to customer but must be not linked to any particular thirdparty @@ -1059,150 +1060,200 @@ if ($action == 'create') print ''; } - print '

'; - print ''; - print '
'; + // Model + print '
'.$langs->trans("DefaultModel").''; + $liste=ModelePDFFicheinter::liste_modeles($db); + print $form->selectarray('model',$liste,$conf->global->FICHEINTER_ADDON_PDF); + print "
'; - print ''; - print '
'.$langs->trans("ThirdParty").''; - print $form->select_company('','socid','',1,1); - print '
'; + // Public note + print ''; + print ''.$langs->trans('NotePublic').''; + print ''; + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + print $doleditor->Create(1); + //print ''; + print ''; - print '
'; - print ''; - print ''; - print '
'; + // Private note + if (!empty($user->societe_id)) + { + print ''; + print ''.$langs->trans('NotePrivate').''; + print ''; + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + print $doleditor->Create(1); + //print ''; + print ''; + } - print ''; - } + // Other attributes + $parameters=array('colspan' => ' colspan="2"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + + + // Show link to origin object + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + { + $newclassname=$classname; + if ($newclassname=='Propal') $newclassname='CommercialProposal'; + print ''.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).''; + } + + print ''; + + if (is_object($objectsrc)) + { + print ''; + print ''; + } + + print '

'; + print ''; + print '
'; + + print ''; + } + else + { + print '
'; + print ''; + print ''; + print '
'.$langs->trans("ThirdParty").''; + print $form->select_company('','socid','',1,1); + print '
'; + + print '
'; + print ''; + print ''; + print '
'; + + print '
'; + } } else if ($id > 0 || ! empty($ref)) { - /* - * Affichage en mode visu - */ + /* + * Affichage en mode visu + */ $object->fetch($id, $ref); - $object->fetch_thirdparty(); + $object->fetch_thirdparty(); - $soc=new Societe($db); - $soc->fetch($object->socid); + $soc=new Societe($db); + $soc->fetch($object->socid); - dol_htmloutput_mesg($mesg); + dol_htmloutput_mesg($mesg); - $head = fichinter_prepare_head($object); + $head = fichinter_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("InterventionCard"), 0, 'intervention'); + dol_fiche_head($head, 'card', $langs->trans("InterventionCard"), 0, 'intervention'); - // Confirmation de la suppression de la fiche d'intervention - if ($action == 'delete') - { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteIntervention'), $langs->trans('ConfirmDeleteIntervention'), 'confirm_delete','',0,1); - if ($ret == 'html') print '
'; - } + // Confirmation de la suppression de la fiche d'intervention + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteIntervention'), $langs->trans('ConfirmDeleteIntervention'), 'confirm_delete','',0,1); + if ($ret == 'html') print '
'; + } - // Confirmation validation - if ($action == 'validate') - { - // on verifie si l'objet est en numerotation provisoire - $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV') - { - $numref = $object->getNextNumRef($soc); - if (empty($numref)) - { - $error++; - dol_htmloutput_errors($object->error); - } - } - else - { - $numref = $object->ref; - } - $text=$langs->trans('ConfirmValidateIntervention',$numref); + // Confirmation validation + if ($action == 'validate') + { + // on verifie si l'objet est en numerotation provisoire + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV') + { + $numref = $object->getNextNumRef($soc); + if (empty($numref)) + { + $error++; + dol_htmloutput_errors($object->error); + } + } + else + { + $numref = $object->ref; + } + $text=$langs->trans('ConfirmValidateIntervention',$numref); - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateIntervention'), $text, 'confirm_validate','',0,1); - if ($ret == 'html') print '
'; - } + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateIntervention'), $text, 'confirm_validate','',0,1); + if ($ret == 'html') print '
'; + } - // Confirmation de la validation de la fiche d'intervention - if ($action == 'modify') - { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ModifyIntervention'), $langs->trans('ConfirmModifyIntervention'), 'confirm_modify','',0,1); - if ($ret == 'html') print '
'; - } + // Confirmation de la validation de la fiche d'intervention + if ($action == 'modify') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ModifyIntervention'), $langs->trans('ConfirmModifyIntervention'), 'confirm_modify','',0,1); + if ($ret == 'html') print '
'; + } - // Confirmation de la suppression d'une ligne d'intervention - if ($action == 'ask_deleteline') - { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&line_id='.GETPOST('line_id','int'), $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline','',0,1); - if ($ret == 'html') print '
'; - } + // Confirmation de la suppression d'une ligne d'intervention + if ($action == 'ask_deleteline') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&line_id='.GETPOST('line_id','int'), $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline','',0,1); + if ($ret == 'html') print '
'; + } - print ''; + print '
'; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - // Ref - print ''; + // Ref + print ''; - // Third party - print ""; + // Third party + print ""; - // Duration - print ''; - print ''; - print ''; + // Duration + print ''; + print ''; + print ''; - // Description (must be a textarea and not html must be allowed (used in list view) - print ''; - print ''; + // Description (must be a textarea and not html must be allowed (used in list view) + print ''; + print ''; - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load('projects'); - print ''; - print ''; + print ''; - print ''; - } + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); - print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); + print '
".$langs->trans("Company")."".$object->client->getNomUrl(1)."
".$langs->trans("Company")."".$object->client->getNomUrl(1)."
'.$langs->trans("TotalDuration").''.convertSecondToTime($object->duree, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'
'.$langs->trans("TotalDuration").''.convertSecondToTime($object->duree, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'
'; - print $form->editfieldkey("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea'); - print ''; - print $form->editfieldval("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea:8:80'); - print '
'; + print $form->editfieldkey("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea'); + print ''; + print $form->editfieldval("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea:8:80'); + print '
'; + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load('projects'); + print '
'; - print ''; - if ($action != 'classify') - { - print ''; - } - print '
'; - print $langs->trans('Project'); - print 'id.'">'; - print img_edit($langs->trans('SetProject'),1); - print '
'; - print '
'; - if ($action == 'classify') - { - $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'projectid'); - } - else - { - $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'none'); - } - print '
'; + if ($action != 'classify') + { + print ''; + } + print '
'; + print $langs->trans('Project'); + print 'id.'">'; + print img_edit($langs->trans('SetProject'),1); + print '
'; + print ''; + if ($action == 'classify') + { + $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'projectid'); + } + else + { + $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'none'); + } + print ''; + print ''; + } - // Statut - print ''.$langs->trans("Status").''.$object->getLibStatut(4).''; + // Statut + print ''.$langs->trans("Status").''.$object->getLibStatut(4).''; // Other attributes $parameters=array('colspan' => ' colspan="3"'); @@ -1269,418 +1320,418 @@ else if ($id > 0 || ! empty($ref)) } } - print "
"; + print "
"; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { - $blocname = 'contacts'; - $title = $langs->trans('ContactsAddresses'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { - $blocname = 'notes'; - $title = $langs->trans('Notes'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } + { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } - /* - * Lignes d'intervention - */ - $sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,'; - $sql.= ' ft.date as date_intervention'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft'; - $sql.= ' WHERE ft.fk_fichinter = '.$object->id; - $sql.= ' ORDER BY ft.rang ASC, ft.rowid'; + /* + * Lignes d'intervention + */ + $sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,'; + $sql.= ' ft.date as date_intervention'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft'; + $sql.= ' WHERE ft.fk_fichinter = '.$object->id; + $sql.= ' ORDER BY ft.rang ASC, ft.rowid'; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; - if ($num) - { - print ''; + if ($num) + { + print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - $var=true; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + $var=true; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; - // Ligne en mode visu - if ($action != 'editline' || GETPOST('line_id','int') != $objp->rowid) - { - print ''; - print ''; + print ''; + // Date + print ''; - // Duration - print ''; + // Duration + print ''; - print "\n"; + print "\n"; - // Icone d'edition et suppression - if ($object->statut == 0 && $user->rights->ficheinter->creer) - { - print ''; - print ''; - if ($num > 1) - { - print ''; - } - } - else - { - print ''; - } + // Icone d'edition et suppression + if ($object->statut == 0 && $user->rights->ficheinter->creer) + { + print ''; + print ''; + if ($num > 1) + { + print ''; + } + } + else + { + print ''; + } - print ''; - } + print ''; + } - // Ligne en mode update - if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && GETPOST('line_id','int') == $objp->rowid) - { - print 'rowid.'" method="post">'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + // Editeur wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('np_desc',$objp->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,ROWS_2,70); + $doleditor->Create(); + print ''; - // Date d'intervention - print ''; + // Date d'intervention + print ''; - // Duration - print ''; + // Duration + print ''; - print ''; - print '' . "\n"; + print ''; + print '' . "\n"; - print "\n"; - } + print "\n"; + } - $i++; - } + $i++; + } - $db->free($resql); + $db->free($resql); - /* - * Add line - */ - if ($object->statut == 0 && $user->rights->ficheinter->creer && $action <> 'editline') - { - if (! $num) print '
'.$langs->trans('Description').''.$langs->trans('Date').''.$langs->trans('Duration').' 
'.$langs->trans('Description').''.$langs->trans('Date').''.$langs->trans('Duration').' 
'; - print ''; // ancre pour retourner sur la ligne - print dol_htmlentitiesbr($objp->description); + // Ligne en mode visu + if ($action != 'editline' || GETPOST('line_id','int') != $objp->rowid) + { + print '
'; + print ''; // ancre pour retourner sur la ligne + print dol_htmlentitiesbr($objp->description); - // Date - print ''.dol_print_date($db->jdate($objp->date_intervention),'dayhour').''.dol_print_date($db->jdate($objp->date_intervention),'dayhour').''.convertSecondToTime($objp->duree).''.convertSecondToTime($objp->duree).''; - print 'rowid.'#'.$objp->rowid.'">'; - print img_edit(); - print ''; - print ''; - print 'rowid.'">'; - print img_delete(); - print ''; - if ($i > 0) - { - print 'rowid.'">'; - print img_up(); - print ''; - } - if ($i < $num-1) - { - print 'rowid.'">'; - print img_down(); - print ''; - } - print ' '; + print 'rowid.'#'.$objp->rowid.'">'; + print img_edit(); + print ''; + print ''; + print 'rowid.'">'; + print img_delete(); + print ''; + if ($i > 0) + { + print 'rowid.'">'; + print img_up(); + print ''; + } + if ($i < $num-1) + { + print 'rowid.'">'; + print img_down(); + print ''; + } + print ' 
'; - print ''; // ancre pour retourner sur la ligne + // Ligne en mode update + if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && GETPOST('line_id','int') == $objp->rowid) + { + print 'rowid.'" method="post">'; + print ''; + print ''; + print ''; + print ''; + print '
'; + print ''; // ancre pour retourner sur la ligne - // Editeur wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('np_desc',$objp->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,ROWS_2,70); - $doleditor->Create(); - print ''; - $form->select_date($db->jdate($objp->date_intervention),'di',1,1,0,"date_intervention"); - print ''; + $form->select_date($db->jdate($objp->date_intervention),'di',1,1,0,"date_intervention"); + print ''; - $form->select_duration('duration',$objp->duree); - print ''; + $form->select_duration('duration',$objp->duree); + print ''; - print '
'; + print '
'; + /* + * Add line + */ + if ($object->statut == 0 && $user->rights->ficheinter->creer && $action <> 'editline') + { + if (! $num) print '
'; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print ''; - print "\n"; + print ''; + print "\n"; - // Ajout ligne d'intervention - print ''; - print ''; - print ''; - print ''; + // Ajout ligne d'intervention + print ''; + print ''; + print ''; + print ''; - $var=false; + $var=false; - print '\n"; - print ''; + print '\n"; + print ''; - // Date intervention - print ''; + // Date intervention + print ''; - // Duration - print ''; + // Duration + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; - if (! $num) print '
'; - print ''; // ancre - print $langs->trans('Description').''.$langs->trans('Date').''.$langs->trans('Duration').'
'; + print ''; // ancre + print $langs->trans('Description').''.$langs->trans('Date').''.$langs->trans('Duration').' 
 
'; - // editeur wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('np_desc',GETPOST('np_desc','alpha'),'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,ROWS_2,70); - $doleditor->Create(); - print '
'; + // editeur wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('np_desc',GETPOST('np_desc','alpha'),'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,ROWS_2,70); + $doleditor->Create(); + print ''; - $now=dol_now(); - $timearray=dol_getdate($now); - if (!GETPOST('diday','int')) $timewithnohour=dol_mktime(0,0,0,$timearray['mon'],$timearray['mday'],$timearray['year']); - else $timewithnohour=dol_mktime(GETPOST('dihour','int'),GETPOST('dimin','int'), 0,GETPOST('dimonth','int'),GETPOST('diday','int'),GETPOST('diyear','int')); - $form->select_date($timewithnohour,'di',1,1,0,"addinter"); - print ''; + $now=dol_now(); + $timearray=dol_getdate($now); + if (!GETPOST('diday','int')) $timewithnohour=dol_mktime(0,0,0,$timearray['mon'],$timearray['mday'],$timearray['year']); + else $timewithnohour=dol_mktime(GETPOST('dihour','int'),GETPOST('dimin','int'), 0,GETPOST('dimonth','int'),GETPOST('diday','int'),GETPOST('diyear','int')); + $form->select_date($timewithnohour,'di',1,1,0,"addinter"); + print ''; - $form->select_duration('duration',(!GETPOST('durationhour','int') && !GETPOST('durationmin','int'))?3600:(60*60*GETPOST('durationhour','int')+60*GETPOST('durationmin','int'))); - print ''; + $form->select_duration('duration',(!GETPOST('durationhour','int') && !GETPOST('durationmin','int'))?3600:(60*60*GETPOST('durationhour','int')+60*GETPOST('durationmin','int'))); + print '
'; - } + if (! $num) print ''; + } - if ($num) print ''; - } - else - { - dol_print_error($db); - } + if ($num) print ''; + } + else + { + dol_print_error($db); + } - print '
'; - print "\n"; + print '
'; + print "\n"; - /* - * Barre d'actions - */ - print '
'; + /* + * Barre d'actions + */ + print '
'; - if ($user->societe_id == 0) - { - if ($action != 'editdescription' && ($action != 'presend')) - { - // Validate - if ($object->statut == 0 && $user->rights->ficheinter->creer && count($object->lines) > 0) - { - print ''; - } + if ($user->societe_id == 0) + { + if ($action != 'editdescription' && ($action != 'presend')) + { + // Validate + if ($object->statut == 0 && $user->rights->ficheinter->creer && count($object->lines) > 0) + { + print ''; + } - // Modify - if ($object->statut == 1 && $user->rights->ficheinter->creer) - { - print ''; - } + // Modify + if ($object->statut == 1 && $user->rights->ficheinter->creer) + { + print ''; + } - // Send - if ($object->statut > 0) - { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send) - { - print ''; - } - else print ''; - } + // Send + if ($object->statut > 0) + { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send) + { + print ''; + } + else print ''; + } - // Invoicing + // Invoicing if (! empty($conf->facture->enabled) && $object->statut > 0) - { + { $langs->load("bills"); - if ($object->statut < 2) - { + if ($object->statut < 2) + { if ($user->rights->facture->creer) print ''; else print ''; - } + } - if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED)) - { - if ($object->statut != 2) + if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED)) + { + if ($object->statut != 2) { print ''; } - } - } + } + } - // Delete - if (($object->statut == 0 && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer) - { - print ''; - } + // Delete + if (($object->statut == 0 && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer) + { + print ''; + } - } - } + } + } - print '
'; - print '
'; + print '
'; + print '
'; - if ($action != 'presend') - { + if ($action != 'presend') + { print '
'; - //print '
'; + //print '
'; - /* - * Built documents - */ - $filename=dol_sanitizeFileName($object->ref); - $filedir=$conf->ficheinter->dir_output . "/".$object->ref; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$user->rights->ficheinter->creer; - $delallowed=$user->rights->ficheinter->supprimer; - $genallowed=1; - $delallowed=1; + /* + * Built documents + */ + $filename=dol_sanitizeFileName($object->ref); + $filedir=$conf->ficheinter->dir_output . "/".$object->ref; + $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed=$user->rights->ficheinter->creer; + $delallowed=$user->rights->ficheinter->supprimer; + $genallowed=1; + $delallowed=1; - $var=true; + $var=true; - //print "
\n"; - $somethingshown=$formfile->show_documents('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); + //print "
\n"; + $somethingshown=$formfile->show_documents('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); - /* - * Linked object block - */ - $somethingshown=$object->showLinkedObjectBlock(); + /* + * Linked object block + */ + $somethingshown=$object->showLinkedObjectBlock(); - //print '
'; - print '
'; + //print '
'; + print '
'; - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($object,'fichinter',$socid); + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($object,'fichinter',$socid); - print '
'; - //print "
\n"; - } + print ''; + //print "
\n"; + } - /* - * Action presend - */ - if ($action == 'presend') - { - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($ref,'/')); - $file=$fileparams['fullname']; + /* + * Action presend + */ + if ($action == 'presend') + { + $ref = dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($ref,'/')); + $file=$fileparams['fullname']; - // Build document if it not exists - if (! $file || ! is_readable($file)) - { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } + // Build document if it not exists + if (! $file || ! is_readable($file)) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } - $result=fichinter_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - $fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($ref,'/')); - $file=$fileparams['fullname']; - } + $result=fichinter_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + $fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($ref,'/')); + $file=$fileparams['fullname']; + } - print '
'; - print_titre($langs->trans('SendInterventionByMail')); + print '
'; + print_titre($langs->trans('SendInterventionByMail')); - // Create form object - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->fromtype = 'user'; - $formmail->fromid = $user->id; - $formmail->fromname = $user->getFullName($langs); - $formmail->frommail = $user->email; - $formmail->withfrom=1; + // Create form object + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + $formmail->fromtype = 'user'; + $formmail->fromid = $user->id; + $formmail->fromname = $user->getFullName($langs); + $formmail->frommail = $user->email; + $formmail->withfrom=1; $liste=array(); foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; $formmail->withto=GETPOST("sendto")?GETOST("sendto"):$liste; $formmail->withtocc=$liste; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->trans('SendInterventionRef','__FICHINTERREF__'); - $formmail->withfile=2; - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; + $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; + $formmail->withtopic=$langs->trans('SendInterventionRef','__FICHINTERREF__'); + $formmail->withfile=2; + $formmail->withbody=1; + $formmail->withdeliveryreceipt=1; + $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__FICHINTERREF__']=$object->ref; - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; + // Tableau des substitutions + $formmail->substit['__FICHINTERREF__']=$object->ref; + $formmail->substit['__SIGNATURE__']=$user->signature; + $formmail->substit['__PERSONALIZED__']=''; + $formmail->substit['__CONTACTCIVNAME__']=''; - //Find the good contact adress - $custcontact=''; - $contactarr=array(); - $contactarr=$object->liste_contact(-1,'external'); + //Find the good contact adress + $custcontact=''; + $contactarr=array(); + $contactarr=$object->liste_contact(-1,'external'); - if (is_array($contactarr) && count($contactarr)>0) { - foreach($contactarr as $contact) { - if ($contact['libelle']==$langs->trans('TypeContact_fichinter_external_CUSTOMER')) { - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $contactstatic=new Contact($db); - $contactstatic->fetch($contact['id']); - $custcontact=$contactstatic->getFullName($langs,1); - } - } + if (is_array($contactarr) && count($contactarr)>0) { + foreach($contactarr as $contact) { + if ($contact['libelle']==$langs->trans('TypeContact_fichinter_external_CUSTOMER')) { + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + $contactstatic=new Contact($db); + $contactstatic->fetch($contact['id']); + $custcontact=$contactstatic->getFullName($langs,1); + } + } - if (!empty($custcontact)) { - $formmail->substit['__CONTACTCIVNAME__']=$custcontact; - } - } + if (!empty($custcontact)) { + $formmail->substit['__CONTACTCIVNAME__']=$custcontact; + } + } - // Tableau des parametres complementaires - $formmail->param['action']='send'; - $formmail->param['models']='fichinter_send'; - $formmail->param['fichinter_id']=$object->id; - $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; + // Tableau des parametres complementaires + $formmail->param['action']='send'; + $formmail->param['models']='fichinter_send'; + $formmail->param['fichinter_id']=$object->id; + $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - // Init list of files - if (GETPOST("mode")=='init') - { - $formmail->clear_attached_files(); - $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); - } + // Init list of files + if (GETPOST("mode")=='init') + { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); + } - $formmail->show_form(); + $formmail->show_form(); - print '
'; - } + print '
'; + } } diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 8624df28102..4d13d502a4d 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -358,7 +358,7 @@ INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) V -- Provinces Greece (id country=102) INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('66', 10201, NULL, NULL, NULL, 'Αθήνα', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('00', 10205, NULL, NULL, NULL, 'Δράμα', 1); +INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('67', 10205, NULL, NULL, NULL, 'Δράμα', 1); INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('01', 10205, NULL, NULL, NULL, 'Έβρος', 1); INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('02', 10205, NULL, NULL, NULL, 'Θάσος', 1); INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('03', 10205, NULL, NULL, NULL, 'Καβάλα', 1); diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 33b5e84a563..86adc112413 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -101,6 +101,15 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 5 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 54, 5, '5.5','0','USt. Forst', 0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 55, 5, '10.7','0','USt. Landwirtschaft', 0); +-- GREECE (id country=102) +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2462, 102, 23, 0, '0', 0, '0', 0, 'Κανονικός Φ.Π.Α.', 1); +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2463, 102, 0, 0, '0', 0, '0', 0, 'Μηδενικό Φ.Π.Α.', 1); +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2464, 102, 13, 0, '0', 0, '0', 0, 'Μειωμένος Φ.Π.Α.', 1); +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2465, 102, 6.5, 0, '0', 0, '0', 0, 'Υπερμειωμένος Φ.Π.Α.', 1); +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2466, 102, 16, 0, '0', 0, '0', 0, 'Νήσων κανονικός Φ.Π.Α.', 1); +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2467, 102, 9, 0, '0', 0, '0', 0, 'Νήσων μειωμένος Φ.Π.Α.', 1); +insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2468, 102, 5, 0, '0', 0, '0', 0, 'Νήσων υπερμειωμένος Φ.Π.Α.', 1); + -- ICELAND (id country=116) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1161, 116,'25.5','0','VAT standard rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1162, 116, '7','0','VAT reduced rate',1); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index a76156142d6..e5df33ec55f 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -393,6 +393,7 @@ AllCompletelyPayedInvoiceWillBeClosed=All invoice with no remain to pay will be ToMakePayment=Pay ToMakePaymentBack=Pay back ListOfYourUnpaidInvoices=List of unpaid invoices +NoteListOfYourUnpaidInvoices=Note: This list contains only invoices for third parties you are linked to as a sale representative. RevenueStamp=Revenue stamp ##### Types de contacts ##### TypeContact_facture_internal_SALESREPFOLL=Representative following-up customer invoice diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index adfa9a34bdc..debbe4f4d33 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -390,6 +390,7 @@ AllCompletelyPayedInvoiceWillBeClosed=Toutes les factures avec un reste à payer ToMakePayment=Payer ToMakePaymentBack=Rembourser ListOfYourUnpaidInvoices=Liste des factures impayées +NoteListOfYourUnpaidInvoices=Remarque: Cette liste ne contient que les factures des Tiers pour lesquels vous êtes le commercial affecté. RevenueStamp=Timbre fiscal ##### Types de contacts ##### TypeContact_facture_internal_SALESREPFOLL=Responsable suivi facture client diff --git a/htdocs/langs/fr_FR/margins.lang b/htdocs/langs/fr_FR/margins.lang index 19910d90291..dcfe51d6786 100644 --- a/htdocs/langs/fr_FR/margins.lang +++ b/htdocs/langs/fr_FR/margins.lang @@ -43,10 +43,10 @@ MargeBrute=Marge brute MargeNette=Marge nette MARGIN_TYPE_DETAILS=Marge brute : Prix de vente HT - Prix d'achat HT
Marge nette : Prix de vente HT - Coût de revient -CostPrice=Prix ​​d'achat -BuyingCost=Coût de revient +BuyingPrice=Prix ​​d'achat +CostPrice=Prix de revient UnitCharges=Charge unitaire Charges=Charges AgentContactType=Type de contact commissionné -AgentContactTypeDetails=Permet de définir le type de contact associé aux factures qui sera associé aux agents commerciaux \ No newline at end of file +AgentContactTypeDetails=Permet de définir le type de contact associé aux factures qui sera associé aux agents commerciaux diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index 07b27fd0904..8cf6588ff8b 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -207,7 +207,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta else { $allmessage.= $newlangs->transnoentities("ListOfYourUnpaidInvoices").($usehtml?"
\n":"\n").($usehtml?"
\n":"\n"); - $allmessage.= "Note: This list contains only invoices for third parties you are linked to as a sale representative.".($usehtml?"
\n":"\n"); + $allmessage.= $newlangs->transnoentities("NoteListOfYourUnpaidInvoices").($usehtml?"
\n":"\n"); } $allmessage.= $message.($usehtml?"
\n":"\n"); $allmessage.= $langs->trans("Total")." = ".price($total).($usehtml?"
\n":"\n");