dolibarr  13.0.2
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 <https://www.gnu.org/licenses/>.
17  */
18 
24 include_once DOL_DOCUMENT_ROOT.'/societe/canvas/actions_card_common.class.php';
25 
26 
33 {
43  public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
44  {
45  $this->db = $db;
46  $this->dirmodule = $dirmodule;
47  $this->targetmodule = $targetmodule;
48  $this->canvas = $canvas;
49  $this->card = $card;
50  }
51 
58  private function getTitle($action)
59  {
60  global $langs;
61 
62  $out = '';
63 
64  if ($action == 'view') $out .= $langs->trans("ThirdParty");
65  if ($action == 'edit') $out .= $langs->trans("EditCompany");
66  if ($action == 'create') $out .= $langs->trans("NewCompany");
67 
68  return $out;
69  }
70 
71 
72  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
81  public function assign_values(&$action, $id = 0, $ref = '')
82  {
83  // phpcs:enable
84  global $conf, $langs, $user, $mysoc;
85  global $form, $formadmin, $formcompany;
86 
87  $ret = $this->getObject($id, $ref);
88 
89  parent::assign_values($action);
90 
91  $this->tpl['title'] = load_fiche_titre($this->getTitle($action));
92 
93  $this->tpl['profid1'] = $this->object->idprof1;
94  $this->tpl['profid2'] = $this->object->idprof2;
95  $this->tpl['profid3'] = $this->object->idprof3;
96  $this->tpl['profid4'] = $this->object->idprof4;
97 
98  if ($conf->use_javascript_ajax && empty($conf->global->MAIN_DISABLEVATCHECK))
99  {
100  $js = "\n";
101  $js .= '<script language="JavaScript" type="text/javascript">';
102  $js .= "function CheckVAT(a) {\n";
103  $js .= "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,230);\n";
104  $js .= "}\n";
105  $js .= '</script>';
106  $js .= "\n";
107  $this->tpl['js_checkVatPopup'] = $js;
108  }
109 
110  if ($action == 'create' || $action == 'edit')
111  {
112  for ($i = 1; $i <= 4; $i++)
113  {
114  $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i, $this->object->country_code);
115  $this->tpl['showprofid'.$i] = $formcompany->get_input_id_prof($i, 'idprof'.$i, $this->tpl['profid'.$i], $this->object->country_code);
116  }
117 
118  // Type
119  $this->tpl['select_companytype'] = $form->selectarray("typent_id", $formcompany->typent_array(0), $this->object->typent_id);
120 
121  // Juridical Status
122  $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code, $this->object->country_code);
123 
124  // Workforce
125  $this->tpl['select_workforce'] = $form->selectarray("effectif_id", $formcompany->effectif_array(0), $this->object->effectif_id);
126 
127  // VAT intra
128  $s = '<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">';
129  if (empty($conf->global->MAIN_DISABLEVATCHECK))
130  {
131  $s .= ' ';
132 
133  if ($conf->use_javascript_ajax)
134  {
135  $s .= '<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
136  $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
137  } else {
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  } else {
141  $this->tpl['tva_intra'] = $s;
142  }
143  } else {
144  // Confirm delete third party
145  if ($action == 'delete')
146  {
147  $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");
148  }
149 
150  for ($i = 1; $i <= 4; $i++)
151  {
152  $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i, $this->object->country_code);
153  $this->tpl['checkprofid'.$i] = $this->object->id_prof_check($i, $this->object);
154  $this->tpl['urlprofid'.$i] = $this->object->id_prof_url($i, $this->object);
155  }
156 
157  // TVA intra
158  if ($this->object->tva_intra)
159  {
160  $s = $this->object->tva_intra;
161  $s .= '<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">';
162  if (empty($conf->global->MAIN_DISABLEVATCHECK))
163  {
164  $s .= ' &nbsp; ';
165 
166  if ($conf->use_javascript_ajax)
167  {
168  $s .= '<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
169  $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
170  } else {
171  $this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL", $this->object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';
172  }
173  } else {
174  $this->tpl['tva_intra'] = $s;
175  }
176  } else {
177  $this->tpl['tva_intra'] = '&nbsp;';
178  }
179 
180  // Parent company
181  if ($this->object->parent)
182  {
183  $socm = new Societe($this->db);
184  $socm->fetch($this->object->parent);
185  $this->tpl['parent_company'] = $socm->getNomUrl(1).' '.($socm->code_client ? "(".$socm->code_client.")" : "");
186  $this->tpl['parent_company'] .= ($socm->town ? ' - '.$socm->town : '');
187  } else {
188  $this->tpl['parent_company'] = $langs->trans("NoParentCompany");
189  }
190  }
191  }
192 
206  public function restrictedArea($user, $features = 'societe', $objectid = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid')
207  {
208  return restrictedArea($user, $features, $objectid, $dbtablename, $feature2, $dbt_keyfield, $dbt_select);
209  }
210 }
__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.
assign_values(&$action, $id=0, $ref= '')
Assign custom values for canvas (for example into this-&gt;tpl to be used by templates) ...
$conf db
API class for accounts.
Definition: inc.php:54
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
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.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
print $_SERVER["PHP_SELF"]
Edit parameters.
getObject($id, $ref= '')
Get object from id or ref and save it into this-&gt;object.
getTitle($action)
Return the title of card.