diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a4c693b1d9c..d626ae9b4e4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1570,6 +1570,36 @@ class CommonObject print "\n"; } } + + /** + * \brief Load type of canvas + * \param id element id + */ + function getCanvas($id) + { + global $conf; + + $sql = "SELECT rowid, canvas"; + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql.= " WHERE entity = ".$conf->entity; + $sql.= " AND rowid = ".$id; + + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->canvas = $obj->canvas; + + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } } diff --git a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql index 254d5d7f61e..43440566dc6 100644 --- a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql +++ b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql @@ -39,3 +39,7 @@ ALTER TABLE llx_actioncomm MODIFY label varchar(128) NOT NULL; ALTER TABLE llx_expedition MODIFY date_expedition datetime; ALTER TABLE llx_expedition MODIFY date_delivery datetime NULL; + +ALTER TABLE llx_societe ADD COLUMN canvas varchar(32) DEFAULT 'default' AFTER default_lang; +UPDATE llx_societe SET canvas='default' WHERE fk_typent <> 8; +UPDATE llx_societe SET canvas='individual' WHERE fk_typent = 8; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index be81f991e76..b44880289f3 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -1,7 +1,7 @@ -- ======================================================================== -- Copyright (C) 2000-2004 Rodolphe Quiedeville --- Copyright (C) 2004-2009 Laurent Destailleur --- Copyright (C) 2005-2009 Regis Houssin +-- Copyright (C) 2004-2010 Laurent Destailleur +-- Copyright (C) 2005-2010 Regis Houssin -- Copyright (C) 2010 Juanjo Menent -- -- This program is free software; you can redistribute it and/or modify @@ -76,14 +76,7 @@ create table llx_societe localtax2_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 2 gencod varchar(255), -- barcode price_level integer NULL, -- level of price for multiprices - default_lang varchar(6), + default_lang varchar(6), -- default language + canvas varchar(32) DEFAULT 'default', -- type of canvas import_key varchar(14) -- import key )type=innodb; - --- --- List of codes for the field entity --- --- 1 : first company customers/suppliers --- 2 : second company customers/suppliers --- 3 : etc... --- \ No newline at end of file diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ca16b594313..075aec68bbd 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2772,39 +2772,6 @@ class Product extends CommonObject } } - /** - * \brief Load type of canvas - * \param id product id - * \param ref product ref - */ - function getCanvas($id, $ref) - { - global $conf; - - $sql = "SELECT rowid, ref, canvas"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity = ".$conf->entity; - if (!empty($id)) $sql.= " AND rowid = ".$id; - if (!empty($ref)) $sql.= " AND ref = '".$ref."'"; - - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - - $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->canvas = $obj->canvas; - - return 1; - } - else - { - dol_print_error($this->db); - return -1; - } - } - /** * \brief Affecte les valeurs communes */ diff --git a/htdocs/societe/canvas/default/thirdparty.default.class.php b/htdocs/societe/canvas/default/thirdparty.default.class.php index 03e4db627e2..943e5c47a12 100644 --- a/htdocs/societe/canvas/default/thirdparty.default.class.php +++ b/htdocs/societe/canvas/default/thirdparty.default.class.php @@ -90,6 +90,53 @@ class ThirdPartyDefault extends Societe $this->tpl['action_delete']=$form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2); } } + + $this->tpl['profid1'] = $this->siren; + $this->tpl['profid2'] = $this->siret; + $this->tpl['profid3'] = $this->ape; + $this->tpl['profid4'] = $this->idprof4; + + for ($i=1; $i<=4; $i++) + { + $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i,$this->pays_code); + $this->tpl['checkprofid'.$i] = $this->id_prof_check($i,$this); + $this->tpl['urlprofid'.$i] = $this->id_prof_url($i,$this); + } + + // TVA intra + if ($this->tva_intra) + { + $s=''; + $s.=$this->tva_intra; + $s.=''; + $s.='   '; + if ($conf->use_javascript_ajax) + { + $s.=''.$langs->trans("VATIntraCheck").''; + $this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); + } + else + { + $this->tpl['tva_intra'] = $s.'id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; + } + } + else + { + $this->tpl['tva_intra'] = ' '; + } + + // Parent company + if ($this->parent) + { + $socm = new Societe($this->db); + $socm->fetch($this->parent); + $this->tpl['parent_company'] = $socm->getNomUrl(1).' '.($socm->code_client?"(".$socm->code_client.")":""); + $this->tpl['parent_company'].= $socm->ville?' - '.$socm->ville:''; + } + else + { + $this->tpl['parent_company'] = $langs->trans("NoParentCompany"); + } } /** diff --git a/htdocs/societe/canvas/individual/index.php b/htdocs/societe/canvas/individual/index.php new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/societe/canvas/individual/thirdparty.individual.class.php b/htdocs/societe/canvas/individual/thirdparty.individual.class.php new file mode 100644 index 00000000000..8a74ebed042 --- /dev/null +++ b/htdocs/societe/canvas/individual/thirdparty.individual.class.php @@ -0,0 +1,107 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/societe/canvas/default/thirdparty.individual.class.php + * \ingroup thirparty + * \brief Fichier de la classe des particuliers + * \version $Id$ + */ + +/** + * \class ThirdPartyIndividual + * \brief Classe permettant la gestion des particuliers, cette classe surcharge la classe societe + */ +class ThirdPartyIndividual extends Societe +{ + //! Numero d'erreur Plage 1280-1535 + var $errno = 0; + //! Template container + var $tpl = array(); + + /** + * \brief Constructeur de la classe + * \param DB Handler acces base de donnees + * \param id Id produit (0 par defaut) + */ + function ThirdPartyIndividual($DB=0, $id=0, $user=0) + { + $this->db = $DB; + $this->id = $id ; + $this->user = $user; + $this->smarty = 0; + $this->module = "societe"; + $this->canvas = "individual"; + $this->name = "individual"; + $this->definition = "Canvas des particuliers"; + $this->fieldListName = "thirdparty_individual"; + } + + function getTitle() + { + global $langs; + + return $langs->trans("Individual"); + } + + /** + * \brief Lecture des donnees dans la base + * \param id Product id + */ + function fetch($id='', $ref='', $action='') + { + $result = parent::fetch($id); + + return $result; + } + + /** + * Assign custom values for canvas + * @param action Type of action + */ + function assign_values($action='') + { + global $langs; + + parent::assign_values($action); + + $form = new Form($db); + + if ($action == 'view') + { + // Confirm delete third party + if ($_GET["action"] == 'delete') + { + $this->tpl['action_delete']=$form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->id,$langs->trans("DeleteAnIndividual"),$langs->trans("ConfirmDeleteIndividual"),"confirm_delete",'',0,2); + } + } + } + + /** + * \brief Fetch datas list + */ + function LoadListDatas($limit, $offset, $sortfield, $sortorder) + { + global $conf, $langs; + + $this->list_datas = array(); + } + +} + +?> \ No newline at end of file diff --git a/htdocs/societe/canvas/individual/tpl/create.tpl.php b/htdocs/societe/canvas/individual/tpl/create.tpl.php new file mode 100644 index 00000000000..4a17dcd09d3 --- /dev/null +++ b/htdocs/societe/canvas/individual/tpl/create.tpl.php @@ -0,0 +1,25 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ +?> + + + + + \ No newline at end of file diff --git a/htdocs/societe/canvas/individual/tpl/edit.tpl.php b/htdocs/societe/canvas/individual/tpl/edit.tpl.php new file mode 100644 index 00000000000..4a17dcd09d3 --- /dev/null +++ b/htdocs/societe/canvas/individual/tpl/edit.tpl.php @@ -0,0 +1,25 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ +?> + + + + + \ No newline at end of file diff --git a/htdocs/societe/canvas/individual/tpl/index.php b/htdocs/societe/canvas/individual/tpl/index.php new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/societe/canvas/individual/tpl/view.tpl.php b/htdocs/societe/canvas/individual/tpl/view.tpl.php new file mode 100644 index 00000000000..18d880413a4 --- /dev/null +++ b/htdocs/societe/canvas/individual/tpl/view.tpl.php @@ -0,0 +1,176 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ +?> + + + +object->tpl['action_delete']) echo $this->object->tpl['action_delete']; ?> + + +
+ + +
+ + + + + + + + + + + + + +object->tpl['client']) { ?> + + + + + + +object->tpl['fournisseur']) { ?> + + + + + + +global->MAIN_MODULE_BARCODE) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +object->tpl['localtax'])) echo $this->object->tpl['localtax']; ?> + + + + + + +global->MAIN_MULTILANGS) { ?> + + + + + + + + + + + + + + + + +adherent->enabled) { ?> + + + + + + +
trans('Name'); ?>object->tpl['showrefnav']; ?>
trans('Prefix'); ?>object->tpl['prefix_comm']; ?>
trans('CustomerCode'); ?>object->tpl['code_client']; ?> + object->tpl['checkcustomercode'] <> 0) { ?> + (trans("WrongCustomerCode"); ?>) + +
trans('SupplierCode'); ?>object->tpl['code_fournisseur']; ?> + object->tpl['checksuppliercode'] <> 0) { ?> + (trans("WrongSupplierCode"); ?>) + +
trans('Gencod'); ?>object->tpl['gencod']; ?>
trans('Address'); ?>object->tpl['address']; ?>
trans('Zip'); ?>object->tpl['cp']; ?>trans('Town'); ?>object->tpl['ville']; ?>
trans("Country"); ?>object->tpl['country']; ?>
trans('State'); ?>object->tpl['departement']; ?>
trans('Phone'); ?>object->tpl['phone']; ?>trans('Fax'); ?>object->tpl['fax']; ?>
trans('EMail'); ?>object->tpl['email'];; ?>trans('Web'); ?>object->tpl['url']; ?>
trans('VATIsUsed'); ?>object->tpl['tva_assuj']; ?>
trans("Type"); ?>object->tpl['typent']; ?>
trans("DefaultLang"); ?>object->tpl['default_lang']; ?>
+ + + + + +
trans('RIB'); ?> + rights->societe->creer) { ?> + object->tpl['image_edit']; ?> + +   + +
+
object->tpl['display_rib']; ?>
+ + + + + +
trans('SalesRepresentatives'); ?> + rights->societe->creer) { ?> + object->tpl['image_edit']; ?> + +   + +
+
object->tpl['sales_representatives']; ?>
trans("LinkedToDolibarrMember"); ?>object->tpl['linked_member']; ?>
+
+ + + + \ No newline at end of file diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 963c95ed76a..fd261e47c4c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -125,6 +125,8 @@ class Societe extends CommonObject var $commercial_id; //Id du commercial affecte var $default_lang; + + var $canvas; var $import_key; @@ -179,6 +181,8 @@ class Societe extends CommonObject $this->error = $langs->trans("ErrorBadEMail",$this->email); return -1; } + + if (empty($this->canvas)) $this->canvas = 'default'; $this->db->begin(); @@ -193,9 +197,10 @@ class Societe extends CommonObject if ($result >= 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, entity, datec, datea, fk_user_creat)"; - $sql.= " VALUES ('".$this->db->escape($this->nom)."', ".$conf->entity.", '".$this->db->idate($now)."', '".$this->db->idate($now)."',"; - $sql.= " ".($user->id > 0 ? "'".$user->id."'":"null"); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, entity, datec, datea, fk_user_creat, canvas)"; + $sql.= " VALUES ('".$this->db->escape($this->nom)."', ".$conf->entity.", '".$this->db->idate($now)."', '".$this->db->idate($now)."'"; + $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); + $sql.= ", '".$this->canvas."'"; $sql.= ")"; dol_syslog("Societe::create sql=".$sql); @@ -2161,42 +2166,8 @@ class Societe extends CommonObject $this->tpl['email'] = dol_print_email($this->email,0,$this->id,'AC_EMAIL'); $this->tpl['url'] = dol_print_url($this->url); - $this->tpl['profid1'] = $this->siren; - $this->tpl['profid2'] = $this->siret; - $this->tpl['profid3'] = $this->ape; - $this->tpl['profid4'] = $this->idprof4; - - for ($i=1; $i<=4; $i++) - { - $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i,$this->pays_code); - $this->tpl['checkprofid'.$i] = $this->id_prof_check($i,$this); - $this->tpl['urlprofid'.$i] = $this->id_prof_url($i,$this); - } - $this->tpl['tva_assuj'] = yn($this->tpl['tva_assuj']); - // TVA intra - if ($this->tva_intra) - { - $s=''; - $s.=$this->tva_intra; - $s.=''; - $s.='   '; - if ($conf->use_javascript_ajax) - { - $s.=''.$langs->trans("VATIntraCheck").''; - $this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); - } - else - { - $this->tpl['tva_intra'] = $s.'id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; - } - } - else - { - $this->tpl['tva_intra'] = ' '; - } - // Third party type $arr = $formcompany->typent_array(1); $this->tpl['typent'] = $arr[$this->typent_code]; @@ -2214,19 +2185,6 @@ class Societe extends CommonObject $this->tpl['display_rib'] = $this->display_rib(); - // Parent company - if ($this->parent) - { - $socm = new Societe($this->db); - $socm->fetch($this->parent); - $this->tpl['parent_company'] = $socm->getNomUrl(1).' '.($socm->code_client?"(".$socm->code_client.")":""); - $this->tpl['parent_company'].= $socm->ville?' - '.$socm->ville:''; - } - else - { - $this->tpl['parent_company'] = $langs->trans("NoParentCompany"); - } - // Sales representatives $sql = "SELECT count(sc.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc"; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 60910181958..f1567d9d1f6 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -91,6 +91,7 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) $soc->nom_particulier = $_POST["nom"]; $soc->prenom = $_POST["prenom"]; $soc->civilite_id = $_POST["civilite_id"]; + $soc->canvas = 'individual'; } else { @@ -1160,10 +1161,13 @@ else */ // Call canvas - if (empty($_GET["canvas"])) $_GET["canvas"]='default'; + //if (empty($_GET["canvas"])) $_GET["canvas"]='default'; + + $socstatic = new Societe($db); + $socstatic->getCanvas($socid); $soc = new Canvas($db,$user); - $soc->load_canvas('thirdparty@societe',$_GET["canvas"]); + $soc->load_canvas('thirdparty@societe',$socstatic->canvas); $soc->id = $socid; $result=$soc->fetch($socid);