dolibarr  9.0.0
actions_card_company.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@inodbox.com>
3  * Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
24 include_once DOL_DOCUMENT_ROOT.'/societe/canvas/actions_card_common.class.php';
25 
31 {
41  function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
42  {
43  $this->db = $db;
44  $this->dirmodule = $dirmodule;
45  $this->targetmodule = $targetmodule;
46  $this->canvas = $canvas;
47  $this->card = $card;
48  }
49 
56  private function getTitle($action)
57  {
58  global $langs;
59 
60  $out='';
61 
62  if ($action == 'view') $out.= $langs->trans("ThirdParty");
63  if ($action == 'edit') $out.= $langs->trans("EditCompany");
64  if ($action == 'create') $out.= $langs->trans("NewCompany");
65 
66  return $out;
67  }
68 
69 
70  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
79  function assign_values(&$action, $id=0, $ref='')
80  {
81  // phpcs:enable
82  global $conf, $langs, $user, $mysoc;
83  global $form, $formadmin, $formcompany;
84 
85  $ret = $this->getObject($id,$ref);
86 
87  parent::assign_values($action);
88 
89  $this->tpl['title'] = load_fiche_titre($this->getTitle($action));
90 
91  $this->tpl['profid1'] = $this->object->idprof1;
92  $this->tpl['profid2'] = $this->object->idprof2;
93  $this->tpl['profid3'] = $this->object->idprof3;
94  $this->tpl['profid4'] = $this->object->idprof4;
95 
96  if ($conf->use_javascript_ajax && empty($conf->global->MAIN_DISABLEVATCHECK))
97  {
98  $js = "\n";
99  $js.= '<script language="JavaScript" type="text/javascript">';
100  $js.= "function CheckVAT(a) {\n";
101  $js.= "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,230);\n";
102  $js.= "}\n";
103  $js.= '</script>';
104  $js.= "\n";
105  $this->tpl['js_checkVatPopup'] = $js;
106  }
107 
108  if ($action == 'create' || $action == 'edit')
109  {
110  for ($i=1; $i<=4; $i++)
111  {
112  $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i,$this->object->country_code);
113  $this->tpl['showprofid'.$i] = $formcompany->get_input_id_prof($i,'idprof'.$i,$this->tpl['profid'.$i],$this->object->country_code);
114  }
115 
116  // Type
117  $this->tpl['select_companytype'] = $form->selectarray("typent_id",$formcompany->typent_array(0), $this->object->typent_id);
118 
119  // Juridical Status
120  $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code,$this->object->country_code);
121 
122  // Workforce
123  $this->tpl['select_workforce'] = $form->selectarray("effectif_id",$formcompany->effectif_array(0), $this->object->effectif_id);
124 
125  // VAT intra
126  $s='<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">';
127  if (empty($conf->global->MAIN_DISABLEVATCHECK))
128  {
129  $s.=' ';
130 
131  if ($conf->use_javascript_ajax)
132  {
133  $s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
134  $this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
135  }
136  else
137  {
138  $this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
139  }
140  }
141  else
142  {
143  $this->tpl['tva_intra'] = $s;
144  }
145  }
146  else
147  {
148  // Confirm delete third party
149  if ($action == 'delete')
150  {
151  $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,"1,action-delete");
152  }
153 
154  for ($i=1; $i<=4; $i++)
155  {
156  $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i,$this->object->country_code);
157  $this->tpl['checkprofid'.$i] = $this->object->id_prof_check($i,$this->object);
158  $this->tpl['urlprofid'.$i] = $this->object->id_prof_url($i,$this->object);
159  }
160 
161  // TVA intra
162  if ($this->object->tva_intra)
163  {
164  $s=$this->object->tva_intra;
165  $s.='<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">';
166  if (empty($conf->global->MAIN_DISABLEVATCHECK))
167  {
168  $s.=' &nbsp; ';
169 
170  if ($conf->use_javascript_ajax)
171  {
172  $s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
173  $this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
174  }
175  else
176  {
177  $this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
178  }
179  }
180  else
181  {
182  $this->tpl['tva_intra'] = $s;
183  }
184  }
185  else
186  {
187  $this->tpl['tva_intra'] = '&nbsp;';
188  }
189 
190  // Parent company
191  if ($this->object->parent)
192  {
193  $socm = new Societe($this->db);
194  $socm->fetch($this->object->parent);
195  $this->tpl['parent_company'] = $socm->getNomUrl(1).' '.($socm->code_client?"(".$socm->code_client.")":"");
196  $this->tpl['parent_company'].= ($socm->town ? ' - ' . $socm->town : '');
197  }
198  else
199  {
200  $this->tpl['parent_company'] = $langs->trans("NoParentCompany");
201  }
202  }
203  }
204 
218  function restrictedArea($user, $features='societe', $objectid=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
219  {
220  return restrictedArea($user,$features,$objectid,$dbtablename,$feature2,$dbt_keyfield,$dbt_select);
221  }
222 }
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
__construct($db, $dirmodule, $targetmodule, $canvas, $card)
Constructor.
Classe permettant la gestion des tiers par defaut.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
getObject($id, $ref='')
Get object from id or ref and save it into this->object.
Class to manage third parties objects (customers, suppliers, prospects...)
Class with controller methods for thirdparty canvas.
assign_values(&$action, $id=0, $ref='')
Assign custom values for canvas (for example into this->tpl to be used by templates) ...
restrictedArea($user, $features='societe', $objectid=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
Check permissions of a user to show a page and an object.
getTitle($action)
Return the title of card.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)