Works on canvas integration in third party module

This commit is contained in:
Regis Houssin 2010-09-01 09:19:03 +00:00
parent c15b95e40e
commit d97c1054f1
13 changed files with 432 additions and 96 deletions

View File

@ -1570,6 +1570,36 @@ class CommonObject
print "</form>\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;
}
}
}

View File

@ -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;

View File

@ -1,7 +1,7 @@
-- ========================================================================
-- Copyright (C) 2000-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2010 Juanjo Menent <dolibarr@2byte.es>
--
-- 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...
--

View File

@ -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
*/

View File

@ -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.='<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$this->tva_intra.'">';
$s.=' &nbsp; ';
if ($conf->use_javascript_ajax)
{
$s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
}
else
{
$this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
}
}
else
{
$this->tpl['tva_intra'] = '&nbsp;';
}
// 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");
}
}
/**

View File

@ -0,0 +1,107 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
*
* 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();
}
}
?>

View File

@ -0,0 +1,25 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
*
* 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$
*/
?>
<!-- BEGIN PHP TEMPLATE -->
<!-- END PHP TEMPLATE -->

View File

@ -0,0 +1,25 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
*
* 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$
*/
?>
<!-- BEGIN PHP TEMPLATE -->
<!-- END PHP TEMPLATE -->

View File

@ -0,0 +1,176 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
*
* 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$
*/
?>
<!-- BEGIN PHP TEMPLATE -->
<?php if ($this->object->tpl['action_delete']) echo $this->object->tpl['action_delete']; ?>
<?php if ($mesg) { ?>
<div class="error"><?php echo $mesg; ?></div>
<?php } ?>
<form name="formsoc" method="POST">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
<table class="border" width="100%">
<tr>
<td width="20%"><?php echo $langs->trans('Name'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['showrefnav']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans('Prefix'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['prefix_comm']; ?></td>
</tr>
<?php if ($this->object->tpl['client']) { ?>
<tr>
<td><?php echo $langs->trans('CustomerCode'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['code_client']; ?>
<?php if ($this->object->tpl['checkcustomercode'] <> 0) { ?>
<font class="error">(<?php echo $langs->trans("WrongCustomerCode"); ?>)</font>
<?php } ?>
</td>
</tr>
<?php } ?>
<?php if ($this->object->tpl['fournisseur']) { ?>
<tr>
<td><?php echo $langs->trans('SupplierCode'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['code_fournisseur']; ?>
<?php if ($this->object->tpl['checksuppliercode'] <> 0) { ?>
<font class="error">(<?php echo $langs->trans("WrongSupplierCode"); ?>)</font>
<?php } ?>
</td>
</tr>
<?php } ?>
<?php if ($conf->global->MAIN_MODULE_BARCODE) { ?>
<tr>
<td><?php echo $langs->trans('Gencod'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['gencod']; ?></td>
</tr>
<?php } ?>
<tr>
<td valign="top"><?php echo $langs->trans('Address'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['address']; ?></td>
</tr>
<tr>
<td width="25%"><?php echo $langs->trans('Zip'); ?></td>
<td width="25%"><?php echo $this->object->tpl['cp']; ?></td>
<td width="25%"><?php echo $langs->trans('Town'); ?></td>
<td width="25%"><?php echo $this->object->tpl['ville']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("Country"); ?></td>
<td colspan="3" nowrap="nowrap"><?php echo $this->object->tpl['country']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans('State'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['departement']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans('Phone'); ?></td>
<td><?php echo $this->object->tpl['phone']; ?></td>
<td><?php echo $langs->trans('Fax'); ?></td>
<td><?php echo $this->object->tpl['fax']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans('EMail'); ?></td>
<td><?php echo $this->object->tpl['email'];; ?></td>
<td><?php echo $langs->trans('Web'); ?></td>
<td><?php echo $this->object->tpl['url']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans('VATIsUsed'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['tva_assuj']; ?></td>
</tr>
<?php if(!empty($this->object->tpl['localtax'])) echo $this->object->tpl['localtax']; ?>
<tr>
<td><?php echo $langs->trans("Type"); ?></td>
<td colspan="3"><?php echo $this->object->tpl['typent']; ?></td>
</tr>
<?php if ($conf->global->MAIN_MULTILANGS) { ?>
<tr>
<td><?php echo $langs->trans("DefaultLang"); ?></td>
<td colspan="3"><?php echo $this->object->tpl['default_lang']; ?></td>
</tr>
<?php } ?>
<tr>
<td>
<table width="100%" class="nobordernopadding">
<tr>
<td><?php echo $langs->trans('RIB'); ?></td>
<td align="right">
<?php if ($user->rights->societe->creer) { ?>
<a href="<?php echo DOL_URL_ROOT.'/societe/rib.php?socid='.$this->object->tpl['id']; ?>"><?php echo $this->object->tpl['image_edit']; ?></a>
<?php } else { ?>
&nbsp;
<?php } ?>
</td>
</tr>
</table>
</td>
<td colspan="3"><?php echo $this->object->tpl['display_rib']; ?></td>
</tr>
<tr>
<td>
<table width="100%" class="nobordernopadding">
<tr>
<td><?php echo $langs->trans('SalesRepresentatives'); ?></td>
<td align="right">
<?php if ($user->rights->societe->creer) { ?>
<a href="<?php echo DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$this->object->tpl['id']; ?>"><?php echo $this->object->tpl['image_edit']; ?></a>
<?php } else { ?>
&nbsp;
<?php } ?>
</td>
</tr>
</table>
</td>
<td colspan="3"><?php echo $this->object->tpl['sales_representatives']; ?></td>
</tr>
<?php if ($conf->adherent->enabled) { ?>
<tr>
<td width="25%" valign="top"><?php echo $langs->trans("LinkedToDolibarrMember"); ?></td>
<td colspan="3"><?php echo $this->object->tpl['linked_member']; ?></td>
</tr>
<?php } ?>
</table>
</form>
</div>
<!-- END PHP TEMPLATE -->

View File

@ -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.='<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$this->tva_intra.'">';
$s.=' &nbsp; ';
if ($conf->use_javascript_ajax)
{
$s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
}
else
{
$this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
}
}
else
{
$this->tpl['tva_intra'] = '&nbsp;';
}
// 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";

View File

@ -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);