/** * Overloading the doActions function : replacing the parent's function with the one below * * @param array() $parameters Hook metadatas (context, etc...) * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) * @param string &$action Current action (if set). Generally create or edit or null * @param HookManager $hookmanager Hook manager propagated to allow calling another hook * @return int < 0 on error, 0 on success, 1 to replace standard code */ function doActions($parameters, &$object, &$action, $hookmanager) { if (in_array('invoicecard', explode(':', $parameters['context']))) { if ($action == 'update_courrier') { global $user, $db, $langs; $object->array_options['options_courrier_envoi'] = time(); $object->insertExtraFields(); dol_include_once('/comm/action/class/actioncomm.class.php'); $a = new ActionComm($db); $a->type_code = 'AC_OTH_AUTO'; $a->label = $langs->trans('ClassifyCourrierEvent', $object->ref); $a->fk_element = $object->id; $a->elementtype = 'facture'; $a->usertodo = $user; $a->userdone = $user; $a->percentage = 100; $a->datep = date('Y-m-d H:i:s'); $a->add($user); setEventMessage('ClassifyCourrierMsg'); } else { if ($action == 'no_courrier') { global $user; $object->array_options['options_courrier_envoi'] = ''; $object->insertExtraFields(); setEventMessage('UnClassifyCourrierMsg'); } } } return 0; }
function _createOFCommande(&$PDOdb, $TProduct, $TQuantites, $fk_commande, $fk_soc, $oneOF = false) { global $db, $langs; if (!empty($TProduct)) { if ($oneOF) { $assetOf = new TAssetOF(); $assetOf->fk_commande = $fk_commande; } foreach ($TProduct as $fk_commandedet => $v) { foreach ($v as $fk_product => $dummy) { if (!$oneOF) { $assetOf = new TAssetOF(); $assetOf->fk_commande = $fk_commande; } if ($assetOf->fk_commande > 0) { $com = new Commande($db); //TODO on est pas censé toujours être sur la même commande ? AA $com->fetch($assetOf->fk_commande); $assetOf->fk_project = $com->fk_project; if (!empty($com->date_livraison)) { $assetOf->date_besoin = $com->date_livraison; } } /* pre($TQuantites,true); pre($TProduct,true);exit;*/ $qty = $TQuantites[$fk_commandedet]; //print "$fk_product x $qty<br />"; $assetOf->fk_soc = $fk_soc; $assetOf->addLine($PDOdb, $fk_product, 'TO_MAKE', $qty, 0, '', 0, $fk_commandedet); $assetOf->save($PDOdb); } } setEventMessage($langs->trans('OFAsset') . " créé(s) avec succès", 'mesgs'); } }
function updateAllSoc(&$PDOdb) { global $langs, $conf, $user, $db; $TUser = TCommercialCategory::getUser($PDOdb, $this->fk_category); // useless, just for popup $nb_user = count($TUser); $TSociete = TCommercialCategory::getSociete($PDOdb, $this->fk_category); $nb_soc = count($TSociete); foreach ($TSociete as &$soc) { self::updateSociete($PDOdb, $soc); } setEventMessage($langs->trans('CategUserAffectation', $nb_user, $nb_soc)); }
static function del(&$PDOdb, $id_charge) { $recurrence = self::get_recurrence($PDOdb, $id_charge); if (isset($recurrence)) { $message = 'Récurrence de la charge sociale ' . $id_charge . ' supprimée.'; setEventMessage($message); return $recurrence->delete($PDOdb); } else { $message = 'Suppression impossible : Récurrence de la charge sociale ' . $id_charge . ' introuvable.'; setEventMessage($message, 'errors'); return false; } }
public function formObjectOptions($parameters, &$object, &$action, HookManager $hookManager) { global $db, $user, $langs, $mysoc, $dolibarr_main_cookie_cryptkey; $langs->load('otp@otp'); $regenerate_button = '<form method="post"> <input type="submit" value="' . $langs->trans('OTPRegenerate') . '" class="button" name="regenerate_otp"> </form>'; if ($action == '') { print '<tr><td>' . $langs->trans('OTPLogin') . '</td><td colspan="2">'; if (GETPOST('regenerate_otp')) { if ($user->admin || $user->id == GETPOST('id', 'int')) { /** * Examples from http://es.php.net/mcrypt_encrypt */ // Generates a 20-byte (160-bit) secret key $otpSeed = Seed::generate(); $base32Seed = $otpSeed->getValue(Seed::FORMAT_BASE32); $key = pack('H*', $dolibarr_main_cookie_cryptkey); # crear una aleatoria IV para utilizarla co condificación CBC $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $base32Seed, MCRYPT_MODE_CBC, $iv); # anteponer la IV para que esté disponible para el descifrado $ciphertext = $iv . $ciphertext; # codificar el texto cifrado resultante para que pueda ser representado por un string $ciphertext_base64 = base64_encode($ciphertext); $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET otp_seed = '" . $db->escape($ciphertext_base64) . "', otp_counter = 0 WHERE rowid = " . $user->id; $db->query($sql); $qrCode = new QrCode(); $qrCode->setText("otpauth://hotp/" . $mysoc->name . ":" . $user->login . "?secret=" . $base32Seed . "&issuer=" . $mysoc->name); $qrCode->setSize(96); $qrCode->setPadding(5); $img_path = __DIR__ . '/../tmp/' . $user->id . '.png'; $qrCode->save($img_path); //Qrcode library doesn't warn on image creation error if (file_exists($img_path)) { print '<img src="' . dol_buildpath('/otp/showdoc.php', 1) . '?img=' . $user->id . '"><br>' . $langs->trans('OTPTroubleHash') . '<br /> <span style="font-family:monospace;font-size:20px">' . $base32Seed . '</span><br>' . $langs->trans('OTPKeyType'); } else { print $regenerate_button; setEventMessage('ErrorCreatingImage', 'errors'); } } } else { if ($user->admin || $user->id == GETPOST('id', 'int')) { print $regenerate_button; } } print '</td></tr>'; } }
function doActions($parameters, &$object, &$action) { global $langs, $user; $langs->load('resource@resource'); if (in_array('element_resource', explode(':', $parameters['context']))) { // Efface une ressource if ($action == 'confirm_delete_resource' && $user->rights->resource->delete && GETPOST('confirm') == 'yes') { $res = $object->fetch(GETPOST('lineid')); if ($res) { $result = $object->delete_resource(GETPOST('lineid'), GETPOST('element')); if ($result >= 0) { setEventMessage($langs->trans('RessourceLineSuccessfullyDeleted')); Header("Location: " . $_SERVER['PHP_SELF'] . "?element=" . GETPOST('element') . "&element_id=" . GETPOST('element_id')); exit; } else { setEventMessage($object->error, 'errors'); } } } // Update ressource if ($action == 'update_resource' && $user->rights->resource->write && !GETPOST('cancel')) { $res = $object->fetch(GETPOST('lineid')); if ($res) { $object->id = GETPOST('lineid'); $object->busy = GETPOST('busy'); $object->mandatory = GETPOST('mandatory'); $result = $object->update(); if ($result >= 0) { setEventMessage($langs->trans('RessourceLineSuccessfullyUpdated')); Header("Location: " . $_SERVER['PHP_SELF'] . "?element=" . GETPOST('element') . "&element_id=" . GETPOST('element_id')); exit; } else { setEventMessage($object->error, 'errors'); } } } } }
static function del(&$PDOdb, $id_charge) { global $conf, $db, $user; $recurrence = self::get_recurrence($PDOdb, $id_charge); if (isset($recurrence)) { $message = 'Récurrence de la charge sociale ' . $id_charge . ' supprimée.'; setEventMessage($message); //Suppression de toutes les charges sociales créé dans le futur lié à cette récurrence if ($conf->global->RECURRENCE_DELETE_FUTUR_SOCIAL_TAXES) { $TCharges = self::get_prochaines_charges($PDOdb, $id_charge, date('Y-m-d')); foreach ($TCharges as $charge) { $chargesocial = new ChargeSociales($db); $chargesocial->fetch($charge->rowid); $chargesocial->delete($user); } } return $recurrence->delete($PDOdb); } else { $message = 'Suppression impossible : Récurrence de la charge sociale ' . $id_charge . ' introuvable.'; setEventMessage($message, 'errors'); return false; } }
function mouvement(&$PDOdb, &$object, $fk_product, $qty, $fk_warehouse_from, $fk_warehouse_to) { global $db, $user, $langs; dol_include_once('/product/stock/class/mouvementstock.class.php'); dol_include_once('/product/class/product.class.php'); /*var_dump($fk_product, $qty,$fk_warehouse_from, $fk_warehouse_to); exit; */ $stock = new MouvementStock($db); $label = ''; if (method_exists($object, 'getNomUrl')) { $label .= $object->getNomUrl(1); } if (!empty($conf->global->ROUTING_INFO_ALERT)) { $product = new Product($db); $product->fetch($fk_product); $msg = $product->getNomUrl(0) . ' ' . $product->label . ' ' . $langs->trans('MoveFrom') . ' ' . $wh_from_label . ' ' . $langs->trans('MoveTo') . ' ' . $wh_to_label; setEventMessage($msg); } $stock->origin = $object; $stock->reception($user, $fk_product, $fk_warehouse_to, $qty, 0, $label); $stock->livraison($user, $fk_product, $fk_warehouse_from, $qty, 0, $label); }
exit; } if (GETPOST("action") == 'setremise') { $soc = new Societe($db); $soc->fetch($_GET["id"]); $result = $soc->set_remise_client($_POST["remise"], $_POST["note"], $user); if ($result > 0) { if (!empty($backtopage)) { header("Location: " . $backtopage); exit; } else { header("Location: remise.php?id=" . $_GET["id"]); exit; } } else { setEventMessage($soc->error, 'errors'); } } /* * View */ $form = new Form($db); llxHeader(); /********************************************************************************* * * Mode fiche * *********************************************************************************/ if ($socid > 0) { // On recupere les donnees societes par l'objet $objsoc = new Societe($db);
$object->fk_parent = $parent; } $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if (!$object->label) { $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")); $action = 'create'; } // Create category in database if (!$error) { $result = $object->create($user); if ($result > 0) { $action = 'confirmed'; $_POST["addcat"] = ''; } else { setEventMessage($object->error, 'errors'); } } } // Confirm action if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->creer) { // Action confirmation de creation categorie if ($action == 'confirmed') { if ($urlfrom) { header("Location: " . $urlfrom); exit; } else { if ($idProdOrigin) { header("Location: " . DOL_URL_ROOT . '/categories/categorie.php?id=' . $idProdOrigin . '&mesg=' . urlencode($langs->trans("CatCreated"))); exit; } else {
} $limit = $conf->liste_limit; $offset = $limit * $page; if (!$user->admin) { accessforbidden(); } /* * Actions */ if ($action == 'delete') { $file = $conf->admin->dir_output . '/' . GETPOST('urlfile'); $ret = dol_delete_file($file, 1); if ($ret) { setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); } else { setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); } $action = ''; } /* * View */ $form = new Form($db); $formfile = new FormFile($db); $label = getStaticMember($db, 'label'); $help_url = 'EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad'; llxHeader('', '', $help_url); ?> <script type="text/javascript"> jQuery(document).ready(function() {
} if ($result >= 0) { $db->commit(); header("Location: " . DOL_URL_ROOT . '/compta/salaries/index.php'); exit; } else { $object->error = $accountline->error; $db->rollback(); setEventMessage($object->error, 'errors'); } } else { $db->rollback(); setEventMessage($object->error, 'errors'); } } else { setEventMessage('Error try do delete a line linked to a conciliated bank transaction', 'errors'); } } /* * View */ llxHeader(); $form = new Form($db); if ($id) { $object = new PaymentSalary($db); $result = $object->fetch($id); if ($result <= 0) { dol_print_error($db); exit; } }
//Verify if process() works $res = $price_updaters->process(); if ($res > 0) { $res = $price_updaters->update($user); } if ($res > 0) { $action = ''; } else { setEventMessage($price_updaters->error, 'errors'); } } elseif ($action == 'delete_updater') { $res = $price_updaters->delete($selection, $user); if ($res > 0) { $action = ''; } else { setEventMessage($price_updaters->error, 'errors'); } } } elseif (!empty($cancel)) { $action = ''; } /* * View */ //Header llxHeader("", "", $langs->trans("CardProduct" . $product->type)); print load_fiche_titre($langs->trans("DynamicPriceConfiguration")); $form = new Form($db); //Global variables table if ($action != 'create_updater' && $action != 'edit_updater') { print $langs->trans("GlobalVariables");
// j is module number. Automatically affected if module number not defined. $modNameLoaded = array(); foreach ($modulesdir as $dir) { // Load modules attributes in arrays (name, numero, orders) from dir directory //print $dir."\n<br>"; dol_syslog("Scan directory " . $dir . " for module descriptor files (modXXX.class.php)"); $handle = @opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { //print "$i ".$file."\n<br>"; if (is_readable($dir . $file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { $modName = substr($file, 0, dol_strlen($file) - 10); if ($modName) { if (!empty($modNameLoaded[$modName])) { $mesg = "Error: Module " . $modName . " was found twice: Into " . $modNameLoaded[$modName] . " and " . $dir . ". You probably have an old file on your disk.<br>"; setEventMessage($mesg, 'warnings'); dol_syslog($mesg, LOG_ERR); continue; } try { $res = (include_once $dir . $file); if (class_exists($modName)) { try { $objMod = new $modName($db); $modNameLoaded[$modName] = $dir; if ($objMod->numero > 0) { $j = $objMod->numero; } else { $j = 1000 + $i; } $modulequalified = 1;
exit; } else { $action = 'create'; setEventMessage($menu->error, 'errors'); } } } // delete if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes') { $this->db->begin(); $sql = "DELETE FROM " . MAIN_DB_PREFIX . "menu WHERE rowid = " . $_GET['menuId']; $db->query($sql); if ($result == 0) { $this->db->commit(); llxHeader(); setEventMessage($langs->trans("MenuDeleted")); llxFooter(); exit; } else { $this->db->rollback(); $reload = 0; $_GET["action"] = ''; } } /* * View */ $form = new Form($db); $formadmin = new FormAdmin($db); llxHeader('', $langs->trans("Menu")); if ($action == 'create') {
/** * Fill array_options property of object by extrafields value (using for data sent by forms) * * @param array $extralabels $array of extrafields * @param object $object Object * @param string $onlykey Only following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must must set this to avoid to have other extrafields being reset. * @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example) */ function setOptionalsFromPost($extralabels, &$object, $onlykey = '') { global $_POST, $langs; $nofillrequired = ''; // For error when required field left blank $error_field_required = array(); if (is_array($extralabels)) { // Get extra fields foreach ($extralabels as $key => $value) { if (!empty($onlykey) && $key != $onlykey) { continue; } $key_type = $this->attribute_type[$key]; if ($this->attribute_required[$key] && !GETPOST("options_{$key}", 2)) { $nofillrequired++; $error_field_required[] = $value; } if (in_array($key_type, array('date', 'datetime'))) { // Clean parameters $value_key = dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]); } else { if (in_array($key_type, array('checkbox', 'chkbxlst'))) { $value_arr = GETPOST("options_" . $key); if (!empty($value_arr)) { $value_key = implode($value_arr, ','); } else { $value_key = ''; } } else { if (in_array($key_type, array('price', 'double'))) { $value_arr = GETPOST("options_" . $key); $value_key = price2num($value_arr); } else { $value_key = GETPOST("options_" . $key); } } } $object->array_options["options_" . $key] = $value_key; } if ($nofillrequired) { $langs->load('errors'); setEventMessage($langs->trans('ErrorFieldsRequired') . ' : ' . implode(', ', $error_field_required), 'errors'); return -1; } else { return 1; } } else { return 0; } }
$object->fetch($id); $res = $object->update_num($_POST['num_paiement']); if ($res === 0) { setEventMessage($langs->trans('PaymentNumberUpdateSucceeded')); } else { setEventMessage($langs->trans('PaymentNumberUpdateFailed'), 'errors'); } } if ($action == 'setdatep' && !empty($_POST['datepday'])) { $object->fetch($id); $datepaye = dol_mktime(12, 0, 0, $_POST['datepmonth'], $_POST['datepday'], $_POST['datepyear']); $res = $object->update_date($datepaye); if ($res === 0) { setEventMessage($langs->trans('PaymentDateUpdateSucceeded')); } else { setEventMessage($langs->trans('PaymentDateUpdateFailed'), 'errors'); } } /* * View */ llxHeader(); $thirdpartystatic = new Societe($db); $result = $object->fetch($id); if ($result <= 0) { dol_print_error($db, 'Payement ' . $id . ' not found in database'); exit; } $form = new Form($db); $head = payment_prepare_head($object); dol_fiche_head($head, 'payment', $langs->trans("PaymentCustomerInvoice"), 0, 'payment');
// Do not use urldecode here ($_GET and $_POST are already decoded by PHP). $ret = dol_delete_file($file); if ($ret) { setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); } else { setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); } $result = $ecmdir->changeNbOfFiles('-'); clearstatcache(); } $action = 'file_manager'; } // Remove directory if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes') { $result = $ecmdir->delete($user); setEventMessage($langs->trans("ECMSectionWasRemoved", $ecmdir->label)); clearstatcache(); } // Refresh directory view if ($action == 'refreshmanual') { $ecmdirtmp = new EcmDirectory($db); // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate clearstatcache(); $diroutputslash = str_replace('\\', '/', $conf->ecm->dir_output); $diroutputslash .= '/'; // Scan directory tree on disk $disktree = dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0); // Scan directory tree in database $sqltree = $ecmdirstatic->get_full_arbo(0); $adirwascreated = 0; // Now we compare both trees to complete missing trees into database
setEventMessage($langs->trans("SetupSaved")); } else { setEventMessage($langs->trans("Error"), 'errors'); } } else { if ($action == 'set_COMMANDE_FREE_TEXT') { $freetext = GETPOST("COMMANDE_FREE_TEXT"); // No alpha here, we want exact string $res = dolibarr_set_const($db, "COMMANDE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); if (!$res > 0) { $error++; } if (!$error) { setEventMessage($langs->trans("SetupSaved")); } else { setEventMessage($langs->trans("Error"), 'errors'); } } else { if ($action == 'setModuleOptions') { if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF_ODT_PATH", GETPOST('value1'), 'chaine', 0, '', $conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent $conf->global->COMMANDE_ADDON_PDF_ODT_PATH = GETPOST('value1'); } } } } } } } }
print '</td>'; print '<td>' . $langs->trans("to") . ' '; print $form->select_date($datee, 'datee', 0, 0, 1); print '</td>'; print '<td>'; print '<input type="submit" name="refresh" value="' . $langs->trans("Refresh") . '" class="button">'; print '</td>'; print '</tr></table>'; print '</form><br>'; $showdatefilter++; } print '<br>'; print_titre($langs->trans($title)); $selectList = $formproject->select_element($tablename, $project->thirdparty->id); if (!$selectList || $selectList < 0) { setEventMessage($formproject->error, 'errors'); } else { print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $projectid . '" method="post">'; print '<input type="hidden" name="tablename" value="' . $tablename . '">'; print '<input type="hidden" name="action" value="addelement">'; print '<input type="hidden" name="datesrfc" value="' . dol_print_date($dates, 'dayhourrfc') . '">'; print '<input type="hidden" name="dateerfc" value="' . dol_print_date($datee, 'dayhourrfc') . '">'; print '<table><tr><td>' . $langs->trans("SelectElement") . '</td>'; print '<td>' . $selectList . '</td>'; print '<td><input type="submit" class="button" value="' . dol_escape_htmltag($langs->trans("AddElement")) . '"></td>'; print '</tr></table>'; print '</form>'; } print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td width="100" colspan="2">' . $langs->trans("Ref") . '</td>';
/** * Function called when a Dolibarrr business event is done. * All functions "run_trigger" are triggered if file * is inside directory core/triggers * * @param string $action Event action code * @param Object $object Object * @param User $user Object user * @param Translate $langs Object langs * @param conf $conf Object conf * @return int <0 if KO, 0 if no triggered ran, >0 if OK */ public function run_trigger($action, $object, $user, $langs, $conf) { global $conf, $user, $db; // Put here code you want to execute when a Dolibarr business events occurs. // Data and type of action are stored into $object and $action // Users $db =& $this->db; //echo $action.'<br>'; if ($action == 'PROPAL_VALIDATE' && $conf->global->PROPALEHISTORY_AUTO_ARCHIVE) { define('INC_FROM_DOLIBARR', true); dol_include_once("/propalehistory/config.php"); dol_include_once("/comm/propal/class/propal.class.php"); dol_include_once('/propalehistory/class/propaleHist.class.php'); if (isset($_REQUEST['mesg'])) { setEventMessage($_REQUEST['mesg']); } $ATMdb = new TPDOdb(); TPropaleHist::archiverPropale($ATMdb, $object); dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); } return 0; }
$userAccess = 0; /* * Actions */ if ($action == 'createtask' && $user->rights->projet->creer) { $error = 0; $date_start = dol_mktime($_POST['dateohour'], $_POST['dateomin'], 0, $_POST['dateomonth'], $_POST['dateoday'], $_POST['dateoyear'], 'user'); $date_end = dol_mktime($_POST['dateehour'], $_POST['dateemin'], 0, $_POST['dateemonth'], $_POST['dateeday'], $_POST['dateeyear'], 'user'); if (empty($_POST["cancel"])) { if (empty($label)) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), 'errors'); $action = 'create'; $error++; } else { if (empty($_POST['task_parent'])) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("ChildOfTask")), 'errors'); $action = 'create'; $error++; } } if (!$error) { $tmparray = explode('_', $_POST['task_parent']); $projectid = $tmparray[0]; if (empty($projectid)) { $projectid = $id; } // If projectid is '' $task_parent = $tmparray[1]; if (empty($task_parent)) { $task_parent = 0; }
} if (!$error) { $result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT . '/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert'); } if (!($result > 0)) { $error++; } if (!$error) { setEventMessage($langs->trans("TransferFromToDone", $accountfrom->label, $accountto->label, $amount, $langs->trans(currency_name($conf->currency)))); $db->commit(); } else { setEventMessage($accountfrom->error . ' ' . $accountto->error, "errors"); $db->rollback(); } } else { setEventMessage($langs->trans("ErrorFromToAccountsMustDiffers"), "errors"); } } } /* * Affichage */ $helpurl = 'EN:Module_DoliPos|FR:Module_DoliPos_FR|ES:Módulo_DoliPos'; llxHeader('', '', $helpurl); $html = new Form($db); print_fiche_titre($langs->trans("BankTransfer")); dol_htmloutput_events(); print $langs->trans("TransferDesc"); print "<br><br>"; print "<form name='add' method=\"post\" action=\"transfers.php\">"; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
$result = $object->setClose($user); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } } if ($action == 'confirm_reopen' && GETPOST('confirm') == 'yes') { $result = $object->setValid($user); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } } if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer) { $object->fetch($id); $result = $object->delete($user); if ($result > 0) { setEventMessage($langs->trans("RecordDeleted"), 'info'); header("Location: index.php"); exit; } else { dol_syslog($object->error, LOG_DEBUG); setEventMessages($object->error, $object->errors, 'errors'); } } if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confirm') == 'yes') { $clone_contacts = GETPOST('clone_contacts') ? 1 : 0; $clone_tasks = GETPOST('clone_tasks') ? 1 : 0; $clone_project_files = GETPOST('clone_project_files') ? 1 : 0; $clone_task_files = GETPOST('clone_task_files') ? 1 : 0; $clone_notes = GETPOST('clone_notes') ? 1 : 0; $move_date = GETPOST('move_date') ? 1 : 0; $result = $object->createFromClone($object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date);
} else { print $langs->trans('None'); } print "\n" . '<div class="tabsAction">' . "\n"; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '">' . $langs->trans("Ok") . '</a></div>'; print "\n</div><br>\n"; } else { // View mode // Count total nb of records $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter); } $result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); if ($result < 0) { setEventMessage($prodcustprice->error, 'errors'); } $option = '&search_soc=' . $search_soc . '&id=' . $object->id; print_barre_liste($langs->trans('PriceByCustomer'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords); if (count($prodcustprice->lines) > 0) { print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">'; print '<input type="hidden" name="id" value="' . $object->id . '">'; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td>' . $langs->trans("Product") . '</td>'; print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>'; print '<td align="center">' . $langs->trans("PriceBase") . '</td>'; print '<td align="right">' . $langs->trans("VAT") . '</td>'; print '<td align="right">' . $langs->trans("HT") . '</td>'; print '<td align="right">' . $langs->trans("TTC") . '</td>'; print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
setEventMessage($langs->trans("SetupSaved")); } else { $db->rollback(); dol_print_error($db); } } /* * View */ llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP'); $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>'; print_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives if (!function_exists("ldap_connect")) { setEventMessage($langs->trans("LDAPFunctionsNotAvailableOnPHP"), 'errors'); } dol_fiche_head($head, 'contacts', $langs->trans("LDAPSetup")); print $langs->trans("LDAPDescContact") . '<br>'; print '<br>'; print '<form method="post" action="' . $_SERVER["PHP_SELF"] . '?action=setvalue">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; $form = new Form($db); print '<table class="noborder" width="100%">'; $var = true; print '<tr class="liste_titre">'; print '<td colspan="4">' . $langs->trans("LDAPSynchronizeContacts") . '</td>'; print "</tr>\n"; // DN Pour les contacts $var = !$var; print '<tr ' . $bc[$var] . '><td width="25%"><span class="fieldrequired">' . $langs->trans("LDAPContactDn") . '</span></td><td>';
$res = $link->delete($user); $langs->load('link'); if ($res) { setEventMessage($langs->trans("LinkRemoved", $link->label)); } else { setEventMessage($langs->trans("ErrorFailedToDeleteLink", $link->label), 'errors'); } } header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (!empty($withproject) ? '&withproject=1' : '')); exit; } } elseif ($action == 'confirm_updateline' && GETPOST('save') && GETPOST('link', 'alpha')) { require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; $langs->load('link'); $link = new Link($db); $link->id = GETPOST('linkid', 'int'); $f = $link->fetch(); if ($f) { $link->url = GETPOST('link', 'alpha'); if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://') { $link->url = 'http://' . $link->url; } $link->label = GETPOST('label', 'alpha'); $res = $link->update($user); if (!$res) { setEventMessage($langs->trans("ErrorFailedToUpdateLink", $link->label)); } } else { //error fetching } }
$error = 0; $db->begin(); $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; $sql1 .= " SET fd.fk_code_ventilation = 0"; $sql1 .= " WHERE fd.fk_facture_fourn IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; $sql1 .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; $sql1 .= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "')"; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); if (!$resql1) { $error++; $db->rollback(); setEventMessage($db->lasterror(), 'errors'); } else { $db->commit(); setEventMessage($langs->trans('Done'), 'mesgs'); } } /* * View */ llxHeader('', $langs->trans("SuppliersVentilation")); $textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>'; $textnextyear = ' <a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>'; print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear); print '<b>' . $langs->trans("DescVentilSupplier") . '</b>'; print '<div class="inline-block divButAction">'; print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>'; print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>'; print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>'; print '</div>';
if ($mailfile->error) { $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); $mesg .= '<br>' . $mailfile->error; } else { $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; } $mesg .= '</div>'; setEventMessage($mesg, 'warnings'); $action = 'presend'; } } /* } else { $langs->load("other"); $mesgs[]='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').'</div>'; dol_syslog('Recipient email is empty'); }*/ } else { $langs->load("errors"); setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("MailTo")), 'warnings'); dol_syslog('Try to send email with no recipiend defined', LOG_WARNING); $action = 'presend'; } } else { $langs->load("other"); setEventMessage($langs->trans('ErrorFailedToReadEntity', $object->element), 'errors'); dol_syslog('Failed to read data of object id=' . $object->id . ' element=' . $object->element); $action = 'presend'; } }
/** * Overloading the doActions function : replacing the parent's function with the one below * * @param array() $parameters Hook metadatas (context, etc...) * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) * @param string &$action Current action (if set). Generally create or edit or null * @param HookManager $hookmanager Hook manager propagated to allow calling another hook * @return int < 0 on error, 0 on success, 1 to replace standard code */ function blockRelated($parameters, &$object, &$action, $hookmanager, $moreStyle = '') { global $langs, $db, $user, $conf, $related_link_added; $error = 0; // Error counter //var_dump($objet); define('INC_FROM_DOLIBARR', true); dol_include_once('/related/config.php'); $PDOdb = new TPDOdb(); $langs->load('related@related'); if (GETPOST('action') == 'add_related_link' && !$related_link_added) { $type = GETPOST('type_related_object'); //var_dump($type);exit; if ($type == 'projet') { $type = 'project'; } else { if ($type == 'invoice') { $type = 'facture'; } else { if ($type == 'company') { $type = 'societe'; } else { if ($type == 'facture_fournisseur') { $type = 'invoice_supplier'; } else { if ($type == 'commande_fournisseur') { $type = 'order_supplier'; } } } } } $res = $object->add_object_linked($type, GETPOST('id_related_object')); $object->fetchObjectLinked(); if (empty($res)) { setEventMessage($langs->trans('RelationCantBeAdded'), 'errors'); } else { $related_link_added = true; global $langs, $conf; dol_include_once('/core/class/interfaces.class.php'); $interface = new Interfaces($db); $object->id_related_object = GETPOST('id_related_object'); $object->type_related_object = $type; $result = $interface->run_triggers('RELATED_ADD_LINK', $object, $user, $langs, $conf); if ($result < 0) { if (!empty($this->errors)) { $this->errors = array_merge($this->errors, $interface->errors); } else { $this->errors = $interface->errors; } } setEventMessage($langs->trans('RelationAdded')); } } elseif (GETPOST('action') == 'delete_related_link') { $idLink = GETPOST('id_link'); if ($idLink) { $PDOdb->Execute("DELETE FROM " . MAIN_DB_PREFIX . "element_element WHERE rowid = " . $idLink); $object->fetchObjectLinked(); } } else { //var_dump($object); if (empty($object->linkedObjects)) { $object->fetchObjectLinked(); } } //var_dump($object->linkedObjectsIds); ?> <div class="blockrelated_content" style="<?php echo $moreStyle; ?> "> <form name="formLinkObj" action="<?php echo $_SERVER['PHP_SELF']; ?> " method="post"> <input type="hidden" name="action" value="add_related_link" /> <input type="hidden" name="id" value="<?php echo GETPOST('id'); ?> " /> <input type="hidden" name="facid" value="<?php echo GETPOST('facid'); ?> " /> <br> <div class="titre"><?php echo $langs->trans('ElementToLink'); ?> </div> <input type="hidden" id="id_related_object" name="id_related_object" value="" /> <input type="hidden" id="type_related_object" name="type_related_object" value="" /> <table class="noborder allwidth"> <tr class="liste_titre"> <td><?php echo $langs->trans("Ref"); ?> <input type="text" id="add_related_object" name="add_related_object" value="" class="flat" /> <input type="submit" id="bt_add_related_object" name="bt_add_related_object" class="button" value="<?php echo $langs->trans('AddRelated'); ?> " style="display:none" /></td> <td align="center"><?php echo $langs->trans("Date"); ?> </td> <td align="center"><?php echo $langs->trans("Status"); ?> </td> <td align="center"><?php echo $langs->trans("Action"); ?> </td> </tr> <?php $class = 'pair'; foreach ($object->linkedObjectsIds as $objecttype => &$TSubIdObject) { //var_dump($objecttype); if (isset($object->linkedObjects[$objecttype]) && $objecttype != 'societe' && $objecttype != 'product' && $object->element != 'project') { continue; } // on affiche ici que les objects non géré en natif foreach ($TSubIdObject as $id_object) { $date_create = 0; $classname = ucfirst($objecttype); $statut = 'N/A'; if ($objecttype == 'task') { dol_include_once('/projet/class/task.class.php'); } else { if ($objecttype == 'event' || $objecttype == 'action') { dol_include_once('/comm/action/class/actioncomm.class.php'); $classname = 'ActionComm'; } else { if ($objecttype == 'project') { dol_include_once('/projet/class/project.class.php'); } else { if ($objecttype == 'ordre_fabrication') { dol_include_once('/of/class/ordre_fabrication_asset.class.php'); $classname = 'TAssetOf'; $abricot = true; } } } } if (!class_exists($classname)) { $link = 'CantInstanciateClass ' . $classname; } else { if (!empty($abricot)) { if (empty($PDOdb)) { $PDOdb = new TPDOdb(); } $subobject = new $classname(); $subobject->load($PDOdb, $id_object); if (method_exists($subobject, 'getNomUrl')) { $link = $subobject->getNomUrl(1); } else { $link = $id_object . '/' . $classname; } $class = $class == 'impair' ? 'pair' : 'impair'; $date_create = $subobject->date_cre; if (method_exists($subobject, 'getLibStatut')) { $statut = $subobject->getLibStatut(3); } } else { $subobject = new $classname($db); $subobject->fetch($id_object); if (method_exists($subobject, 'getNomUrl')) { $link = $subobject->getNomUrl(1); } else { $link = $id_object . '/' . $classname; } $class = $class == 'impair' ? 'pair' : 'impair'; if (!empty($subobject->date_creation)) { $date_create = $subobject->date_creation; } if (empty($date_create) && !empty($subobject->date_create)) { $date_create = $subobject->date_create; } if (empty($date_create) && !empty($subobject->date_c)) { $date_create = $subobject->date_c; } if (method_exists($subobject, 'getLibStatut')) { $statut = $subobject->getLibStatut(3); } } } $Tids = TRequeteCore::get_id_from_what_you_want($PDOdb, MAIN_DB_PREFIX . "element_element", array('fk_source' => $id_object, 'fk_target' => $object->id, 'sourcetype' => $objecttype, 'targettype' => $object->element)); ?> <tr class="<?php echo $class; ?> "> <td><?php echo $link; ?> </td> <td align="center"><?php echo !empty($date_create) ? dol_print_date($date_create, 'day') : ''; ?> </td> <td align="center"><?php echo $statut; ?> </td> <td align="center"><a href="?id=<?php echo $object->id; ?> &action=delete_related_link&id_link=<?php echo $Tids[0]; ?> "><?php print img_picto($langs->trans("Delete"), 'delete.png'); ?> </a></td> </tr> <?php } } ?> </table> </form> </div> <script type="text/javascript"> $(document).ready(function() { $('#add_related_object').autocomplete({ source: function( request, response ) { $.ajax({ url: "<?php echo dol_buildpath('/related/script/interface.php', 1); ?> ", dataType: "json", data: { key: request.term ,get:'search' } ,success: function( data ) { var c = []; $.each(data, function (i, cat) { var first = true; $.each(cat, function(j, label) { if(first) { c.push({value:i, label:i, object:'title'}); first = false; } c.push({ value: j, label:' '+label, object:i}); }); }); response(c); } }); }, minLength: 1, select: function( event, ui ) { if(ui.item.object == 'title') return false; else { $('#id_related_object').val(ui.item.value); $('#add_related_object').val(ui.item.label.trim()); $('#type_related_object').val(ui.item.object); $('#bt_add_related_object').css('display','inline'); return false; } }, open: function( event, ui ) { $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); }, close: function() { $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); } }); $( "#add_related_object" ).autocomplete( "instance" )._renderItem = function( ul, item ) { $li = $( "<li />" ) .attr( "data-value", item.value ) .append( item.label ) .appendTo( ul ); if(item.object=="title") $li.css("font-weight","bold"); return $li; }; var blockrelated = $('div.tabsAction .blockrelated_content'); if (blockrelated.length == 1) { if ($('.blockrelated_content').length > 1) { blockrelated.remove(); } else { $('div.tabsAction').after(blockrelated.clone()); blockrelated.remove(); } } }); </script> <?php if (!$error) { return 0; // or return 1 to replace standard code } else { $this->errors[] = 'Cant link related'; return -1; } }