/** * Show Dolibarr default login page. * Part of this code is also duplicated into main.inc.php::top_htmlhead * * @param Translate $langs Lang object (must be initialized by a new). * @param Conf $conf Conf object * @param Societe $mysoc Company object * @return void */ function dol_loginfunction($langs, $conf, $mysoc) { global $dolibarr_main_demo, $db; global $smartphone, $hookmanager; // Instantiate hooks of thirdparty module only if not already define $hookmanager->initHooks(array('mainloginpage')); $langs->load("main"); $langs->load("other"); $langs->load("help"); $langs->load("admin"); $main_authentication = $conf->file->main_authentication; $session_name = session_name(); $dol_url_root = DOL_URL_ROOT; $php_self = $_SERVER['PHP_SELF']; $php_self .= $_SERVER["QUERY_STRING"] ? '?' . $_SERVER["QUERY_STRING"] : ''; if (!preg_match('/mainmenu=/', $php_self)) { $php_self .= (preg_match('/\\?/', $php_self) ? '&' : '?') . 'mainmenu=home'; } // Title $title = 'Dolibarr ' . DOL_VERSION; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { $title = $conf->global->MAIN_APPLICATION_TITLE; } // Note: $conf->css looks like '/theme/eldy/style.css.php' $conf->css = "/theme/" . (GETPOST('theme') ? GETPOST('theme', 'alpha') : $conf->theme) . "/style.css.php"; //$themepath=dol_buildpath((empty($conf->global->MAIN_FORCETHEMEDIR)?'':$conf->global->MAIN_FORCETHEMEDIR).$conf->css,1); $themepath = dol_buildpath($conf->css, 1); if (!empty($conf->modules_parts['theme'])) { foreach ($conf->modules_parts['theme'] as $reldir) { if (file_exists(dol_buildpath($reldir . $conf->css, 0))) { $themepath = dol_buildpath($reldir . $conf->css, 1); break; } } } $conf_css = $themepath . "?lang=" . $langs->defaultlang; // Select templates if (!empty($conf->modules_parts['tpl'])) { $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl/')); foreach ($dirtpls as $reldir) { $tmp = dol_buildpath($reldir . 'login.tpl.php'); if (file_exists($tmp)) { $template_dir = preg_replace('/login\\.tpl\\.php$/', '', $tmp); break; } } } else { $template_dir = DOL_DOCUMENT_ROOT . "/core/tpl/"; } // Set cookie for timeout management $prefix = dol_getprefix(); $sessiontimeout = 'DOLSESSTIMEOUT_' . $prefix; if (!empty($conf->global->MAIN_SESSION_TIMEOUT)) { setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', 0); } if (GETPOST('urlfrom', 'alpha')) { $_SESSION["urlfrom"] = GETPOST('urlfrom', 'alpha'); } else { unset($_SESSION["urlfrom"]); } if (!GETPOST("username")) { $focus_element = 'username'; } else { $focus_element = 'password'; } $login_background = DOL_URL_ROOT . '/theme/login_background.png'; if (file_exists(DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/img/login_background.png')) { $login_background = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/login_background.png'; } $demologin = ''; $demopassword = ''; if (!empty($dolibarr_main_demo)) { $tab = explode(',', $dolibarr_main_demo); $demologin = $tab[0]; $demopassword = $tab[1]; } // Execute hook getLoginPageOptions // Should be an array with differents options in $hookmanager->resArray $parameters = array('entity' => GETPOST('entity', 'int')); $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks // Login $login = !empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username", "alpha") ? GETPOST("username", "alpha") : $demologin); $password = $demopassword; // Show logo (search in order: small company logo, large company logo, theme logo, common logo) $width = 0; $urllogo = DOL_URL_ROOT . '/theme/login_logo.png'; if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) { $urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=companylogo&file=' . urlencode('thumbs/' . $mysoc->logo_small); } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { $urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=companylogo&file=' . urlencode($mysoc->logo); $width = 128; } elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/img/dolibarr_logo.png')) { $urllogo = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/dolibarr_logo.png'; } elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.png')) { $urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png'; } // Security graphical code $captcha = 0; $captcha_refresh = ''; if (function_exists("imagecreatefrompng") && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) { $captcha = 1; $captcha_refresh = img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"'); } // Extra link $forgetpasslink = 0; $helpcenterlink = 0; if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) { $forgetpasslink = 1; } if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { $helpcenterlink = 1; } } // Home message $main_home = ''; if (!empty($conf->global->MAIN_HOME)) { $i = 0; while (preg_match('/__\\(([a-zA-Z|@]+)\\)__/i', $conf->global->MAIN_HOME, $reg) && $i < 100) { $tmp = explode('|', $reg[1]); if (!empty($tmp[1])) { $langs->load($tmp[1]); } $conf->global->MAIN_HOME = preg_replace('/__\\(' . preg_quote($reg[1]) . '\\)__/i', $langs->trans($tmp[0]), $conf->global->MAIN_HOME); $i++; } $main_home = dol_htmlcleanlastbr($conf->global->MAIN_HOME); } // Google AD $main_google_ad_client = !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT) ? 1 : 0; // Set jquery theme $dol_loginmesg = !empty($_SESSION["dol_loginmesg"]) ? $_SESSION["dol_loginmesg"] : ''; $favicon = dol_buildpath('/theme/' . $conf->theme . '/img/favicon.ico', 1); if (!empty($conf->global->MAIN_FAVICON_URL)) { $favicon = $conf->global->MAIN_FAVICON_URL; } $jquerytheme = 'smoothness'; if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) { $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; } // Set dol_hide_topmenu, dol_hide_leftmenu, dol_optimize_smallscreen, dol_nomousehover $dol_hide_topmenu = GETPOST('dol_hide_topmenu', 'int'); $dol_hide_leftmenu = GETPOST('dol_hide_leftmenu', 'int'); $dol_optimize_smallscreen = GETPOST('dol_optimize_smallscreen', 'int'); $dol_no_mouse_hover = GETPOST('dol_no_mouse_hover', 'int'); $dol_use_jmobile = GETPOST('dol_use_jmobile', 'int'); // Include login page template include $template_dir . 'login.tpl.php'; $_SESSION["dol_loginmesg"] = ''; }
/** * Get list of invoices for third party * * @param array $authentication Array of authentication information * @param int $idthirdparty Id thirdparty * @return array Array result * */ function getSupplierInvoicesForThirdParty($authentication,$idthirdparty) { global $db,$conf,$langs; dol_syslog("Function: getSupplierInvoicesForThirdParty login="******" idthirdparty=".$idthirdparty); if ($authentication['entity']) $conf->entity=$authentication['entity']; // Init and check authentication $objectresp=array(); $errorcode='';$errorlabel=''; $error=0; $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel); // Check parameters if (! $error && empty($idthirdparty)) { $error++; $errorcode='BAD_PARAMETERS'; $errorlabel='Parameter id is not provided'; } if (! $error) { $linesinvoice=array(); $sql.='SELECT f.rowid as facid'; $sql.=' FROM '.MAIN_DB_PREFIX.'facture_fourn as f'; //$sql.=', '.MAIN_DB_PREFIX.'societe as s'; //$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid'; //$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'"; //$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'"; $sql.=" WHERE f.entity = ".$conf->entity; if ($idthirdparty != 'all') $sql.=" AND f.fk_soc = ".$db->escape($idthirdparty); $resql=$db->query($sql); if ($resql) { $num=$db->num_rows($resql); $i=0; while ($i < $num) { // En attendant remplissage par boucle $obj=$db->fetch_object($resql); $invoice=new FactureFournisseur($db); $invoice->fetch($obj->facid); // Define lines of invoice $linesresp=array(); foreach($invoice->lines as $line) { $linesresp[]=array( 'id'=>$line->rowid, 'type'=>$line->product_type, 'desc'=>dol_htmlcleanlastbr($line->description), 'total_net'=>$line->total_ht, 'total_vat'=>$line->total_tva, 'total'=>$line->total_ttc, 'vat_rate'=>$line->tva_tx, 'qty'=>$line->qty, 'product_ref'=>$line->product_ref, 'product_label'=>$line->product_label, 'product_desc'=>$line->product_desc, ); } // Now define invoice $linesinvoice[]=array( 'id'=>$invoice->id, 'ref'=>$invoice->ref, 'ref_supplier'=>$invoice->ref_supplier, 'ref_ext'=>$invoice->ref_ext, 'fk_user_author' => $invoice->fk_user_author, 'fk_user_valid' => $invoice->fk_user_valid, 'fk_thirdparty' => $invoice->fk_soc, 'type'=>$invoice->type, 'status'=>$invoice->statut, 'total_net'=>$invoice->total_ht, 'total_vat'=>$invoice->total_tva, 'total'=>$invoice->total_ttc, 'date_creation'=>dol_print_date($invoice->datec,'dayhourrfc'), 'date_modification'=>dol_print_date($invoice->tms,'dayhourrfc'), 'date_invoice'=>dol_print_date($invoice->date,'dayhourrfc'), 'date_term'=>dol_print_date($invoice->date_echeance,'dayhourrfc'), 'label'=>$invoice->libelle, 'paid'=>$invoice->paye, 'note'=>$invoice->note, 'note_public'=>$invoice->note_public, 'close_code'=>$invoice->close_code, 'close_note'=>$invoice->close_note, 'lines' => $linesresp ); $i++; } $objectresp=array( 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'invoices'=>$linesinvoice ); } else { $error++; $errorcode=$db->lasterrno(); $errorlabel=$db->lasterror(); } } if ($error) { $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; }
$action = "create"; } } } // Update a product or service if ($action == 'update' && ($user->rights->produit->creer || $user->rights->service->creer)) { if (GETPOST('cancel')) { $action = ''; } else { if ($object->id > 0) { $object->oldcopy = clone $object; $object->ref = $ref; $object->label = GETPOST('label'); $object->description = dol_htmlcleanlastbr(GETPOST('desc')); $object->url = GETPOST('url'); $object->note = dol_htmlcleanlastbr(GETPOST('note')); $object->customcode = GETPOST('customcode'); $object->country_id = GETPOST('country_id'); $object->status = GETPOST('statut'); $object->status_buy = GETPOST('statut_buy'); $object->status_batch = GETPOST('status_batch'); // removed from update view so GETPOST always empty /* $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $object->desiredstock = GETPOST('desiredstock'); */ $object->duration_value = GETPOST('duration_value'); $object->duration_unit = GETPOST('duration_unit'); $object->canvas = GETPOST('canvas'); $object->weight = GETPOST('weight'); $object->weight_units = GETPOST('weight_units');
setEventMessages($object->error, $object->errors, 'errors'); } $action = ''; } } } elseif ($action == 'updateligne' && $user->rights->facture->creer && !GETPOST('cancel')) { if (!$object->fetch($id) > 0) { dol_print_error($db); } $object->fetch_thirdparty(); // Clean parameters $date_start = ''; $date_end = ''; $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); $description = dol_htmlcleanlastbr(GETPOST('product_desc')); $pu_ht = GETPOST('price_ht'); $vat_rate = GETPOST('tva_tx') ? GETPOST('tva_tx') : 0; $qty = GETPOST('qty'); // Define info_bits $info_bits = 0; if (preg_match('/\\*/', $vat_rate)) { $info_bits |= 0x1; } // Define vat_rate $vat_rate = str_replace('*', '', $vat_rate); $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty); $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty); // Add buying price $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : '');
unset($_POST['np_tva_tx']); unset($_POST['np_buying_price']); } else { $mesg = '<div class="error">' . $object->error . '</div>'; } } } } } else { if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('save') == $langs->trans('Save')) { // Clean parameters $date_start = ''; $date_end = ''; $date_start = dol_mktime(0, 0, 0, GETPOST('date_start' . $suffixe . 'month'), GETPOST('date_start' . $suffixe . 'day'), GETPOST('date_start' . $suffixe . 'year')); $date_end = dol_mktime(0, 0, 0, GETPOST('date_end' . $suffixe . 'month'), GETPOST('date_end' . $suffixe . 'day'), GETPOST('date_end' . $suffixe . 'year')); $description = dol_htmlcleanlastbr(GETPOST('desc')); $up_ht = GETPOST('pu') ? GETPOST('pu') : GETPOST('subprice'); // Define info_bits $info_bits = 0; if (preg_match('/\\*/', GETPOST('tva_tx'))) { $info_bits |= 0x1; } // Define vat_rate $vat_rate = GETPOST('tva_tx'); $vat_rate = str_replace('*', '', $vat_rate); $localtax1_rate = get_localtax($vat_rate, 1, $object->client); $localtax2_rate = get_localtax($vat_rate, 2, $object->client); // ajout prix d'achat $fk_fournprice = GETPOST('fournprice'); if (GETPOST('buying_price')) { $pa_ht = GETPOST('buying_price');
} else { $action = 'add'; setEventMessage($object->error, 'errors'); } } // Validation de l'edition if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->categorie->creer) { $object->fetch($id); $current_lang = $langs->getDefaultLang(); foreach ($object->multilangs as $key => $value) { if ($key == $current_lang) { $object->label = $_POST["libelle-" . $key]; $object->description = dol_htmlcleanlastbr($_POST["desc-" . $key]); } else { $object->multilangs[$key]["label"] = $_POST["libelle-" . $key]; $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-" . $key]); } } if ($object->setMultiLangs() > 0) { $action = ''; } else { $action = 'edit'; setEventMessage($object->error, 'errors'); } } $result = $object->fetch($id, $ref); /* * View */ llxHeader("", "", $langs->trans("Translation")); $form = new Form($db);
if ($idContactOrigin) { header("Location: " . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $idContactOrigin . '&type=' . $type); exit; } else { header("Location: " . DOL_URL_ROOT . '/categories/index.php?leftmenu=cat&type=' . $type); exit; } } } } } } } } $object->label = $label; $object->description = dol_htmlcleanlastbr($description); $object->socid = $socid ? $socid : 'null'; $object->visible = $visible; $object->type = $type; if ($parent != "-1") { $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);
/** * Add an action/event into database * @param user Object user making action * @param notrigger 1 = disable triggers, 0 = enable triggers * @return int Id of created event, < 0 if KO */ function add($user, $notrigger = 0) { global $langs, $conf; $now = dol_now(); // Clean parameters $this->label = dol_trunc(trim($this->label), 128); $this->location = dol_trunc(trim($this->location), 128); $this->note = dol_htmlcleanlastbr(trim($this->note)); if (empty($this->percentage)) { $this->percentage = 0; } if (empty($this->priority)) { $this->priority = 0; } if (empty($this->fulldayevent)) { $this->fuldayevent = 0; } if (empty($this->punctual)) { $this->punctual = 0; } if ($this->percentage > 100) { $this->percentage = 100; } if ($this->percentage == 100 && !$this->dateend) { $this->dateend = $this->date; } if ($this->datep && $this->datef) { $this->durationp = $this->datef - $this->datep; } if ($this->date && $this->dateend) { $this->durationa = $this->dateend - $this->date; } if ($this->datep && $this->datef && $this->datep > $this->datef) { $this->datef = $this->datep; } if ($this->date && $this->dateend && $this->date > $this->dateend) { $this->dateend = $this->date; } if ($this->fk_project < 0) { $this->fk_project = 0; } if ($this->elementtype == 'facture') { $this->elementtype = 'invoice'; } if ($this->elementtype == 'commande') { $this->elementtype = 'order'; } if ($this->elementtype == 'contrat') { $this->elementtype = 'contract'; } if (!$this->type_id && $this->type_code) { # Get id from code $cactioncomm = new CActionComm($this->db); $result = $cactioncomm->fetch($this->type_code); if ($result > 0) { $this->type_id = $cactioncomm->id; } else { if ($result == 0) { $this->error = 'Failed to get record with code AC_OTH from dictionnary "type of events"'; return -1; } else { $this->error = $cactioncomm->error; return -1; } } } // Check parameters if (!$this->type_id) { $this->error = "ErrorWrongParameters"; return -1; } $this->db->begin(); $sql = "INSERT INTO " . MAIN_DB_PREFIX . "actioncomm"; $sql .= "(datec,"; $sql .= "datep,"; $sql .= "datep2,"; $sql .= "datea,"; $sql .= "datea2,"; $sql .= "durationp,"; $sql .= "durationa,"; $sql .= "fk_action,"; $sql .= "fk_soc,"; $sql .= "fk_project,"; $sql .= "note,"; $sql .= "fk_contact,"; $sql .= "fk_user_author,"; $sql .= "fk_user_action,"; $sql .= "fk_user_done,"; $sql .= "label,percent,priority,fulldayevent,location,punctual,"; $sql .= "fk_element,"; $sql .= "elementtype,"; $sql .= "entity"; $sql .= ") VALUES ("; $sql .= "'" . $this->db->idate($now) . "',"; $sql .= (strval($this->datep) != '' ? "'" . $this->db->idate($this->datep) . "'" : "null") . ","; $sql .= (strval($this->datef) != '' ? "'" . $this->db->idate($this->datef) . "'" : "null") . ","; $sql .= (strval($this->date) != '' ? "'" . $this->db->idate($this->date) . "'" : "null") . ","; $sql .= (strval($this->dateend) != '' ? "'" . $this->db->idate($this->dateend) . "'" : "null") . ","; $sql .= ($this->durationp >= 0 && $this->durationp != '' ? "'" . $this->durationp . "'" : "null") . ","; $sql .= ($this->durationa >= 0 && $this->durationa != '' ? "'" . $this->durationa . "'" : "null") . ","; $sql .= " '" . $this->type_id . "',"; $sql .= ($this->societe->id > 0 ? " '" . $this->societe->id . "'" : "null") . ","; $sql .= ($this->fk_project > 0 ? " '" . $this->fk_project . "'" : "null") . ","; $sql .= " '" . $this->db->escape($this->note) . "',"; $sql .= ($this->contact->id > 0 ? "'" . $this->contact->id . "'" : "null") . ","; $sql .= ($user->id > 0 ? "'" . $user->id . "'" : "null") . ","; $sql .= ($this->usertodo->id > 0 ? "'" . $this->usertodo->id . "'" : "null") . ","; $sql .= ($this->userdone->id > 0 ? "'" . $this->userdone->id . "'" : "null") . ","; $sql .= "'" . $this->db->escape($this->label) . "','" . $this->percentage . "','" . $this->priority . "','" . $this->fulldayevent . "','" . $this->db->escape($this->location) . "','" . $this->punctual . "',"; $sql .= ($this->fk_element ? $this->fk_element : "null") . ","; $sql .= ($this->elementtype ? "'" . $this->elementtype . "'" : "null") . ","; $sql .= $conf->entity; $sql .= ")"; dol_syslog("ActionComm::add sql=" . $sql); $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "actioncomm", "id"); if (!$notrigger) { // Appel des triggers include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"; $interface = new Interfaces($this->db); $result = $interface->run_triggers('ACTION_CREATE', $this, $user, $langs, $conf); if ($result < 0) { $error++; $this->errors = $interface->errors; } // Fin appel triggers } $this->db->commit(); return $this->id; } else { $this->error = $this->db->lasterror() . ' sql=' . $sql; $this->db->rollback(); return -1; } }
$usecanvas=$_POST["canvas"]; if (empty($conf->global->MAIN_USE_CANVAS)) $usecanvas=0; if (! empty($usecanvas)) // Overwrite product here { $canvas = new Canvas($db,$user); $product = $canvas->load_canvas('product',$_POST["canvas"]); } if ($product->fetch($id)) { $product->ref = $ref; $product->libelle = $_POST["libelle"]; $product->description = dol_htmlcleanlastbr($_POST["desc"]); $product->note = dol_htmlcleanlastbr($_POST["note"]); $product->customcode = $_POST["customcode"]; $product->country_id = $_POST["country_id"]; $product->status = $_POST["statut"]; $product->status_buy = $_POST["statut_buy"]; $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; $product->duration_value = $_POST["duration_value"]; $product->duration_unit = $_POST["duration_unit"]; $product->canvas = $_POST["canvas"]; $product->weight = $_POST["weight"]; $product->weight_units = $_POST["weight_units"]; $product->length = $_POST["size"]; $product->length_units = $_POST["size_units"]; $product->surface = $_POST["surface"]; $product->surface_units = $_POST["surface_units"]; $product->volume = $_POST["volume"];
if ($type == 'select' || $type == 'sellist' || $type == 'checkbox' || $type == 'radio') { ?> <tr id="value_choice"> <td> <?php echo $langs->trans("Value"); ?> </td> <td> <table class="nobordernopadding"> <tr><td> <textarea name="param" id="param" cols="80" rows="<?php echo ROWS_4; ?> "><?php echo dol_htmlcleanlastbr($param_chain); ?> </textarea> </td><td><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelp" . $type), 1, 0); ?> </td></tr> </table> </td> </tr> <?php } ?> <!-- Unique --> <tr><td><?php echo $langs->trans("Unique");
/** * Get invoice from id, ref or ref_ext. * * @param array $authentication Array of authentication information * @param int $id Id * @param string $ref Ref * @param string $ref_ext Ref_ext * @return array Array result */ function getInvoice($authentication, $id = '', $ref = '', $ref_ext = '') { global $db, $conf, $langs; dol_syslog("Function: getInvoice login="******" id=" . $id . " ref=" . $ref . " ref_ext=" . $ref_ext); if ($authentication['entity']) { $conf->entity = $authentication['entity']; } // Init and check authentication $objectresp = array(); $errorcode = ''; $errorlabel = ''; $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters if (!$error && ($id && $ref || $id && $ref_ext || $ref && $ref_ext)) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; } if (!$error) { $fuser->getrights(); if ($fuser->rights->facture->lire) { $invoice = new Facture($db); $result = $invoice->fetch($id, $ref, $ref_ext); if ($result > 0) { $linesresp = array(); $i = 0; foreach ($invoice->lines as $line) { //var_dump($line); exit; $linesresp[] = array('id' => $line->rowid, 'type' => $line->product_type, 'desc' => dol_htmlcleanlastbr($line->desc), 'total_net' => $line->total_ht, 'total_vat' => $line->total_tva, 'total' => $line->total_ttc, 'vat_rate' => $line->tva_tx, 'qty' => $line->qty, 'product_ref' => $line->product_ref, 'product_label' => $line->product_label, 'product_desc' => $line->product_desc); $i++; } // Create invoice $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'invoice' => array('id' => $invoice->id, 'ref' => $invoice->ref, 'ref_ext' => $invoice->ref_ext ? $invoice->ref_ext : '', 'fk_user_author' => $invoice->user_author ? $invoice->user_author : '', 'fk_user_valid' => $invoice->user_valid ? $invoice->user_valid : '', 'date' => $invoice->date ? dol_print_date($invoice->date, 'dayrfc') : '', 'date_creation' => $invoice->date_creation ? dol_print_date($invoice->date_creation, 'dayhourrfc') : '', 'date_validation' => $invoice->date_validation ? dol_print_date($invoice->date_creation, 'dayhourrfc') : '', 'date_modification' => $invoice->datem ? dol_print_date($invoice->datem, 'dayhourrfc') : '', 'type' => $invoice->type, 'total_net' => $invoice->total_ht, 'total_vat' => $invoice->total_tva, 'total' => $invoice->total_ttc, 'note_private' => $invoice->note_private ? $invoice->note_private : '', 'note_public' => $invoice->note_public ? $invoice->note_public : '', 'status' => $invoice->statut, 'close_code' => $invoice->close_code ? $invoice->close_code : '', 'close_note' => $invoice->close_note ? $invoice->close_note : '', 'lines' => $linesresp)); } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id=' . $id . ' nor ref=' . $ref . ' nor ref_ext=' . $ref_ext; } } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } if ($error) { $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; }
/** * Add an action/event into database. * $this->type_id OR $this->type_code must be set. * * @param User $user Object user making action * @param int $notrigger 1 = disable triggers, 0 = enable triggers * @return int Id of created event, < 0 if KO */ function add($user, $notrigger = 0) { global $langs, $conf, $hookmanager; $error = 0; $now = dol_now(); // Check parameters if (empty($this->userownerid)) { $this->errors[] = 'ErrorPropertyUserowneridNotDefined'; return -1; } // Clean parameters $this->label = dol_trunc(trim($this->label), 128); $this->location = dol_trunc(trim($this->location), 128); $this->note = dol_htmlcleanlastbr(trim($this->note)); if (empty($this->percentage)) { $this->percentage = 0; } if (empty($this->priority) || !is_numeric($this->priority)) { $this->priority = 0; } if (empty($this->fulldayevent)) { $this->fulldayevent = 0; } if (empty($this->punctual)) { $this->punctual = 0; } if (empty($this->transparency)) { $this->transparency = 0; } if ($this->percentage > 100) { $this->percentage = 100; } //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; if (!empty($this->datep) && !empty($this->datef)) { $this->durationp = $this->datef - $this->datep; } // deprecated //if (! empty($this->date) && ! empty($this->dateend)) $this->durationa=($this->dateend - $this->date); if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) { $this->datef = $this->datep; } //if (! empty($this->date) && ! empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date; if (!isset($this->fk_project) || $this->fk_project < 0) { $this->fk_project = 0; } if ($this->elementtype == 'facture') { $this->elementtype = 'invoice'; } if ($this->elementtype == 'commande') { $this->elementtype = 'order'; } if ($this->elementtype == 'contrat') { $this->elementtype = 'contract'; } if (!is_array($this->userassigned) && !empty($this->userassigned)) { $tmpid = $this->userassigned; $this->userassigned = array(); $this->userassigned[$tmpid] = array('id' => $tmpid); } if (is_object($this->contact) && $this->contact->id > 0 && !($this->contactid > 0)) { $this->contactid = $this->contact->id; } // For backward compatibility. Using this->contact->xx is deprecated $userownerid = $this->userownerid; $userdoneid = $this->userdoneid; // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) { $this->userassigned = array($userownerid => array('id' => $userownerid)); } if (!$this->type_id || !$this->type_code) { $key = empty($this->type_id) ? $this->type_code : $this->type_id; // Get id from code $cactioncomm = new CActionComm($this->db); $result = $cactioncomm->fetch($key); if ($result > 0) { $this->type_id = $cactioncomm->id; $this->type_code = $cactioncomm->code; } else { if ($result == 0) { $this->error = 'Failed to get record with id ' . $this->type_id . ' code ' . $this->type_code . ' from dictionary "type of events"'; return -1; } else { $this->error = $cactioncomm->error; return -1; } } } // Check parameters if (!$this->type_id) { $this->error = "ErrorWrongParameters"; return -1; } $this->db->begin(); $sql = "INSERT INTO " . MAIN_DB_PREFIX . "actioncomm"; $sql .= "(datec,"; $sql .= "datep,"; $sql .= "datep2,"; $sql .= "durationp,"; // deprecated $sql .= "fk_action,"; $sql .= "code,"; $sql .= "fk_soc,"; $sql .= "fk_project,"; $sql .= "note,"; $sql .= "fk_contact,"; $sql .= "fk_user_author,"; $sql .= "fk_user_action,"; $sql .= "fk_user_done,"; $sql .= "label,percent,priority,fulldayevent,location,punctual,"; $sql .= "transparency,"; $sql .= "fk_element,"; $sql .= "elementtype,"; $sql .= "entity"; $sql .= ") VALUES ("; $sql .= "'" . $this->db->idate($now) . "',"; $sql .= (strval($this->datep) != '' ? "'" . $this->db->idate($this->datep) . "'" : "null") . ","; $sql .= (strval($this->datef) != '' ? "'" . $this->db->idate($this->datef) . "'" : "null") . ","; $sql .= (isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '' ? "'" . $this->durationp . "'" : "null") . ","; // deprecated $sql .= (isset($this->type_id) ? $this->type_id : "null") . ","; $sql .= (isset($this->type_code) ? " '" . $this->type_code . "'" : "null") . ","; $sql .= (isset($this->socid) && $this->socid > 0 ? " '" . $this->socid . "'" : "null") . ","; $sql .= (isset($this->fk_project) && $this->fk_project > 0 ? " '" . $this->fk_project . "'" : "null") . ","; $sql .= " '" . $this->db->escape($this->note) . "',"; $sql .= (isset($this->contactid) && $this->contactid > 0 ? "'" . $this->contactid . "'" : "null") . ","; $sql .= (isset($user->id) && $user->id > 0 ? "'" . $user->id . "'" : "null") . ","; $sql .= ($userownerid > 0 ? "'" . $userownerid . "'" : "null") . ","; $sql .= ($userdoneid > 0 ? "'" . $userdoneid . "'" : "null") . ","; $sql .= "'" . $this->db->escape($this->label) . "','" . $this->percentage . "','" . $this->priority . "','" . $this->fulldayevent . "','" . $this->db->escape($this->location) . "','" . $this->punctual . "',"; $sql .= "'" . $this->transparency . "',"; $sql .= (!empty($this->fk_element) ? $this->fk_element : "null") . ","; $sql .= (!empty($this->elementtype) ? "'" . $this->elementtype . "'" : "null") . ","; $sql .= $conf->entity; $sql .= ")"; dol_syslog(get_class($this) . "::add", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "actioncomm", "id"); // Now insert assignedusers if (!$error) { foreach ($this->userassigned as $key => $val) { if (!is_array($val)) { $val = array('id' => $val); } $sql = "INSERT INTO " . MAIN_DB_PREFIX . "actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; $sql .= " VALUES(" . $this->id . ", 'user', " . $val['id'] . ", " . (empty($val['mandatory']) ? '0' : $val['mandatory']) . ", " . (empty($val['transparency']) ? '0' : $val['transparency']) . ", " . (empty($val['answer_status']) ? '0' : $val['answer_status']) . ")"; $resql = $this->db->query($sql); if (!$resql) { $error++; $this->errors[] = $this->db->lasterror(); } //var_dump($sql);exit; } } if (!$error) { $action = 'create'; // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('actioncommdao')); $parameters = array('actcomm' => $this->id); $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } } else { if ($reshook < 0) { $error++; } } } if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('ACTION_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } if (!$error) { $this->db->commit(); return $this->id; } else { $this->db->rollback(); return -1; } } else { $this->db->rollback(); $this->error = $this->db->lasterror(); return -1; } }
/** * testDolHtmlCleanLastBr * * @return boolean */ public function testDolHtmlCleanLastBr() { $input="A string<br>"; $after=dol_htmlcleanlastbr($input); $this->assertEquals("A string",$after); $input="A string first<br>\nA string second<br>"; $after=dol_htmlcleanlastbr($input); $this->assertEquals("A string first<br>\nA string second",$after); $input="A string\n<br type=\"_moz\" />\n"; $after=dol_htmlcleanlastbr($input); $this->assertEquals("A string",$after); $input="A string\n<br><br />\n\n"; $after=dol_htmlcleanlastbr($input); $this->assertEquals("A string",$after); return true; }
/** * Show Dolibarr default login page. * Part of this code is also duplicated into main.inc.php::top_htmlhead * * @param Translate $langs Lang object (must be initialized by a new). * @param Conf $conf Conf object * @param Societe $mysoc Company object * @return void */ function dol_loginfunction($langs, $conf, $mysoc) { global $dolibarr_main_demo, $db; global $smartphone, $hookmanager; // Instantiate hooks of thirdparty module only if not already define if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); } $hookmanager->initHooks(array('mainloginpage')); $langcode = GETPOST('lang') ? is_object($langs) && $langs->defaultlang ? $langs->defaultlang : 'auto' : GETPOST('lang'); $langs->setDefaultLang($langcode); $langs->load("main"); $langs->load("other"); $langs->load("help"); $langs->load("admin"); $main_authentication = $conf->file->main_authentication; $session_name = session_name(); $dol_url_root = DOL_URL_ROOT; $php_self = $_SERVER['PHP_SELF']; $php_self .= $_SERVER["QUERY_STRING"] ? '?' . $_SERVER["QUERY_STRING"] : ''; // Title $title = 'Speedealing ' . DOL_VERSION; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { $title = $conf->global->MAIN_APPLICATION_TITLE; } // Select templates if (file_exists(DOL_DOCUMENT_ROOT . "/theme/" . $conf->theme . "/tpl/login.tpl.php")) { $template_dir = DOL_DOCUMENT_ROOT . "/theme/" . $conf->theme . "/tpl/"; } else { $template_dir = DOL_DOCUMENT_ROOT . "/core/tpl/"; } $conf->css = "/theme/" . (GETPOST('theme') ? GETPOST('theme', 'alpha') : $conf->theme) . "/style.css.php?lang=" . $langs->defaultlang; $conf_css = DOL_URL_ROOT . $conf->css; // Set cookie for timeout management $prefix = dol_getprefix(); $sessiontimeout = 'DOLSESSTIMEOUT_' . $prefix; if (!empty($conf->global->MAIN_SESSION_TIMEOUT)) { setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', 0); } if (GETPOST('urlfrom', 'alpha')) { $_SESSION["urlfrom"] = GETPOST('urlfrom', 'alpha'); } else { unset($_SESSION["urlfrom"]); } if (!GETPOST("username")) { $focus_element = 'username'; } else { $focus_element = 'password'; } $login_background = DOL_URL_ROOT . '/theme/login_background.png'; if (file_exists(DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/img/login_background.png')) { $login_background = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/login_background.png'; } $demologin = ''; $demopassword = ''; if (!empty($dolibarr_main_demo)) { $tab = explode(',', $dolibarr_main_demo); $demologin = $tab[0]; $demopassword = $tab[1]; } // Execute hook getLoginPageOptions // Should be an array with differents options in $hookmanager->resArray $parameters = array('entity' => $_POST['entity']); $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks // Login $login = !empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username", "alpha", 2) ? GETPOST("username", "alpha", 2) : $demologin); $password = $demopassword; // Show logo (search in order: small company logo, large company logo, theme logo, common logo) $width = 0; $urllogo = DOL_URL_ROOT . '/theme/login_logo.png'; if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) { $urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=companylogo&file=' . urlencode('thumbs/' . $mysoc->logo_small); } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { $urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=companylogo&file=' . urlencode($mysoc->logo); $width = 128; } elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/img/dolibarr_logo.png')) { $urllogo = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/dolibarr_logo.png'; } elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.png')) { $urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png'; } // Security graphical code $captcha = 0; $captcha_refresh = ''; if (function_exists("imagecreatefrompng") && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) { $captcha = 1; $captcha_refresh = img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"'); } // Extra link $forgetpasslink = 0; $helpcenterlink = 0; if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) { $forgetpasslink = 1; } if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { $helpcenterlink = 1; } } // Home message if (!empty($conf->global->MAIN_HOME)) { $i = 0; while (preg_match('/__\\(([a-zA-Z]+)\\)__/i', $conf->global->MAIN_HOME, $reg) && $i < 100) { $conf->global->MAIN_HOME = preg_replace('/__\\(' . $reg[1] . '\\)__/i', $langs->trans($reg[1]), $conf->global->MAIN_HOME); $i++; } } $main_home = dol_htmlcleanlastbr($conf->global->MAIN_HOME); // Google AD $main_google_ad_client = !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT) ? 1 : 0; $dol_loginmesg = $_SESSION["dol_loginmesg"]; $favicon = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/favicon.ico'; $jquerytheme = 'smoothness'; if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) { $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; } include $template_dir . 'login.tpl.php'; // To use native PHP $_SESSION["dol_loginmesg"] = ''; }
} print '</tr></table>'; print '</td><td colspan="2">'; if ($action == 'editdate_livraison') { print '<form name="setdate_livraison" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="post">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="action" value="setdate_livraison">'; $html->select_date($object->date_livraison ? $object->date_livraison : -1, 'liv_', '', '', '', "setdate_livraison"); print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">'; print '</form>'; } else { print $object->date_livraison ? dol_print_date($object->date_livraison, 'daytext') : ' '; } print '</td>'; print '<td rowspan="' . $nbrow . '" valign="top">' . $langs->trans('NotePublic') . ' :<br>'; print dol_htmlcleanlastbr($object->note_public); print '</td>'; print '</tr>'; // Delivery address if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS) { print '<tr><td height="10">'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans('DeliveryAddress'); print '</td>'; if ($action != 'editdelivery_adress' && $object->brouillon) { print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editdelivery_adress&socid=' . $object->socid . '&id=' . $object->id . '">' . img_edit($langs->trans('SetDeliveryAddress'), 1) . '</a></td>'; } print '</tr></table>'; print '</td><td colspan="2">'; if ($action == 'editdelivery_adress') { $html->form_address($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_delivery_address, $socid, 'fk_address', 'commande', $object->id);
/** * Show Dolibarr default login page * @param langs Lang object (must be initialized by a new). * @param conf Conf object * @param mysoc Company object */ function dol_loginfunction($langs,$conf,$mysoc) { global $dolibarr_main_demo,$db; global $smartphone; $langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang')); $langs->setDefaultLang($langcode); $langs->load("main"); $langs->load("other"); $langs->load("help"); $langs->load("admin"); $main_authentication=$conf->file->main_authentication; $session_name=session_name(); $dol_url_root = DOL_URL_ROOT; $php_self = $_SERVER['PHP_SELF']; $php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:''; // Title $title='Dolibarr '.DOL_VERSION; if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE; // Select templates if (preg_match('/^smartphone/',$conf->smart_menu) && isset($conf->browser->phone)) { $template_dir = DOL_DOCUMENT_ROOT.'/theme/phones/smartphone/tpl/'; } else { if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/login.tpl.php")) { $template_dir = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/"; } else { $template_dir = DOL_DOCUMENT_ROOT."/core/tpl/"; } } $conf->css = "/theme/".$conf->theme."/style.css.php?lang=".$langs->defaultlang; $conf_css = DOL_URL_ROOT.$conf->css; // Set cookie for timeout management $prefix=dol_getprefix(); $sessiontimeout='DOLSESSTIMEOUT_'.$prefix; if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', 0); if (GETPOST("urlfrom")) $_SESSION["urlfrom"]=GETPOST("urlfrom"); else unset($_SESSION["urlfrom"]); if (! GETPOST("username")) $focus_element='username'; else $focus_element='password'; $login_background=DOL_URL_ROOT.'/theme/login_background.png'; if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/login_background.png')) { $login_background=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_background.png'; } $demologin=''; $demopassword=''; if (! empty($dolibarr_main_demo)) { $tab=explode(',',$dolibarr_main_demo); $demologin=$tab[0]; $demopassword=$tab[1]; } // Entity cookie if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) { $lastuser = ''; $lastentity = $_POST['entity']; if (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE)) { $prefix=dol_getprefix(); $entityCookieName = 'DOLENTITYID_'.$prefix; if (isset($_COOKIE[$entityCookieName])) { include_once(DOL_DOCUMENT_ROOT . "/core/class/cookie.class.php"); $cryptkey = (! empty($conf->file->cookie_cryptkey) ? $conf->file->cookie_cryptkey : '' ); $entityCookie = new DolCookie($cryptkey); $cookieValue = $entityCookie->_getCookie($entityCookieName); list($lastuser, $lastentity) = explode('|', $cookieValue); } } } // Login $login = (!empty($lastuser)?$lastuser:(GETPOST("username")?GETPOST("username"):$demologin)); $password = $demopassword; // Show logo (search in order: small company logo, large company logo, theme logo, common logo) $width=0; $rowspan=2; $urllogo=DOL_URL_ROOT.'/theme/login_logo.png'; if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=companylogo&file='.urlencode('thumbs/'.$mysoc->logo_small); } elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=companylogo&file='.urlencode($mysoc->logo); $width=128; } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.png')) { $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; } // Entity field $select_entity=''; if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY) && empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX)) { $rowspan++; $res=dol_include_once('/multicompany/class/actions_multicompany.class.php'); if ($res) { $mc = new ActionsMulticompany($db); $select_entity=$mc->select_entities($lastentity, 'tabindex="3"'); } } // Security graphical code $captcha=0; $captcha_refresh=''; if (function_exists("imagecreatefrompng") && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) { $captcha=1; $captcha_refresh=img_refresh(); } // Extra link $forgetpasslink=0; $helpcenterlink=0; if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) { $forgetpasslink=1; } if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { $helpcenterlink=1; } } // Home message if (! empty($conf->global->MAIN_HOME)) { $i=0; while (preg_match('/__\(([a-zA-Z]+)\)__/i',$conf->global->MAIN_HOME,$reg) && $i < 100) { $conf->global->MAIN_HOME=preg_replace('/__\('.$reg[1].'\)__/i',$langs->trans($reg[1]),$conf->global->MAIN_HOME); $i++; } } $main_home=dol_htmlcleanlastbr($conf->global->MAIN_HOME); // Google AD $main_google_ad_client = ((! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))?1:0); $dol_loginmesg = $_SESSION["dol_loginmesg"]; include($template_dir.'login.tpl.php'); // To use native PHP $_SESSION["dol_loginmesg"] = ''; }
$socid = $user->societe_id; } $result = restrictedArea($user, 'contrat', $id); $object = new Contrat($db); $object->fetch($id, $ref); /******************************************************************************/ /* Actions */ /******************************************************************************/ if ($action == 'setnote_public' && $user->rights->contrat->creer) { $result = $object->update_note(dol_html_entity_decode(dol_htmlcleanlastbr(GETPOST('note_public')), ENT_QUOTES), '_public'); if ($result < 0) { dol_print_error($db, $object->error); } } else { if ($action == 'setnote_private' && $user->rights->contrat->creer) { $result = $object->update_note(dol_html_entity_decode(dol_htmlcleanlastbr(GETPOST('note_private')), ENT_QUOTES), '_private'); if ($result < 0) { dol_print_error($db, $object->error); } } } /******************************************************************************/ /* Affichage fiche */ /******************************************************************************/ llxHeader(); $form = new Form($db); if ($id > 0 || !empty($ref)) { dol_htmloutput_mesg($mesg); $object->fetch_thirdparty(); $head = contract_prepare_head($object); $hselected = 2;
} } } else { $langs->load("errors"); setEventMessages($langs->trans('ErrorForbidden'), null, 'errors'); } } if ($action == 'update') { if ($caneditperms) { $db->begin(); $object->fetch($id); $object->oldcopy = clone $object; $object->name = trim($_POST["group"]); $object->nom = $object->name; // For backward compatibility $object->note = dol_htmlcleanlastbr($_POST["note"]); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if ($ret < 0) { $error++; } if (!empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode)) { $object->entity = 0; } else { $object->entity = $_POST["entity"]; } $ret = $object->update(); if ($ret >= 0 && !count($object->errors)) { setEventMessages($langs->trans("GroupModified"), null, 'mesgs'); $db->commit(); } else {
} } // Edit translation if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { $object = new Product($db); $object->fetch($id); $current_lang = $langs->getDefaultLang(); foreach ($object->multilangs as $key => $value) { if ($key == $current_lang) { $object->label = $_POST["libelle-" . $key]; $object->description = dol_htmlcleanlastbr($_POST["desc-" . $key]); $object->note = dol_htmlcleanlastbr($_POST["note-" . $key]); } else { $object->multilangs[$key]["label"] = $_POST["libelle-" . $key]; $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-" . $key]); $object->multilangs[$key]["note"] = dol_htmlcleanlastbr($_POST["note-" . $key]); } } if ($object->setMultiLangs($user) > 0) { $action = ''; } else { $action = 'edit'; setEventMessages($object->error, $object->errors, 'errors'); } } // Delete translation if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { $object = new Product($db); $object->fetch($id); $langtodelete = GETPOST('langdel', 'alpha'); if ($object->delMultiLangs($langtodelete, $user) > 0) {
exit; } // Security check $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); /* * Actions */ // Action mise a jour d'une categorie if ($action == 'update' && $user->rights->categorie->creer) { $categorie = new Categorie($db); $result = $categorie->fetch($id); $categorie->label = $nom; $categorie->description = dol_htmlcleanlastbr($description); $categorie->socid = $socid ? $socid : 'null'; $categorie->visible = $visible; if ($parent != "-1") { $categorie->fk_parent = $parent; } else { $categorie->fk_parent = ""; } if (empty($categorie->label)) { $action = 'create'; setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), 'errors'); } if (empty($categorie->description)) { $action = 'create'; setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("Description")), 'errors'); }
// Show bugtrack link $var = !$var; print '<tr ' . $bc[$var] . '"><td width="35%">' . $langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")) . '</td><td>'; print yn($conf->global->MAIN_BUGTRACK_ENABLELINK) . "</td>"; print '<td width="20"> </td>'; print "</tr>"; // Message login $var = !$var; print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("MessageLogin") . '</td><td colspan="2">'; if (isset($conf->global->MAIN_HOME)) { print dol_htmlcleanlastbr($conf->global->MAIN_HOME); } else { print ' '; } print '</td></tr>' . "\n"; // Message of the day $var = !$var; print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("MessageOfDay") . '</td><td colspan="2">'; if (isset($conf->global->MAIN_MOTD)) { print dol_htmlcleanlastbr($conf->global->MAIN_MOTD); } else { print ' '; } print '</td></tr>' . "\n"; print '</table>' . "\n"; print '<div class="tabsAction">'; print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit">' . $langs->trans("Modify") . '</a>'; print '</div>'; } llxFooter(); $db->close();
} $action=''; } if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save'] == $langs->trans('Save')) { if (! $object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); // Clean parameters $date_start=''; $date_end=''; $date_start=dol_mktime($_POST['date_start'.$suffixe.'hour'],$_POST['date_start'.$suffixe.'min'],$_POST['date_start'.$suffixe.'sec'],$_POST['date_start'.$suffixe.'month'],$_POST['date_start'.$suffixe.'day'],$_POST['date_start'.$suffixe.'year']); $date_end=dol_mktime($_POST['date_end'.$suffixe.'hour'],$_POST['date_end'.$suffixe.'min'],$_POST['date_end'.$suffixe.'sec'],$_POST['date_end'.$suffixe.'month'],$_POST['date_end'.$suffixe.'day'],$_POST['date_end'.$suffixe.'year']); $description=dol_htmlcleanlastbr($_POST['desc']); $up_ht=GETPOST('pu')?GETPOST('pu'):GETPOST('subprice'); // Define info_bits $info_bits=0; if (preg_match('/\*/',$_POST['tva_tx'])) $info_bits |= 0x01; // Define vat_rate $vat_rate=$_POST['tva_tx']; $vat_rate=str_replace('*','',$vat_rate); $localtax1_rate=get_localtax($vat_rate,1,$object->client); $localtax2_rate=get_localtax($vat_rate,2,$object->client); // Check parameters if (! GETPOST('productid') && GETPOST("type") < 0) {
//print '</td></tr></table>'; print '</div></div></div>'; print '<div class="fichecenter"><br>'; // Charge tableau des categories $cate_arbo = $categstatic->get_full_arbo($type); // Define fulltree array $fulltree = $cate_arbo; // Define data (format for treeview) $data = array(); $data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => "racine", 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => ''); foreach ($fulltree as $key => $val) { $categstatic->id = $val['id']; $categstatic->ref = $val['label']; $categstatic->type = $type; $li = $categstatic->getNomUrl(1, '', 60); $desc = dol_htmlcleanlastbr($val['description']); $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => '<table class="nobordernopadding centpercent"><tr><td>' . $li . '</td><td width="50%">' . dolGetFirstLineOfText($desc) . '</td>' . '<td align="right" width="20px;"><a href="' . DOL_URL_ROOT . '/categories/viewcat.php?id=' . $val['id'] . '&type=' . $type . '">' . img_view() . '</a></td>' . '</tr></table>'); } print '<table class="liste nohover" width="100%">'; print '<tr class="liste_titre"><td>' . $langs->trans("Categories") . '</td><td></td><td align="right">'; if (!empty($conf->use_javascript_ajax)) { print '<div id="iddivjstreecontrol"><a href="#">' . img_picto('', 'object_category') . ' ' . $langs->trans("UndoExpandAll") . '</a> | <a href="#">' . img_picto('', 'object_category-expanded') . ' ' . $langs->trans("ExpandAll") . '</a></div>'; } print '</td></tr>'; $nbofentries = count($data) - 1; if ($nbofentries > 0) { print '<tr ' . $bc[0] . '><td colspan="3">'; tree_recur($data, $data[0], 0); print '</td></tr>'; } else { print '<tr ' . $bc[0] . '>';
/** * Add an action/event into database * * @param User $user Object user making action * @param int $notrigger 1 = disable triggers, 0 = enable triggers * @return int Id of created event, < 0 if KO */ function add($user, $notrigger = 0) { global $langs, $conf, $hookmanager; $error = 0; $now = dol_now(); // Clean parameters $this->label = dol_trunc(trim($this->label), 128); $this->location = dol_trunc(trim($this->location), 128); $this->note = dol_htmlcleanlastbr(trim($this->note)); if (empty($this->percentage)) { $this->percentage = 0; } if (empty($this->priority) || !is_numeric($this->priority)) { $this->priority = 0; } if (empty($this->fulldayevent)) { $this->fulldayevent = 0; } if (empty($this->punctual)) { $this->punctual = 0; } if (empty($this->transparency)) { $this->transparency = 0; } if ($this->percentage > 100) { $this->percentage = 100; } //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; if (!empty($this->datep) && !empty($this->datef)) { $this->durationp = $this->datef - $this->datep; } //if (! empty($this->date) && ! empty($this->dateend)) $this->durationa=($this->dateend - $this->date); if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) { $this->datef = $this->datep; } //if (! empty($this->date) && ! empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date; if (!isset($this->fk_project) || $this->fk_project < 0) { $this->fk_project = 0; } if ($this->elementtype == 'facture') { $this->elementtype = 'invoice'; } if ($this->elementtype == 'commande') { $this->elementtype = 'order'; } if ($this->elementtype == 'contrat') { $this->elementtype = 'contract'; } if (!$this->type_id && $this->type_code) { // Get id from code $cactioncomm = new CActionComm($this->db); $result = $cactioncomm->fetch($this->type_code); if ($result > 0) { $this->type_id = $cactioncomm->id; $this->code = $cactioncomm->code; } else { if ($result == 0) { $this->error = 'Failed to get record with code ' . $this->type_code . ' from dictionary "type of events"'; return -1; } else { $this->error = $cactioncomm->error; return -1; } } } // Check parameters if (!$this->type_id) { $this->error = "ErrorWrongParameters"; return -1; } $this->db->begin(); $sql = "INSERT INTO " . MAIN_DB_PREFIX . "actioncomm"; $sql .= "(datec,"; $sql .= "datep,"; $sql .= "datep2,"; $sql .= "durationp,"; $sql .= "fk_action,"; $sql .= "code,"; $sql .= "fk_soc,"; $sql .= "fk_project,"; $sql .= "note,"; $sql .= "fk_contact,"; $sql .= "fk_user_author,"; $sql .= "fk_user_action,"; $sql .= "fk_user_done,"; $sql .= "label,percent,priority,fulldayevent,location,punctual,"; $sql .= "transparency,"; $sql .= "fk_element,"; $sql .= "elementtype,"; $sql .= "entity"; $sql .= ") VALUES ("; $sql .= "'" . $this->db->idate($now) . "',"; $sql .= (strval($this->datep) != '' ? "'" . $this->db->idate($this->datep) . "'" : "null") . ","; $sql .= (strval($this->datef) != '' ? "'" . $this->db->idate($this->datef) . "'" : "null") . ","; $sql .= (isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '' ? "'" . $this->durationp . "'" : "null") . ","; $sql .= (isset($this->type_id) ? $this->type_id : "null") . ","; $sql .= (isset($this->code) ? " '" . $this->code . "'" : "null") . ","; $sql .= (isset($this->societe->id) && $this->societe->id > 0 ? " '" . $this->societe->id . "'" : "null") . ","; $sql .= (isset($this->fk_project) && $this->fk_project > 0 ? " '" . $this->fk_project . "'" : "null") . ","; $sql .= " '" . $this->db->escape($this->note) . "',"; $sql .= (isset($this->contact->id) && $this->contact->id > 0 ? "'" . $this->contact->id . "'" : "null") . ","; $sql .= (isset($user->id) && $user->id > 0 ? "'" . $user->id . "'" : "null") . ","; $sql .= (isset($this->usertodo->id) && $this->usertodo->id > 0 ? "'" . $this->usertodo->id . "'" : "null") . ","; $sql .= (isset($this->userdone->id) && $this->userdone->id > 0 ? "'" . $this->userdone->id . "'" : "null") . ","; $sql .= "'" . $this->db->escape($this->label) . "','" . $this->percentage . "','" . $this->priority . "','" . $this->fulldayevent . "','" . $this->db->escape($this->location) . "','" . $this->punctual . "',"; $sql .= "'" . $this->transparency . "',"; $sql .= (!empty($this->fk_element) ? $this->fk_element : "null") . ","; $sql .= (!empty($this->elementtype) ? "'" . $this->elementtype . "'" : "null") . ","; $sql .= $conf->entity; $sql .= ")"; dol_syslog(get_class($this) . "::add sql=" . $sql); $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "actioncomm", "id"); // Actions on extra fields (by external module or standard code) $hookmanager->initHooks(array('actioncommdao')); $parameters = array('actcomm' => $this->id); $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } } else { if ($reshook < 0) { $error++; } } if (!$error && !$notrigger) { // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface = new Interfaces($this->db); $result = $interface->run_triggers('ACTION_CREATE', $this, $user, $langs, $conf); if ($result < 0) { $error++; $this->errors = $interface->errors; } // Fin appel triggers } if (!$error) { $this->db->commit(); return $this->id; } else { $this->db->rollback(); return -1; } } else { $this->db->rollback(); $this->error = $this->db->lasterror(); dol_syslog(get_class($this) . "::add " . $this->error, LOG_ERR); return -1; } }