* * 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 3 of the License, or * (at your option) any later version. */ /** * \file idsconnect/supplier_card.php * \ingroup idsconnect * \brief Großhändler anlegen/bearbeiten */ // Dolibarr laden $res = 0; if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; } if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; } if (!$res && file_exists("../main.inc.php")) { $res = @include "../main.inc.php"; } if (!$res && file_exists("../../main.inc.php")) { $res = @include "../../main.inc.php"; } if (!$res) { die("Include of main fails"); } require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; dol_include_once('/idsconnect/class/idssupplier.class.php'); dol_include_once('/idsconnect/class/idsconnect.class.php'); dol_include_once('/idsconnect/lib/idsconnect.lib.php'); /** * @var Conf $conf * @var DoliDB $db * @var Translate $langs * @var User $user */ $langs->loadLangs(array("idsconnect@idsconnect", "admin")); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $id = GETPOSTINT('id'); $object = new IdsSupplier($db); if ($id > 0) { $object->fetch($id); } // Berechtigungsprüfung if ($action == 'create' || $action == 'add') { if (!$user->hasRight('idsconnect', 'config')) { accessforbidden(); } } elseif ($action == 'edit' || $action == 'update') { if (!$user->hasRight('idsconnect', 'config')) { accessforbidden(); } } elseif ($action == 'confirm_delete') { if (!$user->hasRight('idsconnect', 'delete')) { accessforbidden(); } } else { if (!$user->hasRight('idsconnect', 'read')) { accessforbidden(); } } /* * Actions */ // Anlegen if ($action == 'add' && $user->hasRight('idsconnect', 'config')) { if (!verifCond(GETPOST('token', 'alpha') == newToken())) { accessforbidden('Bad CSRF token'); } $object->ref = GETPOST('ref', 'alphanohtml'); $object->label = GETPOST('label', 'alphanohtml'); $object->fk_soc = GETPOSTINT('fk_soc'); $object->ids_url = GETPOST('ids_url', 'alphanohtml'); $object->ids_version = GETPOST('ids_version', 'alphanohtml'); $object->ids_customer_no = GETPOST('ids_customer_no', 'alphanohtml'); $object->ids_username = GETPOST('ids_username', 'alphanohtml'); $object->ids_password = GETPOST('ids_password', 'none'); $object->testmode = GETPOSTINT('testmode'); $object->active = GETPOSTINT('active'); $object->note_public = GETPOST('note_public', 'restricthtml'); $object->note_private = GETPOST('note_private', 'restricthtml'); // Validierung $error = 0; if (empty($object->ref)) { setEventMessages('Referenz ist Pflichtfeld', null, 'errors'); $error++; } if (empty($object->label)) { setEventMessages('Bezeichnung ist Pflichtfeld', null, 'errors'); $error++; } if (empty($object->ids_url)) { setEventMessages('Shop-URL ist Pflichtfeld', null, 'errors'); $error++; } if (empty($object->ids_customer_no)) { setEventMessages('Kundennummer ist Pflichtfeld', null, 'errors'); $error++; } if (!$error) { $result = $object->create($user); if ($result > 0) { setEventMessages($langs->trans("IdsconnectSupplierCreated"), null, 'mesgs'); header('Location: '.$_SERVER['PHP_SELF'].'?id='.$result); exit; } else { setEventMessages($object->error, null, 'errors'); $action = 'create'; } } else { $action = 'create'; } } // Aktualisieren if ($action == 'update' && $user->hasRight('idsconnect', 'config')) { if (!verifCond(GETPOST('token', 'alpha') == newToken())) { accessforbidden('Bad CSRF token'); } $object->ref = GETPOST('ref', 'alphanohtml'); $object->label = GETPOST('label', 'alphanohtml'); $object->fk_soc = GETPOSTINT('fk_soc'); $object->ids_url = GETPOST('ids_url', 'alphanohtml'); $object->ids_version = GETPOST('ids_version', 'alphanohtml'); $object->ids_customer_no = GETPOST('ids_customer_no', 'alphanohtml'); $object->ids_username = GETPOST('ids_username', 'alphanohtml'); // Passwort nur aktualisieren wenn ein neues eingegeben wurde $new_password = GETPOST('ids_password', 'none'); if (!empty($new_password)) { $object->ids_password = $new_password; } $object->testmode = GETPOSTINT('testmode'); $object->active = GETPOSTINT('active'); $object->note_public = GETPOST('note_public', 'restricthtml'); $object->note_private = GETPOST('note_private', 'restricthtml'); $result = $object->update($user); if ($result > 0) { setEventMessages($langs->trans("IdsconnectSupplierUpdated"), null, 'mesgs'); header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); exit; } else { setEventMessages($object->error, null, 'errors'); $action = 'edit'; } } // Löschen if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('idsconnect', 'delete')) { if (!verifCond(GETPOST('token', 'alpha') == newToken())) { accessforbidden('Bad CSRF token'); } $result = $object->delete($user); if ($result > 0) { setEventMessages($langs->trans("IdsconnectSupplierDeleted"), null, 'mesgs'); header('Location: '.DOL_URL_ROOT.'/custom/idsconnect/idsconnectindex.php'); exit; } else { setEventMessages($object->error, null, 'errors'); } } /* * View */ $form = new Form($db); $title = ($action == 'create') ? $langs->trans("IdsconnectSupplierNew") : $langs->trans("IdsconnectSupplierCard"); llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-idsconnect page-supplier_card'); // ============================================================ // Formular: Anlegen oder Bearbeiten // ============================================================ if ($action == 'create' || $action == 'edit') { $isEdit = ($action == 'edit'); print load_fiche_titre($title, '', 'fa-plug'); print '
'; } // ============================================================ // Anzeige: Großhändler-Details // ============================================================ elseif ($id > 0 && $object->id > 0) { // Lösch-Bestätigung if ($action == 'delete') { $formconfirm = $form->formconfirm( $_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Delete'), $langs->trans('IdsconnectSupplierConfirmDelete'), 'confirm_delete', '', 0, 1 ); print $formconfirm; } $head = idsconnectSupplierPrepareHead($object); print dol_get_fiche_head($head, 'supplier', $langs->trans("IdsconnectSupplierCard"), -1, 'fa-plug'); // Testmodus-Banner idsconnectShowTestModeBanner(); print '| '.$langs->trans("IdsconnectSupplierRef").' | '; print ''.htmlspecialchars($object->ref).' |
| '.$langs->trans("IdsconnectSupplierLabel").' | '; print ''.htmlspecialchars($object->label).' |
| '.$langs->trans("IdsconnectSupplierSoc").' | '; print ''.$soc->getNomUrl(1).' |
| '.$langs->trans("IdsconnectSupplierUrl").' | '; print ''.htmlspecialchars($object->ids_url).' |
| '.$langs->trans("IdsconnectSupplierVersion").' | '; print 'IDS '.htmlspecialchars($object->ids_version).' |
| '.$langs->trans("IdsconnectSupplierCustomerNo").' | '; print ''.htmlspecialchars($object->ids_customer_no).' |
| '.$langs->trans("IdsconnectSupplierUsername").' | '; print ''.htmlspecialchars($object->ids_username).' |
| '.$langs->trans("IdsconnectSupplierPassword").' | '; print ''.$object->getMaskedPassword().' |
| '.$langs->trans("IdsconnectSupplierTestmode").' | '; print ''.yn($object->testmode).' |
| '.$langs->trans("IdsconnectSupplierActive").' | '; print ''.yn($object->active).' |
| '.$langs->trans("DateCreation").' | '; print ''.dol_print_date($object->date_creation, 'dayhour').' |