dolibarr 23.0.3
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 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
25include_once DOL_DOCUMENT_ROOT.'/societe/canvas/actions_card_common.class.php';
26
27
34{
44 public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
45 {
46 $this->db = $db;
47 $this->dirmodule = $dirmodule;
48 $this->targetmodule = $targetmodule;
49 $this->canvas = $canvas;
50 $this->card = $card;
51 }
52
59 private function getTitle($action)
60 {
61 global $langs;
62
63 $out = '';
64
65 if ($action == 'view') {
66 $out .= $langs->trans("ThirdParty");
67 }
68 if ($action == 'edit') {
69 $out .= $langs->trans("EditCompany");
70 }
71 if ($action == 'create') {
72 $out .= $langs->trans("NewCompany");
73 }
74
75 return $out;
76 }
77
78
79 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
88 public function assign_values(&$action, $id = 0, $ref = '')
89 {
90 // phpcs:enable
91 global $conf, $langs;
92 global $form, $formcompany;
93
94 $ret = $this->getObject($id, $ref);
95
96 parent::assign_values($action);
97
98 $this->tpl['title'] = load_fiche_titre($this->getTitle($action));
99
100 $this->tpl['profid1'] = $this->object->idprof1;
101 $this->tpl['profid2'] = $this->object->idprof2;
102 $this->tpl['profid3'] = $this->object->idprof3;
103 $this->tpl['profid4'] = $this->object->idprof4;
104
105 if ($conf->use_javascript_ajax && !getDolGlobalString('MAIN_DISABLEVATCHECK')) {
106 $js = "\n";
107 $js .= '<script type="text/javascript">';
108 $js .= "function CheckVAT(a) {\n";
109 $js .= "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,230);\n";
110 $js .= "}\n";
111 $js .= '</script>';
112 $js .= "\n";
113 $this->tpl['js_checkVatPopup'] = $js;
114 }
115
116 if ($action == 'create' || $action == 'edit') {
117 for ($i = 1; $i <= 4; $i++) {
118 $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i, $this->object->country_code);
119 $this->tpl['showprofid'.$i] = $formcompany->get_input_id_prof($i, 'idprof'.$i, $this->tpl['profid'.$i], $this->object->country_code);
120 }
121
122 // Type
123 $this->tpl['select_companytype'] = $form->selectarray("typent_id", $formcompany->typent_array(0), $this->object->typent_id);
124
125 // Juridical Status
126 $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code, $this->object->country_id);
127
128 // Workforce
129 $this->tpl['select_workforce'] = $form->selectarray("effectif_id", $formcompany->effectif_array(0), $this->object->effectif_id);
130
131 // VAT intra
132 $s = '<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">';
133 if (!getDolGlobalString('MAIN_DISABLEVATCHECK')) {
134 $s .= ' ';
135
136 if ($conf->use_javascript_ajax) {
137 $s .= '<a href="#" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
138 $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
139 } else {
140 $this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL", (string) $this->object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';
141 }
142 } else {
143 $this->tpl['tva_intra'] = $s;
144 }
145 } else {
146 // Confirm delete third party
147 if ($action == 'delete') {
148 $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");
149 }
150
151 for ($i = 1; $i <= 4; $i++) {
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 $s = $this->object->tva_intra;
160 $s .= '<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">';
161 if (!getDolGlobalString('MAIN_DISABLEVATCHECK')) {
162 $s .= ' &nbsp; ';
163
164 if ($conf->use_javascript_ajax) {
165 $s .= '<a href="#" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
166 $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
167 } else {
168 $this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL", (string) $this->object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';
169 }
170 } else {
171 $this->tpl['tva_intra'] = $s;
172 }
173 } else {
174 $this->tpl['tva_intra'] = '&nbsp;';
175 }
176
177 // Parent company
178 if ($this->object->parent) {
179 $socm = new Societe($this->db);
180 $socm->fetch($this->object->parent);
181 $this->tpl['parent_company'] = $socm->getNomUrl(1).' '.($socm->code_client ? "(".$socm->code_client.")" : "");
182 $this->tpl['parent_company'] .= ($socm->town ? ' - '.$socm->town : '');
183 } else {
184 $this->tpl['parent_company'] = $langs->trans("NoParentCompany");
185 }
186 }
187 }
188
202 public function restrictedArea($user, $features = 'societe', $objectid = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid')
203 {
204 return restrictedArea($user, $features, $objectid, $dbtablename, $feature2, $dbt_keyfield, $dbt_select);
205 }
206}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
Abstract class to manage third parties.
getObject($id, $ref='')
Get object from id or ref and save it into this->object.
assign_values(&$action, $id=0, $ref='')
Assign custom values for canvas (for example into this->tpl to be used by templates)
getTitle($action)
Return the title of card.
__construct($db, $dirmodule, $targetmodule, $canvas, $card)
Constructor.
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.
Class to manage third parties objects (customers, suppliers, prospects...)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.