PageRenderTime 47ms CodeModel.GetById 3ms RepoModel.GetById 6ms app.codeStats 1ms

/htdocs/societe/fiche.php

https://bitbucket.org/speedealing/speedealing
PHP | 1833 lines | 1327 code | 237 blank | 269 comment | 368 complexity | 4c76c42928782cec143ac412ffe9be10 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Brian Fraval <brian@fraval.org>
  4. * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
  6. * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
  7. * Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
  8. * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
  9. * Copyright (C) 2010-2013 Herve Prot <herve.prot@symeos.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. */
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT . '/societe/lib/societe.lib.php';
  26. require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php';
  27. require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
  28. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php';
  29. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
  30. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
  31. require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
  32. require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
  33. if (!empty($conf->adherent->enabled))
  34. require_once DOL_DOCUMENT_ROOT . '/adherent/class/adherent.class.php';
  35. if (!empty($conf->agenda->enabled))
  36. require_once DOL_DOCUMENT_ROOT . '/agenda/class/agenda.class.php';
  37. $langs->load("companies");
  38. $langs->load("commercial");
  39. $langs->load("bills");
  40. $langs->load("banks");
  41. $langs->load("users");
  42. if (!empty($conf->notification->enabled))
  43. $langs->load("mails");
  44. $mesg = '';
  45. $error = 0;
  46. $errors = array();
  47. $action = (GETPOST('action') ? GETPOST('action') : 'view');
  48. $confirm = GETPOST('confirm');
  49. $socid = GETPOST('id', 'alpha');
  50. if ($user->societe_id)
  51. $socid = $user->societe_id;
  52. $object = new Societe($db);
  53. $contact = new Contact($db);
  54. // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
  55. /*
  56. $object->getCanvas($socid);
  57. $canvas = $object->canvas ? $object->canvas : GETPOST("canvas");
  58. $objcanvas = '';
  59. if (!empty($canvas)) {
  60. require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php';
  61. $objcanvas = new Canvas($db, $action);
  62. $objcanvas->getCanvas('thirdparty', 'card', $canvas);
  63. }
  64. */
  65. // Security check
  66. $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid');
  67. // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
  68. $hookmanager->initHooks(array('thirdpartycard'));
  69. /*
  70. * Actions
  71. */
  72. $parameters = array('id' => $socid);
  73. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  74. $error = $hookmanager->error;
  75. $errors = array_merge($errors, (array) $hookmanager->errors);
  76. if (empty($reshook)) {
  77. if (GETPOST('getcustomercode')) {
  78. // We defined value code_client
  79. $_POST["code_client"] = "Acompleter";
  80. }
  81. if (GETPOST('getsuppliercode')) {
  82. // We defined value code_fournisseur
  83. $_POST["code_fournisseur"] = "Acompleter";
  84. }
  85. // Add new third party
  86. if ((!GETPOST('getcustomercode') && !GETPOST('getsuppliercode')) && ($action == 'add' || $action == 'update') && $user->rights->societe->creer) {
  87. require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
  88. if ($action == 'update') {
  89. $ret = $object->fetch($socid);
  90. $oldcopy = dol_clone($object);
  91. } else {
  92. //$object->canvas = $canvas;
  93. $object->commercial_id->id = GETPOST('commercial_id');
  94. }
  95. if (GETPOST("private") == 1) {
  96. $object->particulier = GETPOST("private");
  97. $object->name = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? GETPOST('prenom') . ' ' . GETPOST('nom') : GETPOST('nom') . ' ' . GETPOST('prenom');
  98. $object->civilite_id = GETPOST('civilite_id');
  99. // Add non official properties
  100. $object->name_bis = GETPOST('nom');
  101. $object->firstname = GETPOST('prenom');
  102. } else {
  103. $object->name = GETPOST('nom');
  104. }
  105. $object->address = GETPOST('adresse');
  106. $object->zip = GETPOST('zipcode');
  107. $object->town = GETPOST('town');
  108. $object->country_id = GETPOST('country_id');
  109. $object->state_id = GETPOST('departement_id');
  110. $object->phone = GETPOST('phone');
  111. $object->fax = GETPOST('fax');
  112. $object->email = GETPOST('email');
  113. $object->url = GETPOST('url');
  114. $object->idprof1 = GETPOST('idprof1');
  115. $object->idprof2 = GETPOST('idprof2');
  116. $object->idprof3 = GETPOST('idprof3');
  117. $object->idprof4 = GETPOST('idprof4');
  118. $object->prefix_comm = GETPOST('prefix_comm');
  119. $object->code_client = GETPOST('code_client');
  120. $object->code_fournisseur = GETPOST('code_fournisseur');
  121. $object->capital = GETPOST('capital');
  122. $object->barcode = GETPOST('barcode');
  123. $object->tva_intra = GETPOST('tva_intra');
  124. $object->tva_assuj = GETPOST('assujtva_value');
  125. $object->Status = GETPOST('status');
  126. // Local Taxes
  127. $object->localtax1_assuj = GETPOST('localtax1assuj_value');
  128. $object->localtax2_assuj = GETPOST('localtax2assuj_value');
  129. $object->forme_juridique_code = GETPOST('forme_juridique_code');
  130. $object->effectif_id = GETPOST('effectif_id');
  131. if (GETPOST("private") == 1) {
  132. $object->typent_id = "TE_PRIVATE";
  133. } else {
  134. $object->typent_id = GETPOST('typent_id');
  135. }
  136. $object->client = GETPOST('client');
  137. $object->fournisseur = GETPOST('fournisseur');
  138. $object->fournisseur_categorie = GETPOST('fournisseur_categorie');
  139. $object->default_lang = GETPOST('default_lang');
  140. // Get extra fields
  141. foreach ($_POST as $key => $value) {
  142. if (preg_match("/^options_/", $key)) {
  143. $object->array_options[$key] = GETPOST($key);
  144. }
  145. }
  146. if (GETPOST('deletephoto'))
  147. $object->logo = '';
  148. else if (!empty($_FILES['photo']['name']))
  149. $object->logo = dol_sanitizeFileName($_FILES['photo']['name']);
  150. // Check parameters
  151. if (empty($_POST["cancel"])) {
  152. if (!empty($object->email) && !isValidEMail($object->email)) {
  153. $langs->load("errors");
  154. $error++;
  155. $errors[] = $langs->trans("ErrorBadEMail", $object->email);
  156. $action = ($action == 'add' ? 'create' : 'edit');
  157. }
  158. if (!empty($object->url) && !isValidUrl($object->url)) {
  159. $langs->load("errors");
  160. $error++;
  161. $errors[] = $langs->trans("ErrorBadUrl", $object->url);
  162. $action = ($action == 'add' ? 'create' : 'edit');
  163. }
  164. if ($object->fournisseur && !$conf->fournisseur->enabled) {
  165. $langs->load("errors");
  166. $error++;
  167. $errors[] = $langs->trans("ErrorSupplierModuleNotEnabled");
  168. $action = ($action == 'add' ? 'create' : 'edit');
  169. }
  170. // Check for duplicate prof id
  171. for ($i = 1; $i < 3; $i++) {
  172. $slabel = "idprof" . $i;
  173. $_POST[$slabel] = trim($_POST[$slabel]);
  174. $vallabel = $_POST[$slabel];
  175. if ($vallabel && $object->id_prof_verifiable($i)) {
  176. if ($object->id_prof_exists($i, $vallabel, $object->id)) {
  177. $langs->load("errors");
  178. $error++;
  179. $errors[] = $langs->transcountry('ProfId' . $i, $object->country_id) . " " . $langs->trans("ErrorProdIdAlreadyExist", $vallabel);
  180. $action = ($action == 'add' ? 'create' : 'edit');
  181. }
  182. }
  183. }
  184. }
  185. if (!$error) {
  186. if ($action == 'add') {
  187. if (empty($object->client))
  188. $object->code_client = '';
  189. if (empty($object->fournisseur))
  190. $object->code_fournisseur = '';
  191. $result = $object->create($user);
  192. if ($result >= 0) {
  193. if ($object->particulier) {
  194. $contact->civilite_id = $object->civilite_id;
  195. $contact->name = $object->name_bis;
  196. $contact->firstname = $object->firstname;
  197. $contact->address = $object->address;
  198. $contact->zip = $object->zip;
  199. $contact->town = $object->town;
  200. $contact->state_id = $object->state_id;
  201. $contact->country_id = $object->country_id;
  202. $contact->societe->id = $object->id; // fk_soc
  203. $contact->societe->name = $object->name; // fk_soc
  204. $contact->email = $object->email;
  205. $contact->phone_pro = $object->phone;
  206. $contact->fax = $object->fax;
  207. $result = $contact->create($user);
  208. if (!$result >= 0) {
  209. $error = $contact->error;
  210. $errors = $contact->errors;
  211. }
  212. }
  213. // Gestion du logo de la société
  214. $dir = $conf->societe->multidir_output[$conf->entity] . "/" . $object->id . "/logos/";
  215. $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
  216. if ($file_OK) {
  217. if (image_format_supported($_FILES['photo']['name'])) {
  218. dol_mkdir($dir);
  219. if (@is_dir($dir)) {
  220. $newfile = $dir . '/' . dol_sanitizeFileName($_FILES['photo']['name']);
  221. $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
  222. if (!$result > 0) {
  223. $errors[] = "ErrorFailedToSaveFile";
  224. } else {
  225. // Create small thumbs for company (Ratio is near 16/9)
  226. // Used on logon for example
  227. $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
  228. // Create mini thumbs for company (Ratio is near 16/9)
  229. // Used on menu or for setup page for example
  230. $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
  231. }
  232. }
  233. }
  234. }
  235. // Gestion du logo de la société
  236. } else {
  237. $error = $object->error;
  238. $errors = $object->errors;
  239. }
  240. if ($result >= 0) {
  241. $url = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
  242. if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
  243. $url = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
  244. else if ($object->fournisseur == 1)
  245. $url = DOL_URL_ROOT . "/fourn/fiche.php?id=" . $object->id;
  246. header("Location: " . $url);
  247. exit;
  248. }
  249. else {
  250. $action = 'create';
  251. }
  252. }
  253. if ($action == 'update') {
  254. if ($_POST["cancel"]) {
  255. header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $socid);
  256. exit;
  257. }
  258. $result = $object->update($socid, $user, 1, $oldcopy->codeclient_modifiable(), $oldcopy->codefournisseur_modifiable());
  259. if ($result <= 0) {
  260. $error = $object->error;
  261. $errors = $object->errors;
  262. }
  263. // Gestion du logo de la société
  264. $dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id . "/logos";
  265. $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
  266. if ($file_OK) {
  267. if (GETPOST('deletephoto')) {
  268. $fileimg = $dir . '/' . $object->logo;
  269. $dirthumbs = $dir . '/thumbs';
  270. dol_delete_file($fileimg);
  271. dol_delete_dir_recursive($dirthumbs);
  272. }
  273. if (image_format_supported($_FILES['photo']['name']) > 0) {
  274. dol_mkdir($dir);
  275. if (@is_dir($dir)) {
  276. $newfile = $dir . '/' . dol_sanitizeFileName($_FILES['photo']['name']);
  277. $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
  278. if (!$result > 0) {
  279. $errors[] = "ErrorFailedToSaveFile";
  280. } else {
  281. // Create small thumbs for company (Ratio is near 16/9)
  282. // Used on logon for example
  283. $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
  284. // Create mini thumbs for company (Ratio is near 16/9)
  285. // Used on menu or for setup page for example
  286. $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
  287. }
  288. }
  289. } else {
  290. $errors[] = "ErrorBadImageFormat";
  291. }
  292. }
  293. // Gestion du logo de la société
  294. if (!$error && !count($errors)) {
  295. header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $socid);
  296. exit;
  297. } else {
  298. $object->id = $socid;
  299. $action = "edit";
  300. }
  301. }
  302. }
  303. }
  304. // Delete third party
  305. if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer) {
  306. $object->fetch($socid);
  307. $result = $object->delete($socid);
  308. if ($result > 0) {
  309. header("Location: " . DOL_URL_ROOT . "/societe/societe.php?delsoc=" . urlencode($object->name));
  310. exit;
  311. } else {
  312. $langs->load("errors");
  313. $error = $langs->trans($object->error);
  314. $errors = $object->errors;
  315. $action = '';
  316. }
  317. }
  318. /*
  319. * Generate document
  320. */
  321. if ($action == 'builddoc') { // En get ou en post
  322. if (is_numeric(GETPOST('model'))) {
  323. $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model"));
  324. } else {
  325. require_once DOL_DOCUMENT_ROOT . '/core/models/modules_societe.class.php';
  326. $object->fetch($socid);
  327. // Define output language
  328. $outputlangs = $langs;
  329. $newlang = '';
  330. if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id']))
  331. $newlang = $_REQUEST['lang_id'];
  332. if ($conf->global->MAIN_MULTILANGS && empty($newlang))
  333. $newlang = $fac->client->default_lang;
  334. if (!empty($newlang)) {
  335. $outputlangs = new Translate();
  336. $outputlangs->setDefaultLang($newlang);
  337. }
  338. $result = thirdparty_doc_create($db, $object, '', $_REQUEST['model'], $outputlangs);
  339. if ($result <= 0) {
  340. dol_print_error($db, $result);
  341. exit;
  342. } else {
  343. header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc'));
  344. exit;
  345. }
  346. }
  347. }
  348. // Remove file in doc form
  349. else if ($action == 'remove_file') {
  350. if ($object->fetch($socid)) {
  351. require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
  352. $langs->load("other");
  353. $upload_dir = $conf->societe->dir_output;
  354. $file = $upload_dir . '/' . GETPOST('file');
  355. $ret = dol_delete_file($file, 0, 0, 0, $object);
  356. if ($ret)
  357. setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
  358. else
  359. setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
  360. }
  361. }
  362. }
  363. /*
  364. * View
  365. */
  366. llxHeader('', $langs->trans("ThirdParty"));
  367. $form = new Form($db);
  368. $formfile = new FormFile($db);
  369. $formadmin = new FormAdmin($db);
  370. $formcompany = new FormCompany($db);
  371. $countrynotdefined = $langs->trans("ErrorSetACountryFirst") . ' (' . $langs->trans("SeeAbove") . ')';
  372. if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
  373. // -----------------------------------------
  374. // When used with CANVAS
  375. // -----------------------------------------
  376. if (empty($object->error) && $socid) {
  377. $object = new Societe($db);
  378. $object->fetch($socid);
  379. }
  380. $objcanvas->assign_values($action, $socid); // Set value for templates
  381. $objcanvas->display_canvas($action); // Show template
  382. } else {
  383. // -----------------------------------------
  384. // When used in standard mode
  385. // -----------------------------------------
  386. if ($action == 'create') {
  387. /*
  388. * Creation
  389. */
  390. // Load object modCodeTiers
  391. $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard');
  392. if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
  393. $module = substr($module, 0, dol_strlen($module) - 4);
  394. }
  395. $dirsociete = array_merge(array('/societe/core/models/'), $conf->societe_modules);
  396. foreach ($dirsociete as $dirroot) {
  397. $res = dol_include_once($dirroot . $module . '.php');
  398. if ($res)
  399. break;
  400. }
  401. $modCodeClient = new $module;
  402. $module = $conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
  403. if (!$module)
  404. $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
  405. if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
  406. $module = substr($module, 0, dol_strlen($module) - 4);
  407. }
  408. $dirsociete = array_merge(array('/societe/core/models/'), $conf->societe_modules);
  409. foreach ($dirsociete as $dirroot) {
  410. $res = dol_include_once($dirroot . $module . '.php');
  411. if ($res)
  412. break;
  413. }
  414. $modCodeFournisseur = new $module;
  415. //if ($_GET["type"]=='cp') { $object->client=3; }
  416. if (GETPOST("type") != 'f') {
  417. $object->client = 3;
  418. }
  419. if (GETPOST("type") == 'c') {
  420. $object->client = 1;
  421. }
  422. if (GETPOST("type") == 'p') {
  423. $object->client = 2;
  424. }
  425. if (!empty($conf->fournisseur->enabled) && (GETPOST("type") == 'f' || GETPOST("type") == '')) {
  426. $object->fournisseur = 1;
  427. }
  428. if (GETPOST("private") == 1) {
  429. $object->particulier = 1;
  430. }
  431. $object->name = GETPOST('nom');
  432. $object->firstname = GETPOST('prenom');
  433. $object->particulier = GETPOST('private', 'int');
  434. $object->prefix_comm = GETPOST('prefix_comm');
  435. $object->client = GETPOST('client') ? GETPOST('client') : $object->client;
  436. $object->code_client = GETPOST('code_client');
  437. $object->fournisseur = GETPOST('fournisseur') ? GETPOST('fournisseur') : $object->fournisseur;
  438. $object->code_fournisseur = GETPOST('code_fournisseur');
  439. $object->address = GETPOST('adresse');
  440. $object->zip = GETPOST('zipcode');
  441. $object->town = GETPOST('town');
  442. $object->state_id = GETPOST('departement_id');
  443. $object->phone = GETPOST('phone');
  444. $object->fax = GETPOST('fax');
  445. $object->email = GETPOST('email');
  446. $object->url = GETPOST('url');
  447. $object->capital = GETPOST('capital');
  448. $object->barcode = GETPOST('barcode');
  449. $object->idprof1 = GETPOST('idprof1');
  450. $object->idprof2 = GETPOST('idprof2');
  451. $object->idprof3 = GETPOST('idprof3');
  452. $object->idprof4 = GETPOST('idprof4');
  453. $object->typent_id = GETPOST('typent_id');
  454. $object->effectif_id = GETPOST('effectif_id');
  455. $object->civility_id = GETPOST('civilite_id');
  456. $object->tva_assuj = GETPOST('assujtva_value');
  457. $object->Status = GETPOST('status');
  458. //Local Taxes
  459. $object->localtax1_assuj = GETPOST('localtax1assuj_value');
  460. $object->localtax2_assuj = GETPOST('localtax2assuj_value');
  461. $object->tva_intra = GETPOST('tva_intra');
  462. if (!is_object($object->commercial_id))
  463. $object->commercial_id = new stdClass();
  464. $object->commercial_id->id = GETPOST('commercial_id');
  465. $object->default_lang = GETPOST('default_lang');
  466. $object->logo = (isset($_FILES['photo']) ? dol_sanitizeFileName($_FILES['photo']['name']) : '');
  467. // Gestion du logo de la société
  468. $dir = $conf->societe->multidir_output[$conf->entity] . "/" . $object->id . "/logos";
  469. $file_OK = (isset($_FILES['photo']) ? is_uploaded_file($_FILES['photo']['tmp_name']) : false);
  470. if ($file_OK) {
  471. if (image_format_supported($_FILES['photo']['name'])) {
  472. dol_mkdir($dir);
  473. if (@is_dir($dir)) {
  474. $newfile = $dir . '/' . dol_sanitizeFileName($_FILES['photo']['name']);
  475. $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
  476. if (!$result > 0) {
  477. $errors[] = "ErrorFailedToSaveFile";
  478. } else {
  479. // Create small thumbs for company (Ratio is near 16/9)
  480. // Used on logon for example
  481. $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
  482. // Create mini thumbs for company (Ratio is near 16/9)
  483. // Used on menu or for setup page for example
  484. $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
  485. }
  486. }
  487. }
  488. }
  489. // We set country_id country for the selected country
  490. $object->country_id = GETPOST('country_id') ? GETPOST('country_id') : $mysoc->country_id;
  491. $object->forme_juridique_code = GETPOST('forme_juridique_code');
  492. /* Show create form */
  493. print_fiche_titre($langs->trans("NewThirdParty"));
  494. print '<div class="with-padding">';
  495. print '<div class="columns">';
  496. $titre = $langs->trans("NewThirdParty");
  497. //print start_box($titre, $object->fk_extrafields->ico);
  498. print column_start();
  499. if (!empty($conf->use_javascript_ajax)) {
  500. print "\n" . '<script type="text/javascript">';
  501. print '$(document).ready(function () {
  502. id_te_private=8;
  503. id_ef15=1;
  504. is_private=' . (GETPOST("private") ? GETPOST("private") : 0) . ';
  505. if (is_private) {
  506. $(".individualline").show();
  507. } else {
  508. $(".individualline").hide();
  509. }
  510. $("#radiocompany").click(function() {
  511. $(".individualline").hide();
  512. $("#typent_id").val(0);
  513. $("#effectif_id").val(0);
  514. $("#TypeName").html(document.formsoc.ThirdPartyName.value);
  515. document.formsoc.private.value=0;
  516. });
  517. $("#radioprivate").click(function() {
  518. $(".individualline").show();
  519. $("#typent_id").val(id_te_private);
  520. $("#effectif_id").val(id_ef15);
  521. $("#TypeName").html(document.formsoc.LastName.value);
  522. document.formsoc.private.value=1;
  523. });
  524. $("#selectcountry_id").change(function() {
  525. document.formsoc.action.value="create";
  526. document.formsoc.submit();
  527. });
  528. });';
  529. print '</script>' . "\n";
  530. print "<br>\n";
  531. print $langs->trans("ThirdPartyType") . ': &nbsp; ';
  532. print '<input type="radio" id="radiocompany" class="flat" name="private" value="0"' . (!GETPOST("private") ? ' checked="checked"' : '');
  533. print '> ' . $langs->trans("Company/Fundation");
  534. print ' &nbsp; &nbsp; ';
  535. print '<input type="radio" id="radioprivate" class="flat" name="private" value="1"' . (!GETPOST("private") ? '' : ' checked="checked"');
  536. print '> ' . $langs->trans("Individual");
  537. print ' (' . $langs->trans("ToCreateContactWithSameName") . ')';
  538. print "<br>\n";
  539. print "<br>\n";
  540. }
  541. dol_htmloutput_errors($error, $errors);
  542. print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formsoc">';
  543. print '<input type="hidden" name="action" value="add">';
  544. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  545. print '<input type="hidden" name="private" value=' . $object->particulier . '>';
  546. print '<input type="hidden" name="type" value=' . GETPOST("type") . '>';
  547. print '<input type="hidden" name="LastName" value="' . $langs->trans('LastName') . '">';
  548. print '<input type="hidden" name="ThirdPartyName" value="' . $langs->trans('ThirdPartyName') . '">';
  549. if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto)
  550. print '<input type="hidden" name="code_auto" value="1">';
  551. print '<table class="border" width="100%">';
  552. // Name, firstname
  553. if ($object->particulier || GETPOST("private")) {
  554. print '<tr><td><span id="TypeName" class="fieldrequired">' . $langs->trans('LastName') . '</span></td><td' . (empty($conf->global->SOCIETE_USEPREFIX) ? ' colspan="3"' : '') . '><input type="text" size="30" maxlength="60" name="nom" value="' . $object->name . '"></td>';
  555. if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
  556. print '<td>' . $langs->trans('Prefix') . '</td><td><input type="text" size="5" maxlength="5" name="prefix_comm" value="' . $object->prefix_comm . '"></td>';
  557. }
  558. print '</tr>';
  559. } else {
  560. print '<tr><td><span span id="TypeName" class="fieldrequired">' . $langs->trans('ThirdPartyName') . '</span></td><td' . (empty($conf->global->SOCIETE_USEPREFIX) ? ' colspan="3"' : '') . '><input type="text" size="30" maxlength="60" name="nom" value="' . $object->name . '"></td>';
  561. if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
  562. print '<td>' . $langs->trans('Prefix') . '</td><td><input type="text" size="5" maxlength="5" name="prefix_comm" value="' . $object->prefix_comm . '"></td>';
  563. }
  564. print '</tr>';
  565. }
  566. // If javascript on, we show option individual
  567. if ($conf->use_javascript_ajax) {
  568. print '<tr class="individualline"><td>' . $langs->trans('FirstName') . '</td><td><input type="text" size="30" name="prenom" value="' . $object->firstname . '"></td>';
  569. print '<td colspan=2>&nbsp;</td></tr>';
  570. print '<tr class="individualline"><td>' . $langs->trans("UserTitle") . '</td><td>';
  571. print $object->select_fk_extrafields('civilite_id', 'civilite_id') . '</td>';
  572. print '<td colspan=2>&nbsp;</td></tr>';
  573. }
  574. // Prospect/Customer
  575. print '<tr><td width="25%"><span class="fieldrequired">' . $langs->trans('ProspectCustomer') . '</span></td><td width="25%"><select class="flat" name="client">';
  576. $selected = isset($_POST['client']) ? GETPOST('client') : $object->client;
  577. if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
  578. print '<option value="2"' . ($selected == 2 ? ' selected="selected"' : '') . '>' . $langs->trans('Prospect') . '</option>';
  579. if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
  580. print '<option value="3"' . ($selected == 3 ? ' selected="selected"' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
  581. print '<option value="1"' . ($selected == 1 ? ' selected="selected"' : '') . '>' . $langs->trans('Customer') . '</option>';
  582. print '<option value="0"' . ($selected == 0 ? ' selected="selected"' : '') . '>' . $langs->trans('NorProspectNorCustomer') . '</option>';
  583. print '</select></td>';
  584. print '<td width="25%">' . $langs->trans('CustomerCode') . '</td><td width="25%">';
  585. print '<table class="nobordernopadding"><tr><td>';
  586. $tmpcode = $object->code_client;
  587. if ($modCodeClient->code_auto)
  588. $tmpcode = $modCodeClient->getNextValue($object, 0);
  589. print '<input type="text" name="code_client" size="16" value="' . $tmpcode . '" maxlength="15">';
  590. print '</td><td>';
  591. $s = $modCodeClient->getToolTip($langs, $object, 0);
  592. print $form->textwithpicto('', $s, 1);
  593. print '</td></tr></table>';
  594. print '</td></tr>';
  595. if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) {
  596. // Supplier
  597. print '<tr>';
  598. print '<td><span class="fieldrequired">' . $langs->trans('Supplier') . '</span></td><td>';
  599. print $form->selectyesno("fournisseur", (isset($_POST['fournisseur']) ? GETPOST('fournisseur') : $object->fournisseur), 1);
  600. print '</td>';
  601. print '<td>' . $langs->trans('SupplierCode') . '</td><td>';
  602. print '<table class="nobordernopadding"><tr><td>';
  603. $tmpcode = $object->code_fournisseur;
  604. if ($modCodeFournisseur->code_auto)
  605. $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
  606. print '<input type="text" name="code_fournisseur" size="16" value="' . $tmpcode . '" maxlength="15">';
  607. print '</td><td>';
  608. $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
  609. print $form->textwithpicto('', $s, 1);
  610. print '</td></tr></table>';
  611. print '</td></tr>';
  612. // Category
  613. /* This must be set into category tab, like for customer category
  614. if ($object->fournisseur)
  615. {
  616. $load = $object->LoadSupplierCateg();
  617. if ( $load == 0)
  618. {
  619. if (count($object->SupplierCategories) > 0)
  620. {
  621. print '<tr>';
  622. print '<td>'.$langs->trans('SupplierCategory').'</td><td colspan="3">';
  623. print $form->selectarray("fournisseur_categorie",$object->SupplierCategories,GETPOST('fournisseur_categorie'),1);
  624. print '</td></tr>';
  625. }
  626. }
  627. } */
  628. }
  629. // Status
  630. print '<tr><td>' . $langs->trans('Status') . '</td><td colspan="3">';
  631. print $object->select_fk_extrafields('Status', "status");
  632. print '</td></tr>';
  633. // Barcode
  634. if (!empty($conf->barcode->enabled)) {
  635. print '<tr><td>' . $langs->trans('Gencod') . '</td><td colspan="3"><input type="text" name="barcode" value="' . $object->barcode . '">';
  636. print '</td></tr>';
  637. }
  638. // Address
  639. print '<tr><td valign="top">' . $langs->trans('Address') . '</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
  640. print $object->address;
  641. print '</textarea></td></tr>';
  642. // Zip / Town
  643. print '<tr><td>' . $langs->trans('Zip') . '</td><td>';
  644. print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'departement_id'), 6);
  645. print '</td><td>' . $langs->trans('Town') . '</td><td>';
  646. print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'departement_id'));
  647. print '</td></tr>';
  648. // Country
  649. print '<tr><td width="25%">' . $langs->trans('Country') . '</td><td colspan="3">';
  650. print $object->select_fk_extrafields('country_id', 'country_id');
  651. if ($user->admin)
  652. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"), 1);
  653. print '</td></tr>';
  654. // State
  655. if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
  656. print '<tr><td>' . $langs->trans('State') . '</td><td colspan="3">';
  657. if ($object->country_id)
  658. print $object->select_fk_extrafields('state_id', 'departement_id');
  659. else
  660. print $countrynotdefined;
  661. print '</td></tr>';
  662. }
  663. // Phone / Fax
  664. print '<tr><td>' . $langs->trans('Phone') . '</td><td><input type="text" name="phone" value="' . $object->phone . '"></td>';
  665. print '<td>' . $langs->trans('Fax') . '</td><td><input type="text" name="fax" value="' . $object->fax . '"></td></tr>';
  666. print '<tr><td>' . $langs->trans('EMail') . (!empty($conf->global->SOCIETE_MAIL_REQUIRED) ? '*' : '') . '</td><td><input type="text" name="email" size="32" value="' . $object->email . '"></td>';
  667. print '<td>' . $langs->trans('Web') . '</td><td><input type="text" name="url" size="32" value="' . $object->url . '"></td></tr>';
  668. // Prof ids
  669. $i = 1;
  670. $j = 0;
  671. while ($i <= 6) {
  672. $idprof = $langs->transcountry('ProfId' . $i, $object->country_id);
  673. if ($idprof != '-') {
  674. if (($j % 2) == 0)
  675. print '<tr>';
  676. print '<td>' . $idprof . '</td><td>';
  677. $key = 'idprof' . $i;
  678. print $formcompany->get_input_id_prof($i, 'idprof' . $i, $object->$key, $object->country_id);
  679. print '</td>';
  680. if (($j % 2) == 1)
  681. print '</tr>';
  682. $j++;
  683. }
  684. $i++;
  685. }
  686. if ($j % 2 == 1)
  687. print '<td colspan="2"></td></tr>';
  688. // Assujeti TVA
  689. $form = new Form($db);
  690. print '<tr><td>' . $langs->trans('VATIsUsed') . '</td>';
  691. print '<td>';
  692. print $form->selectyesno('assujtva_value', 1, 1); // Assujeti par defaut en creation
  693. print '</td>';
  694. print '<td nowrap="nowrap">' . $langs->trans('VATIntra') . '</td>';
  695. print '<td nowrap="nowrap">';
  696. $s = '<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="' . $object->tva_intra . '">';
  697. if (empty($conf->global->MAIN_DISABLEVATCHECK)) {
  698. $s.=' ';
  699. if (!empty($conf->use_javascript_ajax)) {
  700. print "\n";
  701. print '<script language="JavaScript" type="text/javascript">';
  702. print "function CheckVAT(a) {\n";
  703. print "newpopup('" . DOL_URL_ROOT . "/societe/checkvat/checkVatPopup.php?vatNumber='+a,'" . dol_escape_js($langs->trans("VATIntraCheckableOnEUSite")) . "',500,300);\n";
  704. print "}\n";
  705. print '</script>';
  706. print "\n";
  707. $s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">' . $langs->trans("VATIntraCheck") . '</a>';
  708. $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->trans("VATIntraCheck")), 1);
  709. } else {
  710. $s.='<a href="' . $langs->transcountry("VATIntraCheckURL", $object->country_id) . '" target="_blank">' . img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help') . '</a>';
  711. }
  712. }
  713. print $s;
  714. print '</td>';
  715. print '</tr>';
  716. // Type - Size
  717. print '<tr><td>' . $langs->trans("ThirdPartyType") . '</td><td>' . "\n";
  718. print $object->select_fk_extrafields("typent_id", "typent_id");
  719. if ($user->admin)
  720. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"), 1);
  721. print '</td>';
  722. print '<td>' . $langs->trans("Staff") . '</td><td>';
  723. print $object->select_fk_extrafields("effectif_id", "effectif_id");
  724. if ($user->admin)
  725. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"), 1);
  726. print '</td></tr>';
  727. // Legal Form
  728. print '<tr><td>' . $langs->trans('JuridicalStatus') . '</td>';
  729. print '<td colspan="3">';
  730. if ($object->country_id) {
  731. print $object->select_fk_extrafields("forme_juridique_code", "forme_juridique_code");
  732. } else {
  733. print $countrynotdefined;
  734. }
  735. print '</td></tr>';
  736. // Capital
  737. print '<tr><td>' . $langs->trans('Capital') . '</td><td colspan="3"><input type="text" name="capital" size="10" value="' . $object->capital . '"> ' . $langs->trans("Currency" . $conf->currency) . '</td></tr>';
  738. // Local Taxes
  739. // TODO add specific function by country
  740. if ($mysoc->country_id == 'ES') {
  741. if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
  742. print '<tr><td>' . $langs->trans("LocalTax1IsUsedES") . '</td><td>';
  743. print $form->selectyesno('localtax1assuj_value', 0, 1);
  744. print '</td><td>' . $langs->trans("LocalTax2IsUsedES") . '</td><td>';
  745. print $form->selectyesno('localtax2assuj_value', 0, 1);
  746. print '</td></tr>';
  747. } elseif ($mysoc->localtax1_assuj == "1") {
  748. print '<tr><td>' . $langs->trans("LocalTax1IsUsedES") . '</td><td colspan="3">';
  749. print $form->selectyesno('localtax1assuj_value', 0, 1);
  750. print '</td><tr>';
  751. } elseif ($mysoc->localtax2_assuj == "1") {
  752. print '<tr><td>' . $langs->trans("LocalTax2IsUsedES") . '</td><td colspan="3">';
  753. print $form->selectyesno('localtax2assuj_value', 0, 1);
  754. print '</td><tr>';
  755. }
  756. }
  757. if (!empty($conf->global->MAIN_MULTILANGS)) {
  758. print '<tr><td>' . $langs->trans("DefaultLang") . '</td><td colspan="3">' . "\n";
  759. print $formadmin->select_language(($object->default_lang ? $object->default_lang : $conf->global->MAIN_LANG_DEFAULT), 'default_lang', 0, 0, 1);
  760. print '</td>';
  761. print '</tr>';
  762. }
  763. // Assign a Name
  764. print '<tr>';
  765. print '<td>' . $langs->trans("AllocateCommercial") . '</td>';
  766. print '<td colspan="3">';
  767. if ($user->rights->societe->client->voir) {
  768. $object->commercial_id->id = $user->id;
  769. print $object->select_fk_extrafields("commercial_id", "commercial_id");
  770. } else {
  771. print $user->name;
  772. print '<input type="hidden" name="commercial_id" value=' . $user->id . '>';
  773. }
  774. print '</td></tr>';
  775. // Other attributes
  776. /* $parameters = array('colspan' => ' colspan="3"');
  777. $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  778. if (empty($reshook)) {
  779. foreach ($object->fk_extrafields->fields as $key => $aRow) {
  780. if ($aRow->optional && $aRow->enable) {
  781. $value = (isset($_POST["options_" . $key]) ? $_POST["options_" . $key] : (isset($object->array_options["options_" . $key]) ? $object->array_options["options_" . $key] : ''));
  782. print '<tr><td><strong class="blue">' . $aRow->label . '</strong></td><td colspan="3">';
  783. print $object->fk_extrafields->showInputField($key, $value);
  784. print '</td></tr>' . "\n";
  785. }
  786. }
  787. } */
  788. // Ajout du logo
  789. print '<tr>';
  790. print '<td>' . $langs->trans("Logo") . '</td>';
  791. print '<td colspan="3">';
  792. print '<input class="flat" type="file" name="photo" id="photoinput" />';
  793. print '</td>';
  794. print '</tr>';
  795. print '</table>' . "\n";
  796. print '<br><center>';
  797. print '<input type="submit" class="button" value="' . $langs->trans('AddThirdParty') . '">';
  798. print '</center>' . "\n";
  799. print '</form>' . "\n";
  800. print column_end();
  801. print '</div></div>';
  802. } elseif ($action == 'edit') {
  803. /*
  804. * Edition
  805. */
  806. //print_fiche_titre($langs->trans("EditCompany"));
  807. if ($socid) {
  808. $object = new Societe($db);
  809. $res = $object->fetch($socid);
  810. if ($res < 0) {
  811. dol_print_error($db, $object->error);
  812. exit;
  813. }
  814. //$res = $object->fetch_optionals($object->id, $extralabels);
  815. //if ($res < 0) { dol_print_error($db); exit; }
  816. print_fiche_titre($object->name);
  817. print '<div class="with-padding">';
  818. print '<div class="columns">';
  819. $titre = $langs->trans("ThirdParty");
  820. print column_start();
  821. dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company');
  822. // Load object modCodeTiers
  823. $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard');
  824. if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
  825. $module = substr($module, 0, dol_strlen($module) - 4);
  826. }
  827. $dirsociete = array_merge(array('/societe/core/models/'), $conf->societe_modules);
  828. foreach ($dirsociete as $dirroot) {
  829. $res = dol_include_once($dirroot . $module . '.php');
  830. if ($res)
  831. break;
  832. }
  833. $modCodeClient = new $module($db);
  834. // We verified if the tag prefix is used
  835. if ($modCodeClient->code_auto) {
  836. $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
  837. }
  838. $module = $conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
  839. if (!$module)
  840. $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
  841. if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
  842. $module = substr($module, 0, dol_strlen($module) - 4);
  843. }
  844. $dirsociete = array_merge(array('/societe/core/models/'), $conf->societe_modules);
  845. foreach ($dirsociete as $dirroot) {
  846. $res = dol_include_once($dirroot . $module . '.php');
  847. if ($res)
  848. break;
  849. }
  850. $modCodeFournisseur = new $module($db);
  851. // On verifie si la balise prefix est utilisee
  852. if ($modCodeFournisseur->code_auto) {
  853. $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
  854. }
  855. if (GETPOST('nom')) {
  856. // We overwrite with values if posted
  857. $object->name = GETPOST('nom');
  858. $object->prefix_comm = GETPOST('prefix_comm');
  859. $object->client = GETPOST('client');
  860. $object->code_client = GETPOST('code_client');
  861. $object->fournisseur = GETPOST('fournisseur');
  862. $object->code_fournisseur = GETPOST('code_fournisseur');
  863. $object->address = GETPOST('adresse');
  864. $object->zip = GETPOST('zipcode');
  865. $object->town = GETPOST('town');
  866. $object->country_id = GETPOST('country_id') ? GETPOST('country_id') : $mysoc->country_id;
  867. $object->state_id = GETPOST('departement_id');
  868. $object->phone = GETPOST('phone');
  869. $object->fax = GETPOST('fax');
  870. $object->email = GETPOST('email');
  871. $object->url = GETPOST('url');
  872. $object->capital = GETPOST('capital');
  873. $object->idprof1 = GETPOST('idprof1');
  874. $object->idprof2 = GETPOST('idprof2');
  875. $object->idprof3 = GETPOST('idprof3');
  876. $object->idprof4 = GETPOST('idprof4');
  877. $object->typent_id = GETPOST('typent_id');
  878. $object->effectif_id = GETPOST('effectif_id');
  879. $object->barcode = GETPOST('barcode');
  880. $object->forme_juridique_code = GETPOST('forme_juridique_code');
  881. $object->default_lang = GETPOST('default_lang');
  882. $object->tva_assuj = GETPOST('assujtva_value');
  883. $object->tva_intra = GETPOST('tva_intra');
  884. $object->Status = GETPOST('status');
  885. //Local Taxes
  886. $object->localtax1_assuj = GETPOST('localtax1assuj_value');
  887. $object->localtax2_assuj = GETPOST('localtax2assuj_value');
  888. }
  889. dol_htmloutput_errors($error, $errors);
  890. if ($conf->use_javascript_ajax) {
  891. print "\n" . '<script type="text/javascript" language="javascript">';
  892. print '$(document).ready(function () {
  893. $("#selectcountry_id").change(function() {
  894. document.formsoc.action.value="edit";
  895. document.formsoc.submit();
  896. });
  897. })';
  898. print '</script>' . "\n";
  899. }
  900. print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="post" name="formsoc">';
  901. print '<input type="hidden" name="action" value="update">';
  902. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  903. print '<input type="hidden" name="socid" value="' . $object->id . '">';
  904. if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto)
  905. print '<input type="hidden" name="code_auto" value="1">';
  906. print '<table class="border" width="100%">';
  907. // Name
  908. print '<tr><td><span class="fieldrequired">' . $langs->trans('ThirdPartyName') . '</span></td><td colspan="3"><input type="text" size="40" maxlength="60" name="nom" value="' . $object->name . '"></td></tr>';
  909. // Prefix
  910. if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
  911. print '<tr><td>' . $langs->trans("Prefix") . '</td><td colspan="3">';
  912. // It does not change the prefix mode using the auto numbering prefix
  913. if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm) {
  914. print '<input type="hidden" name="prefix_comm" value="' . $object->prefix_comm . '">';
  915. print $object->prefix_comm;
  916. } else {
  917. print '<input type="text" size="5" maxlength="5" name="prefix_comm" value="' . $object->prefix_comm . '">';
  918. }
  919. print '</td>';
  920. }
  921. // Prospect/Customer
  922. print '<tr><td width="25%"><span class="fieldrequired">' . $langs->trans('ProspectCustomer') . '</span></td><td width="25%"><select class="flat" name="client">';
  923. if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
  924. print '<option value="2"' . ($object->client == 2 ? ' selected="selected"' : '') . '>' . $langs->trans('Prospect') . '</option>';
  925. if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
  926. print '<option value="3"' . ($object->client == 3 ? ' selected="selected"' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
  927. print '<option value="1"' . ($object->client == 1 ? ' selected="selected"' : '') . '>' . $langs->trans('Customer') . '</option>';
  928. print '<option value="0"' . ($object->client == 0 ? ' selected="selected"' : '') . '>' . $langs->trans('NorProspectNorCustomer') . '</option>';
  929. print '</select></td>';
  930. print '<td width="25%">' . $langs->trans('CustomerCode') . '</td><td width="25%">';
  931. print '<table class="nobordernopadding"><tr><td>';
  932. if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto) {
  933. $tmpcode = $object->code_client;
  934. if (empty($tmpcode) && $modCodeClient->code_auto)
  935. $tmpcode = $modCodeClient->getNextValue($object, 0);
  936. print '<input type="text" name="code_client" size="16" value="' . $tmpcode . '" maxlength="15">';
  937. }
  938. else if ($object->codeclient_modifiable()) {
  939. print '<input type="text" name="code_client" size="16" value="' . $object->code_client . '" maxlength="15">';
  940. } else {
  941. print $object->code_client;
  942. print '<input type="hidden" name="code_client" value="' . $object->code_client . '">';
  943. }
  944. print '</td><td>';
  945. $s = $modCodeClient->getToolTip($langs, $object, 0);
  946. print $form->textwithpicto('', $s, 1);
  947. print '</td></tr></table>';
  948. print '</td></tr>';
  949. // Supplier
  950. if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) {
  951. print '<tr>';
  952. print '<td><span class="fieldrequired">' . $langs->trans('Supplier') . '</span></td><td>';
  953. print $form->selectyesno("fournisseur", $object->fournisseur, 1);
  954. print '</td>';
  955. print '<td>' . $langs->trans('SupplierCode') . '</td><td>';
  956. print '<table class="nobordernopadding"><tr><td>';
  957. if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) {
  958. $tmpcode = $object->code_fournisseur;
  959. if (empty($tmpcode) && $modCodeFournisseur->code_auto)
  960. $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
  961. print '<input type="text" name="code_fournisseur" size="16" value="' . $tmpcode . '" maxlength="15">';
  962. }
  963. else if ($object->codefournisseur_modifiable()) {
  964. print '<input type="text" name="code_fournisseur" size="16" value="' . $object->code_fournisseur . '" maxlength="15">';
  965. } else {
  966. print $object->code_fournisseur;
  967. print '<input type="hidden" name="code_fournisseur" value="' . $object->code_fournisseur . '">';
  968. }
  969. print '</td><td>';
  970. $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
  971. print $form->textwithpicto('', $s, 1);
  972. print '</td></tr></table>';
  973. print '</td></tr>';
  974. // Category
  975. if (!empty($conf->categorie->enabled) && $object->fournisseur) {
  976. $load = $object->LoadSupplierCateg();
  977. if ($load == 0) {
  978. if (count($object->SupplierCategories) > 0) {
  979. print '<tr>';
  980. print '<td>' . $langs->trans('SupplierCategory') . '</td><td colspan="3">';
  981. print $form->selectarray("fournisseur_categorie", $object->SupplierCategories, '', 1);
  982. print '</td></tr>';
  983. }
  984. }
  985. }
  986. }
  987. // Barcode
  988. if (!empty($conf->barcode->enabled)) {
  989. print '<tr><td valign="top">' . $langs->trans('Gencod') . '</td><td colspan="3"><input type="text" name="barcode" value="' . $object->barcode . '">';
  990. print '</td></tr>';
  991. }
  992. // Status
  993. print '<tr><td>' . $langs->trans("Status") . '</td><td colspan="3">';
  994. print $object->select_fk_extrafields("Status", 'status');
  995. print '</td></tr>';
  996. // Address
  997. print '<tr><td valign="top">' . $langs->trans('Address') . '</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
  998. print $object->address;
  999. print '</textarea></td></tr>';
  1000. // Zip / Town
  1001. print '<tr><td>' . $langs->trans('Zip') . '</td><td>';
  1002. print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'departement_id'), 6);
  1003. print '</td><td>' . $langs->trans('Town') . '</td><td>';
  1004. print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'departement_id'));
  1005. print '</td></tr>';
  1006. // Country
  1007. print '<tr><td>' . $langs->trans('Country') . '</td><td colspan="3">';
  1008. print $object->select_fk_extrafields("country_id", 'country_id');
  1009. if ($user->admin)
  1010. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"), 1);
  1011. print '</td></tr>';
  1012. // State
  1013. if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
  1014. print '<tr><td>' . $langs->trans('State') . '</td><td colspan="3">';
  1015. print $object->select_fk_extrafields("state_id", "departement_id");
  1016. print '</td></tr>';
  1017. }
  1018. // Phone / Fax
  1019. print '<tr><td>' . $langs->trans('Phone') . '</td><td><input type="text" name="phone" value="' . $object->phone . '"></td>';
  1020. print '<td>' . $langs->trans('Fax') . '</td><td><input type="text" name="fax" value="' . $object->fax . '"></td></tr>';
  1021. // EMail / Web
  1022. print '<tr><td>' . $langs->trans('EMail') . ($conf->global->SOCIETE_MAIL_REQUIRED ? '*' : '') . '</td><td><input type="text" name="email" size="32" value="' . $object->email . '"></td>';
  1023. print '<td>' . $langs->trans('Web') . '</td><td><input type="text" name="url" size="32" value="' . $object->url . '"></td></tr>';
  1024. // Prof ids
  1025. $i = 1;
  1026. $j = 0;
  1027. while ($i <= 6) {
  1028. $idprof = $langs->transcountry('ProfId' . $i, $object->country_id);
  1029. if ($idprof != '-') {
  1030. if (($j % 2) == 0)
  1031. print '<tr>';
  1032. print '<td>' . $idprof . '</td><td>';
  1033. $key = 'idprof' . $i;
  1034. print $formcompany->get_input_id_prof($i, 'idprof' . $i, $object->$key, $object->country_id);
  1035. print '</td>';
  1036. if (($j % 2) == 1)
  1037. print '</tr>';
  1038. $j++;
  1039. }
  1040. $i++;
  1041. }
  1042. if ($j % 2 == 1)
  1043. print '<td colspan="2"></td></tr>';
  1044. // VAT payers
  1045. print '<tr><td>' . $langs->trans('VATIsUsed') . '</td><td>';
  1046. print $form->selectyesno('assujtva_value', $object->tva_assuj, 1);
  1047. print '</td>';
  1048. // VAT Code
  1049. print '<td nowrap="nowrap">' . $langs->trans('VATIntra') . '</td>';
  1050. print '<td nowrap="nowrap">';
  1051. $s = '<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="' . $object->tva_intra . '">';
  1052. if (empty($conf->global->MAIN_DISABLEVATCHECK)) {
  1053. $s.=' &nbsp; ';
  1054. if ($conf->use_javascript_ajax) {
  1055. print "\n";
  1056. print '<script language="JavaScript" type="text/javascript">';
  1057. print "function CheckVAT(a) {\n";
  1058. print "newpopup('" . DOL_URL_ROOT . "/societe/checkvat/checkVatPopup.php?vatNumber='+a,'" . dol_escape_js($langs->trans("VATIntraCheckableOnEUSite")) . "',500,285);\n";
  1059. print "}\n";
  1060. print '</script>';
  1061. print "\n";
  1062. $s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">' . $langs->trans("VATIntraCheck") . '</a>';
  1063. $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->trans("VATIntraCheck")), 1);
  1064. } else {
  1065. $s.='<a href="' . $langs->transcountry("VATIntraCheckURL", $object->id_pays) . '" target="_blank">' . img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help') . '</a>';
  1066. }
  1067. }
  1068. print $s;
  1069. print '</td>';
  1070. print '</tr>';
  1071. // Local Taxes
  1072. // TODO add specific function by country
  1073. if ($mysoc->country_id == 'ES') {
  1074. if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
  1075. print '<tr><td>' . $langs->trans("LocalTax1IsUsedES") . '</td><td>';
  1076. print $form->selectyesno('localtax1assuj_value', $object->localtax1_assuj, 1);
  1077. print '</td><td>' . $langs->trans("LocalTax2IsUsedES") . '</td><td>';
  1078. print $form->selectyesno('localtax2assuj_value', $object->localtax2_assuj, 1);
  1079. print '</td></tr>';
  1080. } elseif ($mysoc->localtax1_assuj == "1") {
  1081. print '<tr><td>' . $langs->trans("LocalTax1IsUsedES") . '</td><td colspan="3">';
  1082. print $form->selectyesno('localtax1assuj_value', $object->localtax1_assuj, 1);
  1083. print '</td></tr>';
  1084. } elseif ($mysoc->localtax2_assuj == "1") {
  1085. print '<tr><td>' . $langs->trans("LocalTax2IsUsedES") . '</td><td colspan="3">';
  1086. print $form->selectyesno('localtax2assuj_value', $object->localtax2_assuj, 1);
  1087. print '</td></tr>';
  1088. }
  1089. }
  1090. // Type - Size
  1091. print '<tr><td>' . $langs->trans("ThirdPartyType") . '</td><td>';
  1092. print $object->select_fk_extrafields("typent_id", "typent_id");
  1093. if ($user->admin)
  1094. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"), 1);
  1095. print '</td>';
  1096. print '<td>' . $langs->trans("Staff") . '</td><td>';
  1097. print $object->select_fk_extrafields("effectif_id", "effectif_id");
  1098. if ($user->admin)
  1099. pr

Large files files are truncated, but you can click here to view the full file