function doActions($parameters, &$object, &$action, $hookmanager) { if (GETPOST('addcontratline')) { $fk_line_contrat_origin = GETPOST('fk_line_contrat_origin', 'int'); if ($fk_line_contrat_origin > 0) { global $db; dol_include_once('/contrat/class/contrat.class.php'); $lineContrat = new ContratLigne($db); $res = $lineContrat->fetch($fk_line_contrat_origin); if ($res > 0) { $linePropal = new PropaleLigne($db); $array_options = array(); require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($db); $TExtra = $extrafields->fetch_name_optionals_label($linePropal->table_element); // Récupération des extrafields de la ligne contrat vers la ligne propal $lineContrat->fetch_optionals(); foreach ($lineContrat->array_options as $key => $val) { $subkey = substr($key, 8); if (isset($TExtra[$subkey])) { $array_options[$key] = $val; } } if (isset($TExtra['fk_contratdet_origin'])) { $array_options['options_fk_contratdet_origin'] = $lineContrat->id; } $object->addline($lineContrat->description, $lineContrat->subprice, $lineContrat->qty, $lineContrat->tva_tx, $lineContrat->localtax1_tx, $lineContrat->localtax2_tx, $lineContrat->fk_product, $lineContrat->remise_percent, 'HT', 0.0, $lineContrat->info_bits, 1, -1, 0, 0, 0, $lineContrat->pa_ht, '', $lineContrat->date_ouverture_prevue, $lineContrat->date_fin_validite, $array_options, $lineContrat->fk_unit); } } } }
/** * Add/Update all extra fields values for the current object. * All data to describe values to insert are stored into $this->array_options=array('keyextrafield'=>'valueextrafieldtoadd') * * @return void */ function insertExtraFields() { global $langs; $error = 0; if (!empty($this->array_options)) { // Check parameters $langs->load('admin'); require_once DOL_DOCUMENT_ROOT . "/core/class/extrafields.class.php"; $extrafields = new ExtraFields($this->db); $optionsArray = $extrafields->fetch_name_optionals_label($this->elementType); foreach ($this->array_options as $key => $value) { $attributeKey = substr($key, 8); // Remove 'options_' prefix $attributeType = $extrafields->attribute_type[$attributeKey]; $attributeSize = $extrafields->attribute_size[$attributeKey]; $attributeLabel = $extrafields->attribute_label[$attributeKey]; switch ($attributeType) { case 'int': if (!is_numeric($value) && $value != '') { $error++; $this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel); return -1; } elseif ($value == '') { $this->array_options[$key] = null; } break; } } $this->db->begin(); $sql_del = "DELETE FROM " . MAIN_DB_PREFIX . $this->table_element . "_extrafields WHERE fk_object = " . $this->id; dol_syslog(get_class($this) . "::insertExtraFields delete sql=" . $sql_del); $this->db->query($sql_del); $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . "_extrafields (fk_object"; foreach ($this->array_options as $key => $value) { // Add field of attribut $sql .= "," . substr($key, 8); // Remove 'options_' prefix } $sql .= ") VALUES (" . $this->id; foreach ($this->array_options as $key => $value) { // Add field o fattribut if ($this->array_options[$key] != '') { $sql .= ",'" . $this->array_options[$key] . "'"; } else { $sql .= ",null"; } } $sql .= ")"; dol_syslog(get_class($this) . "::insertExtraFields insert sql=" . $sql); $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->lasterror(); dol_syslog(get_class($this) . "::update " . $this->error, LOG_ERR); $this->db->rollback(); return -1; } else { $this->db->commit(); return 1; } } else { return 0; } }
/** * Get list of products for a category * * @param array $authentication Array of authentication information * @param array $id Category id * @param $lang $lang Force lang * @return array Array result */ function getProductsForCategory($authentication, $id, $lang = '') { global $db, $conf, $langs; $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT); $langs->setDefaultLang($langcode); dol_syslog("Function: getProductsForCategory login="******" id=" . $id); if ($authentication['entity']) { $conf->entity = $authentication['entity']; } $objectresp = array(); $errorcode = ''; $errorlabel = ''; $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); if (!$error && !$id) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id must be provided."; } if (!$error) { $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT); $langs->setDefaultLang($langcode); $fuser->getrights(); if ($fuser->rights->produit->lire) { $categorie = new Categorie($db); $result = $categorie->fetch($id); if ($result > 0) { $table = "product"; $field = "product"; $sql = "SELECT fk_" . $field . " FROM " . MAIN_DB_PREFIX . "categorie_" . $table; $sql .= " WHERE fk_categorie = " . $id; $sql .= " ORDER BY fk_" . $field . " ASC"; dol_syslog("getProductsForCategory get id of product into category", LOG_DEBUG); $res = $db->query($sql); if ($res) { while ($rec = $db->fetch_array($res)) { $obj = new Product($db); $obj->fetch($rec['fk_' . $field]); $iProduct = 0; if ($obj->status > 0) { $dir = !empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output; $pdir = get_exdir($obj->id, 2) . $obj->id . "/photos/"; $dir = $dir . '/' . $pdir; $products[] = array('id' => $obj->id, 'ref' => $obj->ref, 'ref_ext' => $obj->ref_ext, 'label' => !empty($obj->multilangs[$langs->defaultlang]["label"]) ? $obj->multilangs[$langs->defaultlang]["label"] : $obj->label, 'description' => !empty($obj->multilangs[$langs->defaultlang]["description"]) ? $obj->multilangs[$langs->defaultlang]["description"] : $obj->description, 'date_creation' => dol_print_date($obj->date_creation, 'dayhourrfc'), 'date_modification' => dol_print_date($obj->date_modification, 'dayhourrfc'), 'note' => !empty($obj->multilangs[$langs->defaultlang]["note"]) ? $obj->multilangs[$langs->defaultlang]["note"] : $obj->note, 'status_tosell' => $obj->status, 'status_tobuy' => $obj->status_buy, 'type' => $obj->type, 'barcode' => $obj->barcode, 'barcode_type' => $obj->barcode_type, 'country_id' => $obj->country_id > 0 ? $obj->country_id : '', 'country_code' => $obj->country_code, 'custom_code' => $obj->customcode, 'price_net' => $obj->price, 'price' => $obj->price_ttc, 'vat_rate' => $obj->tva_tx, 'price_base_type' => $obj->price_base_type, 'stock_real' => $obj->stock_reel, 'stock_alert' => $obj->seuil_stock_alerte, 'pmp' => $obj->pmp, 'import_key' => $obj->import_key, 'dir' => $pdir, 'images' => $obj->liste_photos($dir, $nbmax = 10)); //Retreive all extrafield for thirdsparty // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label('product', true); //Get extrafield values $product->fetch_optionals($obj->id, $extralabels); foreach ($extrafields->attribute_label as $key => $label) { $products[$iProduct] = array_merge($products[$iProduct], array('options_' . $key => $product->array_options['options_' . $key])); } $iProduct++; } } // Retour $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'products' => $products); } else { $errorcode = 'NORECORDS_FOR_ASSOCIATION'; $errorlabel = 'No products associated' . $sql; $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); dol_syslog("getProductsForCategory:: " . $c->error, LOG_DEBUG); } } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id=' . $id; } } 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; }
if ($id == "") { dol_print_error('', 'Missing parameter id'); exit; } // Security check $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); $result = $object->fetch($id); $object->fetch_optionals($id, $extralabels); if ($result <= 0) { dol_print_error($db, $object->error); exit; } $type = $object->type; $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('categorycard')); /* * Actions */ // Remove element from category if ($id > 0 && $removeelem > 0) { if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) { require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $tmpobject = new Product($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'product'; } else { if ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) { $tmpobject = new Societe($db);
// sync_extrafields: Search list of fields declared and list of fields created into databases and create fields missing if ($ok) { $extrafields=new ExtraFields($db); $listofmodulesextra=array('societe'=>'societe','adherent'=>'adherent','product'=>'product', 'socpeople'=>'socpeople', 'commande'=>'commande', 'facture'=>'facture', 'commande_fournisseur'=>'commande_fournisseur', 'actioncomm'=>'actioncomm', 'adherent_type'=>'adherent_type','user'=>'user','projet'=>'projet', 'projet_task'=>'projet_task'); foreach($listofmodulesextra as $tablename => $elementtype) { // Get list of fields $tableextra=MAIN_DB_PREFIX.$tablename.'_extrafields'; // Define $arrayoffieldsdesc $arrayoffieldsdesc=$extrafields->fetch_name_optionals_label($elementtype); // Define $arrayoffieldsfound $arrayoffieldsfound=array(); $resql=$db->DDLDescTable($tableextra); if ($resql) { print '<tr><td>Check availability of extra field for '.$tableextra."<br>\n"; $i=0; while($obj=$db->fetch_object($resql)) { $fieldname=$fieldtype=''; if (preg_match('/mysql/',$db->type)) { $fieldname=$obj->Field; $fieldtype=$obj->Type;
/** * Load object in memory from the database * * @param string $sortorder order * @param string $sortfield field * @param int $limit page * @param int $offset Offset results * @param array $filter output * * @return int <0 if KO, >0 if OK */ function fetch_all($sortorder, $sortfield, $limit, $offset, $filter = array()) { global $langs; $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.ref,"; $sql .= " t.ref_ext,"; $sql .= " t.ref_int,"; $sql .= " t.fk_c_status,"; $sql .= " t.fk_c_type,"; $sql .= " t.fk_soc,"; $sql .= " t.date_closure,"; $sql .= " t.amount_prosp,"; $sql .= " t.fk_user_resp,"; $sql .= " t.description,"; $sql .= " t.note_private,"; $sql .= " t.note_public,"; $sql .= " t.fk_user_author,"; $sql .= " t.datec,"; $sql .= " t.fk_user_mod,"; $sql .= " t.tms"; $sql .= " FROM " . MAIN_DB_PREFIX . "lead as t"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as so ON so.rowid=t.fk_soc"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as usr ON usr.rowid=t.fk_user_resp"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_lead_status as leadsta ON leadsta.rowid=t.fk_c_status"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_lead_type as leadtype ON leadtype.rowid=t.fk_c_type"; $sql .= " WHERE t.entity IN (" . getEntity('lead') . ")"; if (is_array($filter)) { foreach ($filter as $key => $value) { if ($key == 't.fk_c_status' || $key == 't.rowid' || $key == 'so.rowid' || $key == 't.fk_c_type' || $key == 't.fk_user_resp') { $sql .= ' AND ' . $key . ' = ' . $value; } elseif ($key == 't.date_closure<') { // To allow $filter['YEAR(s.dated)']=>$year $sql .= " AND t.date_closure<='" . $this->db->idate($value) . "'"; } elseif (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year $sql .= ' AND ' . $key . ' = \'' . $value . '\''; } elseif ($key == 't.fk_c_status !IN') { $sql .= ' AND t.fk_c_status NOT IN (' . $value . ')'; } elseif ($key == 't.rowid !IN') { $sql .= ' AND t.rowid NOT IN (' . $value . ')'; } else { $sql .= ' AND ' . $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; } } } if (!empty($sortfield)) { $sql .= " ORDER BY " . $sortfield . ' ' . $sortorder; } if (!empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); } dol_syslog(get_class($this) . "::fetch_all sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->lines = array(); $num = $this->db->num_rows($resql); while ($obj = $this->db->fetch_object($resql)) { $line = new Lead($this->db, 1); $line->id = $obj->rowid; $line->ref = $obj->ref; $line->ref_ext = $obj->ref_ext; $line->ref_int = $obj->ref_int; $line->fk_c_status = $obj->fk_c_status; $line->fk_c_type = $obj->fk_c_type; $line->fk_soc = $obj->fk_soc; $line->date_closure = $this->db->jdate($obj->date_closure); $line->amount_prosp = $obj->amount_prosp; $line->fk_user_resp = $obj->fk_user_resp; $line->description = $obj->description; $line->note_private = $obj->note_private; $line->note_public = $obj->note_public; $line->fk_user_author = $obj->fk_user_author; $line->datec = $this->db->jdate($obj->datec); $line->fk_user_mod = $obj->fk_user_mod; $line->tms = $this->db->jdate($obj->tms); $line->status_label = $this->status[$line->fk_c_status]; $line->type_label = $this->type[$line->fk_c_type]; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); if (count($extralabels) > 0) { $line->fetch_optionals($line->id, $extralabels); } $this->lines[] = $line; } $this->db->free($resql); return $num; } else { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::fetch_all " . $this->error, LOG_ERR); return -1; } }
/** * Create ActionComm * * @param array $authentication Array of authentication information * @param ActionComm $actioncomm $actioncomm * @return array Array result */ function updateActionComm($authentication, $actioncomm) { global $db, $conf, $langs; $now = dol_now(); dol_syslog("Function: updateActionComm login="******"Actioncomm id is mandatory."; } if (!$error) { $objectfound = false; $object = new ActionComm($db); $result = $object->fetch($actioncomm['id']); if (!empty($object->id)) { $objectfound = true; $object->datep = $actioncomm['datep']; $object->datef = $actioncomm['datef']; $object->type_code = $actioncomm['type_code']; $object->societe->id = $actioncomm['socid']; $object->fk_project = $actioncomm['projectid']; $object->note = $actioncomm['note']; $object->contact->id = $actioncomm['contactid']; $object->usertodo->id = $actioncomm['usertodo']; $object->userdone->id = $actioncomm['userdone']; $object->label = $actioncomm['label']; $object->percentage = $actioncomm['percentage']; $object->priority = $actioncomm['priority']; $object->fulldayevent = $actioncomm['fulldayevent']; $object->location = $actioncomm['location']; $object->fk_element = $actioncomm['fk_element']; $object->elementtype = $actioncomm['elementtype']; //Retreive all extrafield for actioncomm // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label('actioncomm', true); foreach ($extrafields->attribute_label as $key => $label) { $key = 'options_' . $key; $object->array_options[$key] = $actioncomm[$key]; } $db->begin(); $result = $object->update($fuser); if ($result <= 0) { $error++; } } if (!$error && $objectfound) { $db->commit(); $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $object->id); } elseif ($objectfound) { $db->rollback(); $error++; $errorcode = 'KO'; $errorlabel = $object->error; } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Actioncomm id=' . $actioncomm['id'] . ' cannot be found'; } } if ($error) { $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; }
/** * Get object and lines from database * * @param int $rowid Id of object to load * @param string $ref Reference of invoice * @param string $ref_ext External reference of invoice * @param int $ref_int Internal reference of other object * @return int >0 if OK, <0 if KO, 0 if not found */ function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '') { global $conf; if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) { return -1; } $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount,f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; $sql .= ', f.datef as df'; $sql .= ', f.date_lim_reglement as dlr'; $sql .= ', f.datec as datec'; $sql .= ', f.date_valid as datev'; $sql .= ', f.tms as datem'; $sql .= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf'; $sql .= ', f.fk_facture_source'; $sql .= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams'; $sql .= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; $sql .= ', f.fk_account'; $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; $sql .= ', f.fk_incoterms, f.location_incoterms'; $sql .= ", i.libelle as libelle_incoterms"; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture as f'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_paiement as p ON f.fk_mode_reglement = p.id'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_incoterms as i ON f.fk_incoterms = i.rowid'; $sql .= ' WHERE f.entity = ' . $conf->entity; if ($rowid) { $sql .= " AND f.rowid=" . $rowid; } if ($ref) { $sql .= " AND f.facnumber='" . $this->db->escape($ref) . "'"; } if ($ref_ext) { $sql .= " AND f.ref_ext='" . $this->db->escape($ref_ext) . "'"; } if ($ref_int) { $sql .= " AND f.ref_int='" . $this->db->escape($ref_int) . "'"; } dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; $this->ref = $obj->facnumber; $this->ref_client = $obj->ref_client; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; $this->type = $obj->type; $this->date = $this->db->jdate($obj->df); $this->date_creation = $this->db->jdate($obj->datec); $this->date_validation = $this->db->jdate($obj->datev); $this->datem = $this->db->jdate($obj->datem); $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; $this->total_ht = $obj->total; $this->total_tva = $obj->tva; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; $this->total_ttc = $obj->total_ttc; $this->revenuestamp = $obj->revenuestamp; $this->paye = $obj->paye; $this->close_code = $obj->close_code; $this->close_note = $obj->close_note; $this->socid = $obj->fk_soc; $this->statut = $obj->fk_statut; $this->date_lim_reglement = $this->db->jdate($obj->dlr); $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement = $obj->mode_reglement_libelle; $this->cond_reglement_id = $obj->fk_cond_reglement; $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement_libelle; $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; $this->fk_account = $obj->fk_account > 0 ? $obj->fk_account : null; $this->fk_project = $obj->fk_projet; $this->fk_facture_source = $obj->fk_facture_source; $this->note = $obj->note_private; // deprecated $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->user_author = $obj->fk_user_author; $this->user_valid = $obj->fk_user_valid; $this->modelpdf = $obj->model_pdf; $this->situation_cycle_ref = $obj->situation_cycle_ref; $this->situation_counter = $obj->situation_counter; $this->situation_final = $obj->situation_final; $this->extraparams = (array) json_decode($obj->extraparams, true); //Incoterms $this->fk_incoterms = $obj->fk_incoterms; $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; if ($this->statut == self::STATUS_DRAFT) { $this->brouillon = 1; } // Retrieve all extrafield for invoice // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id, $extralabels); /* * Lines */ $this->lines = array(); $result = $this->fetch_lines(); if ($result < 0) { $this->error = $this->db->error(); return -3; } return 1; } else { $this->error = 'Bill with id ' . $rowid . ' or ref ' . $ref . ' not found sql=' . $sql; dol_syslog(get_class($this) . "::fetch Error " . $this->error, LOG_ERR); return 0; } } else { $this->error = $this->db->error(); return -1; } }
/** * Load a bank account into memory from database * * @param int $id Id of bank account to get * @param string $ref Ref of bank account to get * @return int <0 if KO, >0 if OK */ function fetch($id, $ref = '') { global $conf; if (empty($id) && empty($ref)) { $this->error = "ErrorBadParameters"; return -1; } $sql = "SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,"; $sql .= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,"; $sql .= " ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,"; $sql .= " ba.account_number, ba.accountancy_journal, ba.currency_code,"; $sql .= " ba.min_allowed, ba.min_desired, ba.comment,"; $sql .= ' c.code as country_code, c.label as country,'; $sql .= ' d.code_departement as state_code, d.nom as state'; $sql .= " FROM " . MAIN_DB_PREFIX . "bank_account as ba"; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as c ON ba.fk_pays = c.rowid'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_departements as d ON ba.state_id = d.rowid'; $sql .= " WHERE entity IN (" . getEntity($this->element, 1) . ")"; if ($id) { $sql .= " AND ba.rowid = " . $id; } if ($ref) { $sql .= " AND ba.ref = '" . $this->db->escape($ref) . "'"; } dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; $this->rowid = $obj->rowid; // deprecated $this->ref = $obj->ref; $this->label = $obj->label; $this->type = $obj->courant; $this->courant = $obj->courant; $this->bank = $obj->bank; $this->clos = $obj->clos; $this->rappro = $obj->rappro; $this->url = $obj->url; $this->code_banque = $obj->code_banque; $this->code_guichet = $obj->code_guichet; $this->number = $obj->number; $this->cle_rib = $obj->cle_rib; $this->bic = $obj->bic; $this->iban = $obj->iban; $this->domiciliation = $obj->domiciliation; $this->proprio = $obj->proprio; $this->owner_address = $obj->owner_address; $this->state_id = $obj->state_id; $this->state_code = $obj->state_code; $this->state = $obj->state; $this->country_id = $obj->country_id; $this->country_code = $obj->country_code; $this->country = $obj->country; $this->account_number = $obj->account_number; $this->accountancy_journal = $obj->accountancy_journal; $this->currency_code = $obj->currency_code; $this->account_currency_code = $obj->currency_code; $this->min_allowed = $obj->min_allowed; $this->min_desired = $obj->min_desired; $this->comment = $obj->comment; // Retreive all extrafield for thirdparty // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id, $extralabels); return 1; } else { return 0; } } else { dol_print_error($this->db); return -1; } }
/** * Load member from database * * @param int $rowid Id of object to load * @param string $ref To load member from its ref * @param int $fk_soc To load member from its link to third party * @param string $ref_ext External reference * @return int >0 if OK, 0 if not found, <0 if KO */ function fetch($rowid, $ref = '', $fk_soc = '', $ref_ext = '') { global $langs; $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_id, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; $sql .= " d.note_public,"; $sql .= " d.email, d.skype, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,"; $sql .= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; $sql .= " d.datec as datec,"; $sql .= " d.tms as datem,"; $sql .= " d.datefin as datefin,"; $sql .= " d.birth as birthday,"; $sql .= " d.datevalid as datev,"; $sql .= " d.country,"; $sql .= " d.state_id,"; $sql .= " c.rowid as country_id, c.code as country_code, c.label as country,"; $sql .= " dep.nom as state, dep.code_departement as state_code,"; $sql .= " t.libelle as type, t.cotisation as cotisation,"; $sql .= " u.rowid as user_id, u.login as user_login"; $sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type as t, " . MAIN_DB_PREFIX . "adherent as d"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as c ON d.country = c.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_departements as dep ON d.state_id = dep.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u ON d.rowid = u.fk_member"; $sql .= " WHERE d.fk_adherent_type = t.rowid"; if ($rowid) { $sql .= " AND d.rowid=" . $rowid; } elseif ($ref || $fk_soc) { $sql .= " AND d.entity IN (" . getEntity() . ")"; if ($ref) { $sql .= " AND d.rowid='" . $this->db->escape($ref) . "'"; } elseif ($fk_soc) { $sql .= " AND d.fk_soc='" . $fk_soc . "'"; } } elseif ($ref_ext) { $sql .= " AND d.ref_ext='" . $this->db->escape($ref_ext) . "'"; } dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->entity = $obj->entity; $this->ref = $obj->rowid; $this->id = $obj->rowid; $this->ref_ext = $obj->ref_ext; $this->civility_id = $obj->civility_id; $this->firstname = $obj->firstname; $this->lastname = $obj->lastname; $this->login = $obj->login; $this->pass = $obj->pass; $this->societe = $obj->company; $this->company = $obj->company; $this->fk_soc = $obj->fk_soc; $this->address = $obj->address; $this->zip = $obj->zip; $this->town = $obj->town; $this->state_id = $obj->state_id; $this->state_code = $obj->state_id ? $obj->state_code : ''; $this->state = $obj->state_id ? $obj->state : ''; $this->country_id = $obj->country_id; $this->country_code = $obj->country_code; if ($langs->trans("Country" . $obj->country_code) != "Country" . $obj->country_code) { $this->country = $langs->transnoentitiesnoconv("Country" . $obj->country_code); } else { $this->country = $obj->country; } $this->phone = $obj->phone; $this->phone_perso = $obj->phone_perso; $this->phone_mobile = $obj->phone_mobile; $this->email = $obj->email; $this->skype = $obj->skype; $this->photo = $obj->photo; $this->statut = $obj->statut; $this->public = $obj->public; $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); $this->datefin = $this->db->jdate($obj->datefin); $this->datevalid = $this->db->jdate($obj->datev); $this->birth = $this->db->jdate($obj->birthday); $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->morphy = $obj->morphy; $this->typeid = $obj->fk_adherent_type; $this->type = $obj->type; $this->need_subscription = $obj->cotisation == 'yes' ? 1 : 0; $this->user_id = $obj->user_id; $this->user_login = $obj->user_login; // Retreive all extrafield for thirdparty // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id, $extralabels); // Load other properties $result = $this->fetch_subscriptions(); return $result; } else { return 0; } } else { $this->error = $this->db->lasterror(); return -1; } }
/** * Get object and lines from database * * @param int $id Id of object to load * @param string $ref Ref of object * @param string $ref_ext External reference of object * @param string $ref_int Internal reference of other object * @return int >0 if OK, <0 if KO, 0 if not found */ function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') { global $conf; // Check parameters if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) { return -1; } $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut'; $sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; $sql .= ', c.fk_account'; $sql .= ', c.date_commande'; $sql .= ', c.date_livraison'; $sql .= ', c.fk_shipping_method'; $sql .= ', c.fk_warehouse'; $sql .= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed'; $sql .= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_delivery_address, c.extraparams'; $sql .= ', c.fk_incoterms, c.location_incoterms'; $sql .= ", i.libelle as libelle_incoterms"; $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql .= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc'; $sql .= ', ca.code as availability_code, ca.label as availability_label'; $sql .= ', dr.code as demand_reason_code'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'commande as c'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid)'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_paiement as p ON (c.fk_mode_reglement = p.id)'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_availability as ca ON (c.fk_availability = ca.rowid)'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_input_reason as dr ON (c.fk_input_reason = ca.rowid)'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_incoterms as i ON c.fk_incoterms = i.rowid'; $sql .= " WHERE c.entity IN (" . getEntity('commande', 1) . ")"; if ($id) { $sql .= " AND c.rowid=" . $id; } if ($ref) { $sql .= " AND c.ref='" . $this->db->escape($ref) . "'"; } if ($ref_ext) { $sql .= " AND c.ref_ext='" . $this->db->escape($ref_ext) . "'"; } if ($ref_int) { $sql .= " AND c.ref_int='" . $this->db->escape($ref_int) . "'"; } dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); if ($obj) { $this->id = $obj->rowid; $this->ref = $obj->ref; $this->ref_client = $obj->ref_client; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; $this->socid = $obj->fk_soc; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; $this->total_ht = $obj->total_ht; $this->total_tva = $obj->total_tva; $this->total_localtax1 = $obj->total_localtax1; $this->total_localtax2 = $obj->total_localtax2; $this->total_ttc = $obj->total_ttc; $this->date = $this->db->jdate($obj->date_commande); $this->date_commande = $this->db->jdate($obj->date_commande); $this->remise = $obj->remise; $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; $this->source = $obj->source; $this->facturee = $obj->billed; // deprecated $this->billed = $obj->billed; $this->note = $obj->note_private; // deprecated $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->fk_project = $obj->fk_projet; $this->modelpdf = $obj->model_pdf; $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement = $obj->mode_reglement_libelle; $this->cond_reglement_id = $obj->fk_cond_reglement; $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement_libelle; $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; $this->fk_account = $obj->fk_account; $this->availability_id = $obj->fk_availability; $this->availability_code = $obj->availability_code; $this->availability = $obj->availability_label; $this->demand_reason_id = $obj->fk_input_reason; $this->demand_reason_code = $obj->demand_reason_code; $this->date_livraison = $this->db->jdate($obj->date_livraison); $this->shipping_method_id = $obj->fk_shipping_method > 0 ? $obj->fk_shipping_method : null; $this->warehouse_id = $obj->fk_warehouse > 0 ? $obj->fk_warehouse : null; $this->fk_delivery_address = $obj->fk_delivery_address; //Incoterms $this->fk_incoterms = $obj->fk_incoterms; $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; $this->extraparams = (array) json_decode($obj->extraparams, true); $this->lines = array(); if ($this->statut == self::STATUS_DRAFT) { $this->brouillon = 1; } // Retrieve all extrafields for invoice // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id, $extralabels); $this->db->free($result); /* * Lines */ $result = $this->fetch_lines(); if ($result < 0) { return -3; } return 1; } else { $this->error = 'Order with id ' . $id . ' not found sql=' . $sql; return 0; } } else { $this->error = $this->db->error(); return -1; } }
// Action confirmation suppression if ($action == 'confirm_delete' && $confirm == 'yes') { if ($object->delete($object->id)) { $url = !empty($urlfrom) ? $urlfrom : 'liste.php'; Header("Location: " . $url); exit; } } if (!empty($_POST["cancel"])) { $action = ''; } /* * View */ // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('mailing'); $help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'; llxHeader('', $langs->trans("Mailing"), $help_url); $form = new Form($db); $htmlother = new FormOther($db); if ($action == 'create') { // EMailing in creation mode print '<form name="new_mailing" action="' . $_SERVER['PHP_SELF'] . '" method="POST">' . "\n"; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="action" value="add">'; print_fiche_titre($langs->trans("NewMailing")); dol_htmloutput_mesg($mesg); print '<table class="border" width="100%">'; print '<tr><td width="25%" class="fieldrequired">' . $langs->trans("MailTitle") . '</td><td><input class="flat" name="titre" size="40" value="' . $_POST['titre'] . '"></td></tr>'; print '<tr><td width="25%" class="fieldrequired">' . $langs->trans("MailFrom") . '</td><td><input class="flat" name="from" size="40" value="' . $conf->global->MAILING_EMAIL_FROM . '"></td></tr>'; print '<tr><td width="25%">' . $langs->trans("MailErrorsTo") . '</td><td><input class="flat" name="errorsto" size="40" value="' . (!empty($conf->global->MAILING_EMAIL_ERRORSTO) ? $conf->global->MAILING_EMAIL_ERRORSTO : $conf->global->MAIN_MAIL_ERRORS_TO) . '"></td></tr>';
$contextpage = 'prospectlist'; if ($search_type == '') { $search_type = '2,3'; } } if ($type == 'f') { $contextpage = 'supplierlist'; if ($search_type == '') { $search_type = '4'; } } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('thirdparty'); $search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array('s.nom' => "ThirdPartyName", 's.name_alias' => "AliasNameShort", 's.code_client' => "CustomerCode", "s.code_fournisseur" => "SupplierCode", 's.email' => "EMail", 's.url' => "URL", 's.tva_intra' => "VATIntra", 's.siren' => "ProfId1", 's.siret' => "ProfId2", 's.ape' => "ProfId3"); if (($tmp = $langs->transnoentities("ProfId4" . $mysoc->country_code)) && $tmp != "ProfId4" . $mysoc->country_code && $tmp != '-') { $fieldstosearchall['s.idprof4'] = 'ProfId4'; } if (($tmp = $langs->transnoentities("ProfId5" . $mysoc->country_code)) && $tmp != "ProfId5" . $mysoc->country_code && $tmp != '-') { $fieldstosearchall['s.idprof5'] = 'ProfId5'; } if (($tmp = $langs->transnoentities("ProfId6" . $mysoc->country_code)) && $tmp != "ProfId6" . $mysoc->country_code && $tmp != '-') { $fieldstosearchall['s.idprof6'] = 'ProfId6'; } if (!empty($conf->barcode->enabled)) { $fieldstosearchall['s.barcode'] = 'Gencod'; }
/** * Load a user from database with its id or ref (login) * * @param int $id Si defini, id a utiliser pour recherche * @param string $login Si defini, login a utiliser pour recherche * @param string $sid Si defini, sid a utiliser pour recherche * @param int $loadpersonalconf Also load personal conf of user (in $user->conf->xxx) * @param int $entity If a value is >= 0, we force the search on a specific entity. If -1, means search depens on default setup. * @return int <0 if KO, 0 not found, >0 if OK */ function fetch($id = '', $login = '', $sid = '', $loadpersonalconf = 1, $entity = -1) { global $langs, $conf, $user; // Clean parameters $login = trim($login); // Get user $sql = "SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.email, u.job, u.skype, u.signature, u.office_phone, u.office_fax, u.user_mobile,"; $sql .= " u.address, u.zip, u.town, u.fk_state as state_id, u.fk_country as country_id,"; $sql .= " u.admin, u.login, u.note,"; $sql .= " u.pass, u.pass_crypted, u.pass_temp, u.api_key,"; $sql .= " u.fk_soc, u.fk_socpeople, u.fk_member, u.fk_user, u.ldap_sid,"; $sql .= " u.statut, u.lang, u.entity,"; $sql .= " u.datec as datec,"; $sql .= " u.tms as datem,"; $sql .= " u.datelastlogin as datel,"; $sql .= " u.datepreviouslogin as datep,"; $sql .= " u.photo as photo,"; $sql .= " u.openid as openid,"; $sql .= " u.accountancy_code,"; $sql .= " u.thm,"; $sql .= " u.tjm,"; $sql .= " u.salary,"; $sql .= " u.salaryextra,"; $sql .= " u.weeklyhours,"; $sql .= " u.color,"; $sql .= " u.ref_int, u.ref_ext,"; $sql .= " c.code as country_code, c.label as country,"; $sql .= " d.code_departement as state_code, d.nom as state"; $sql .= " FROM " . MAIN_DB_PREFIX . "user as u"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as c ON u.fk_country = c.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_departements as d ON u.fk_state = d.rowid"; if ($entity < 0) { if ((empty($conf->multicompany->enabled) || empty($conf->multicompany->transverse_mode)) && !empty($user->entity)) { $sql .= " WHERE u.entity IN (0," . $conf->entity . ")"; } else { $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database } } else { $sql .= " WHERE u.entity IN (0, " . $conf->entity . ")"; } if ($sid) { $sql .= " AND (u.ldap_sid = '" . $this->db->escape($sid) . "' OR u.login = '******') LIMIT 1"; } else { if ($login) { $sql .= " AND u.login = '******'"; } else { $sql .= " AND u.rowid = " . $id; } } dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); if ($obj) { $this->id = $obj->rowid; $this->ref = $obj->rowid; $this->ref_int = $obj->ref_int; $this->ref_ext = $obj->ref_ext; $this->ldap_sid = $obj->ldap_sid; $this->lastname = $obj->lastname; $this->firstname = $obj->firstname; $this->employee = $obj->employee; $this->login = $obj->login; $this->gender = $obj->gender; $this->pass_indatabase = $obj->pass; $this->pass_indatabase_crypted = $obj->pass_crypted; $this->pass = $obj->pass; $this->pass_temp = $obj->pass_temp; $this->api_key = $obj->api_key; $this->address = $obj->address; $this->zip = $obj->zip; $this->town = $obj->town; $this->country_id = $obj->country_id; $this->country_code = $obj->country_id ? $obj->country_code : ''; $this->country = $obj->country_id ? $langs->trans('Country' . $obj->country_code) != 'Country' . $obj->country_code ? $langs->transnoentities('Country' . $obj->country_code) : $obj->country : ''; $this->state_id = $obj->state_id; $this->state_code = $obj->state_code; $this->state = $obj->state != '-' ? $obj->state : ''; $this->office_phone = $obj->office_phone; $this->office_fax = $obj->office_fax; $this->user_mobile = $obj->user_mobile; $this->email = $obj->email; $this->skype = $obj->skype; $this->job = $obj->job; $this->signature = $obj->signature; $this->admin = $obj->admin; $this->note = $obj->note; $this->statut = $obj->statut; $this->photo = $obj->photo; $this->openid = $obj->openid; $this->lang = $obj->lang; $this->entity = $obj->entity; $this->accountancy_code = $obj->accountancy_code; $this->thm = $obj->thm; $this->tjm = $obj->tjm; $this->salary = $obj->salary; $this->salaryextra = $obj->salaryextra; $this->weeklyhours = $obj->weeklyhours; $this->color = $obj->color; $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); $this->datelastlogin = $this->db->jdate($obj->datel); $this->datepreviouslogin = $this->db->jdate($obj->datep); $this->societe_id = $obj->fk_soc; // deprecated $this->contact_id = $obj->fk_socpeople; // deprecated $this->socid = $obj->fk_soc; $this->contactid = $obj->fk_socpeople; $this->fk_member = $obj->fk_member; $this->fk_user = $obj->fk_user; // Retreive all extrafield for thirdparty // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id, $extralabels); $this->db->free($result); } else { $this->error = "USERNOTFOUND"; dol_syslog(get_class($this) . "::fetch user not found", LOG_DEBUG); $this->db->free($result); return 0; } } else { $this->error = $this->db->error(); return -1; } // To get back the global configuration unique to the user if ($loadpersonalconf) { $sql = "SELECT param, value FROM " . MAIN_DB_PREFIX . "user_param"; $sql .= " WHERE fk_user = "******" AND entity = " . $conf->entity; //dol_syslog(get_class($this).'::fetch load personalized conf', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $p = !empty($obj->param) ? $obj->param : ''; if (!empty($p)) { $this->conf->{$p} = $obj->value; } $i++; } $this->db->free($resql); } else { $this->error = $this->db->error(); return -2; } } return 1; }
$contextpage = 'contactsupplierlist'; $titre .= ' (' . $langs->trans("ThirdPartySuppliers") . ')'; $urlfiche = "card.php"; } else { if ($type == "o") { $contextpage = 'contactotherlist'; $titre .= ' (' . $langs->trans("OthersNotLinkedToThirdParty") . ')'; $urlfiche = ""; } } } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('contact'); $search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array('p.lastname' => 'Lastname', 'p.firstname' => 'Firstname', 'p.email' => 'EMail', 's.nom' => "ThirdParty"); // Definition of fields for list $arrayfields = array('p.lastname' => array('label' => $langs->trans("Lastname"), 'checked' => 1), 'p.firstname' => array('label' => $langs->trans("Firsname"), 'checked' => 1), 'p.poste' => array('label' => $langs->trans("Post"), 'checked' => 1), 'p.town' => array('label' => $langs->trans("Town"), 'checked' => 0), 'p.zip' => array('label' => $langs->trans("Zip"), 'checked' => 0), 'p.phone' => array('label' => $langs->trans("PhonePro"), 'checked' => 1), 'p.phone_perso' => array('label' => $langs->trans("PhonePerso"), 'checked' => 0), 'p.phone_mobile' => array('label' => $langs->trans("PhoneMobile"), 'checked' => 1), 'p.fax' => array('label' => $langs->trans("Fax"), 'checked' => 1), 'p.email' => array('label' => $langs->trans("Email"), 'checked' => 1), 'p.skype' => array('label' => $langs->trans("Skype"), 'checked' => 1, 'enabled' => !empty($conf->skype->enabled)), 'p.thirdparty' => array('label' => $langs->trans("ThirdParty"), 'checked' => 1, 'enabled' => empty($conf->global->SOCIETE_DISABLE_CONTACTS)), 'p.priv' => array('label' => $langs->trans("ContactVisibility"), 'checked' => 1, 'position' => 200), 'p.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500), 'p.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 500), 'p.statut' => array('label' => $langs->trans("Status"), 'checked' => 1, 'position' => 1000)); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { foreach ($extrafields->attribute_label as $key => $val) { $arrayfields["ef." . $key] = array('label' => $extrafields->attribute_label[$key], 'checked' => $extrafields->attribute_list[$key], 'position' => $extrafields->attribute_pos[$key], 'enabled' => $extrafields->attribute_perms[$key]); } } $object = new Contact($db); if (($id > 0 || !empty($ref)) && $action != 'add') { $result = $object->fetch($id, $ref); if ($result < 0) {
/** * Load a contract from database * * @param int $id Id of contract to load * @param string $ref Ref * @return int <0 if KO, id of contract if OK */ function fetch($id, $ref = '') { $sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,"; $sql .= " fk_user_mise_en_service, date_contrat as datecontrat,"; $sql .= " fk_user_author,"; $sql .= " fk_projet,"; $sql .= " fk_commercial_signature, fk_commercial_suivi,"; $sql .= " note_private, note_public, model_pdf, extraparams"; $sql .= " ,ref_supplier"; $sql .= " ,ref_ext"; $sql .= " FROM " . MAIN_DB_PREFIX . "contrat"; if ($ref) { $sql .= " WHERE ref='" . $this->db->escape($ref) . "'"; $sql .= " AND entity IN (" . getEntity('contract') . ")"; } else { $sql .= " WHERE rowid=" . $id; } dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $result = $this->db->fetch_array($resql); if ($result) { $this->id = $result["rowid"]; $this->ref = !isset($result["ref"]) || !$result["ref"] ? $result["rowid"] : $result["ref"]; $this->ref_supplier = $result["ref_supplier"]; $this->ref_ext = $result["ref_ext"]; $this->statut = $result["statut"]; $this->mise_en_service = $this->db->jdate($result["datemise"]); $this->date_contrat = $this->db->jdate($result["datecontrat"]); $this->date_creation = $this->db->jdate($result["datecontrat"]); $this->user_author_id = $result["fk_user_author"]; $this->commercial_signature_id = $result["fk_commercial_signature"]; $this->commercial_suivi_id = $result["fk_commercial_suivi"]; $this->note = $result["note_private"]; // deprecated $this->note_private = $result["note_private"]; $this->note_public = $result["note_public"]; $this->modelpdf = $result["model_pdf"]; $this->fk_projet = $result["fk_projet"]; // deprecated $this->fk_project = $result["fk_projet"]; $this->socid = $result["fk_soc"]; $this->fk_soc = $result["fk_soc"]; $this->extraparams = (array) json_decode($result["extraparams"], true); $this->db->free($resql); // Retreive all extrafield for thirdparty // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id, $extralabels); /* * Lines */ $this->lines = array(); $result = $this->fetch_lines(); if ($result < 0) { $this->error = $this->db->lasterror(); return -3; } return $this->id; } else { dol_syslog(get_class($this) . "::Fetch Erreur contrat non trouve"); $this->error = "Contract not found"; return -2; } } else { dol_syslog(get_class($this) . "::Fetch Erreur lecture contrat"); $this->error = $this->db->error(); return -1; } }
$ref = GETPOST('ref', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $mode = GETPOST('mode', 'alpha'); $mine = $mode == 'mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects $object = new Project($db); $taskstatic = new Task($db); $extrafields_project = new ExtraFields($db); $extrafields_task = new ExtraFields($db); if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); $id = $object->id; $ref = $object->ref; // fetch optionals attributes and labels $extralabels_projet = $extrafields_project->fetch_name_optionals_label($object->table_element); $extralabels_task = $extrafields_task->fetch_name_optionals_label($taskstatic->table_element); } // Security check $socid = 0; if ($user->societe_id > 0) { $socid = $user->societe_id; } $result = restrictedArea($user, 'projet', $id); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('projecttaskcard', 'globalcard')); $progress = GETPOST('progress', 'int'); $label = GETPOST('label', 'alpha'); $description = GETPOST('description'); $planned_workload = GETPOST('planned_workloadhour') * 3600 + GETPOST('planned_workloadmin') * 60; $userAccess = 0; /*
/** * Load a product in memory from database * * @param int $id Id of product/service to load * @param string $ref Ref of product/service to load * @param string $ref_ext Ref ext of product/service to load * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead * @return int <0 if KO, 0 if not found, >0 if OK */ function fetch($id = '', $ref = '', $ref_ext = '', $ignore_expression = 0) { include_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; global $langs, $conf; dol_syslog(get_class($this) . "::fetch id=" . $id . " ref=" . $ref . " ref_ext=" . $ref_ext); // Check parameters if (!$id && !$ref && !$ref_ext) { $this->error = 'ErrorWrongParameters'; dol_print_error(get_class($this) . "::fetch " . $this->error); return -1; } $sql = "SELECT rowid, ref, ref_ext, label, description, url, note, customcode, fk_country, price, price_ttc,"; $sql .= " price_min, price_min_ttc, price_base_type, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, tosell,"; $sql .= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas,"; $sql .= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; $sql .= " accountancy_code_buy, accountancy_code_sell, stock, pmp,"; $sql .= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit"; $sql .= " , fk_price_expression"; $sql .= " FROM " . MAIN_DB_PREFIX . "product"; if ($id) { $sql .= " WHERE rowid = " . $this->db->escape($id); } else { $sql .= " WHERE entity IN (" . getEntity($this->element, 1) . ")"; if ($ref) { $sql .= " AND ref = '" . $this->db->escape($ref) . "'"; } else { if ($ref_ext) { $sql .= " AND ref_ext = '" . $this->db->escape($ref_ext) . "'"; } } } $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql) > 0) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; $this->ref = $obj->ref; $this->ref_ext = $obj->ref_ext; $this->label = $obj->label; $this->description = $obj->description; $this->url = $obj->url; $this->note = $obj->note; $this->type = $obj->fk_product_type; $this->status = $obj->tosell; $this->status_buy = $obj->tobuy; $this->status_batch = $obj->tobatch; $this->customcode = $obj->customcode; $this->country_id = $obj->fk_country; $this->country_code = getCountry($this->country_id, 2, $this->db); $this->price = $obj->price; $this->price_ttc = $obj->price_ttc; $this->price_min = $obj->price_min; $this->price_min_ttc = $obj->price_min_ttc; $this->price_base_type = $obj->price_base_type; $this->tva_tx = $obj->tva_tx; //! French VAT NPR $this->tva_npr = $obj->tva_npr; //! Spanish local taxes $this->localtax1_tx = $obj->localtax1_tx; $this->localtax2_tx = $obj->localtax2_tx; $this->finished = $obj->finished; $this->duration = $obj->duration; $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); $this->duration_unit = substr($obj->duration, -1); $this->canvas = $obj->canvas; $this->weight = $obj->weight; $this->weight_units = $obj->weight_units; $this->length = $obj->length; $this->length_units = $obj->length_units; $this->surface = $obj->surface; $this->surface_units = $obj->surface_units; $this->volume = $obj->volume; $this->volume_units = $obj->volume_units; $this->barcode = $obj->barcode; $this->barcode_type = $obj->fk_barcode_type; $this->accountancy_code_buy = $obj->accountancy_code_buy; $this->accountancy_code_sell = $obj->accountancy_code_sell; $this->seuil_stock_alerte = $obj->seuil_stock_alerte; $this->desiredstock = $obj->desiredstock; $this->stock_reel = $obj->stock; $this->pmp = $obj->pmp; $this->date_creation = $obj->datec; $this->date_modification = $obj->tms; $this->import_key = $obj->import_key; $this->entity = $obj->entity; $this->ref_ext = $obj->ref_ext; $this->fk_price_expression = $obj->fk_price_expression; $this->fk_unit = $obj->fk_unit; $this->db->free($resql); // Retreive all extrafield for current object // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id, $extralabels); // multilangs if (!empty($conf->global->MAIN_MULTILANGS)) { $this->getMultiLangs(); } // Load multiprices array if (!empty($conf->global->PRODUIT_MULTIPRICES)) { for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; $sql .= " price_base_type, tva_tx, tosell, price_by_qty, rowid, recuperableonly"; $sql .= " FROM " . MAIN_DB_PREFIX . "product_price"; $sql .= " WHERE entity IN (" . getEntity('productprice', 1) . ")"; $sql .= " AND price_level=" . $i; $sql .= " AND fk_product = '" . $this->id . "'"; $sql .= " ORDER BY date_price DESC"; $sql .= " LIMIT 1"; $resql = $this->db->query($sql); if ($resql) { $result = $this->db->fetch_array($resql); $this->multiprices[$i] = $result["price"]; $this->multiprices_ttc[$i] = $result["price_ttc"]; $this->multiprices_min[$i] = $result["price_min"]; $this->multiprices_min_ttc[$i] = $result["price_min_ttc"]; $this->multiprices_base_type[$i] = $result["price_base_type"]; $this->multiprices_tva_tx[$i] = $result["tva_tx"]; $this->multiprices_recuperableonly[$i] = $result["recuperableonly"]; // Price by quantity $this->prices_by_qty[$i] = $result["price_by_qty"]; $this->prices_by_qty_id[$i] = $result["rowid"]; // Récuperation de la liste des prix selon qty si flag positionné if ($this->prices_by_qty[$i] == 1) { $sql = "SELECT rowid,price, unitprice, quantity, remise_percent, remise"; $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty"; $sql .= " WHERE fk_product_price = '" . $this->prices_by_qty_id[$i] . "'"; $sql .= " ORDER BY quantity ASC"; $resultat = array(); $resql = $this->db->query($sql); if ($resql) { $ii = 0; while ($result = $this->db->fetch_array($resql)) { $resultat[$ii] = array(); $resultat[$ii]["rowid"] = $result["rowid"]; $resultat[$ii]["price"] = $result["price"]; $resultat[$ii]["unitprice"] = $result["unitprice"]; $resultat[$ii]["quantity"] = $result["quantity"]; $resultat[$ii]["remise_percent"] = $result["remise_percent"]; $resultat[$ii]["remise"] = $result["remise"]; $ii++; } $this->prices_by_qty_list[$i] = $resultat; } else { dol_print_error($this->db); return -1; } } } else { dol_print_error($this->db); return -1; } } } else { if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; $sql .= " price_base_type, tva_tx, tosell, price_by_qty, rowid"; $sql .= " FROM " . MAIN_DB_PREFIX . "product_price"; $sql .= " WHERE fk_product = '" . $this->id . "'"; $sql .= " ORDER BY date_price DESC"; $sql .= " LIMIT 1"; $resql = $this->db->query($sql); if ($resql) { $result = $this->db->fetch_array($resql); // Price by quantity $this->prices_by_qty[0] = $result["price_by_qty"]; $this->prices_by_qty_id[0] = $result["rowid"]; // Récuperation de la liste des prix selon qty si flag positionné if ($this->prices_by_qty[0] == 1) { $sql = "SELECT rowid,price, unitprice, quantity, remise_percent, remise"; $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty"; $sql .= " WHERE fk_product_price = '" . $this->prices_by_qty_id[0] . "'"; $sql .= " ORDER BY quantity ASC"; $resultat = array(); $resql = $this->db->query($sql); if ($resql) { $ii = 0; while ($result = $this->db->fetch_array($resql)) { $resultat[$ii] = array(); $resultat[$ii]["rowid"] = $result["rowid"]; $resultat[$ii]["price"] = $result["price"]; $resultat[$ii]["unitprice"] = $result["unitprice"]; $resultat[$ii]["quantity"] = $result["quantity"]; $resultat[$ii]["remise_percent"] = $result["remise_percent"]; $resultat[$ii]["remise"] = $result["remise"]; $ii++; } $this->prices_by_qty_list[0] = $resultat; } else { dol_print_error($this->db); return -1; } } } else { dol_print_error($this->db); return -1; } } } if (!empty($this->fk_price_expression) && empty($ignore_expression)) { require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php'; $priceparser = new PriceParser($this->db); $price_result = $priceparser->parseProduct($this); if ($price_result >= 0) { $this->price = $price_result; //Calculate the VAT $this->price_ttc = price2num($this->price) * (1 + $this->tva_tx / 100); $this->price_ttc = price2num($this->price_ttc, 'MU'); } } // We should not load stock at each fetch. If someone need stock, he must call load_stock after fetch. //$res=$this->load_stock(); // instead we just init the stock_warehouse array $this->stock_warehouse = array(); return 1; } else { return 0; } } else { dol_print_error($this->db); return -1; } }
/** * Charge un objet group avec toutes ces caracteristiques (excpet ->members array) * * @param int $id id du groupe a charger * @param string $groupname name du groupe a charger * @return int <0 if KO, >0 if OK */ function fetch($id = '', $groupname = '') { global $conf; $sql = "SELECT g.rowid, g.entity, g.nom as name, g.note, g.datec, g.tms as datem"; $sql .= " FROM " . MAIN_DB_PREFIX . "usergroup as g"; if ($groupname) { $sql .= " WHERE g.nom = '" . $this->db->escape($groupname) . "'"; } else { $sql .= " WHERE g.rowid = " . $id; } dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; $this->ref = $obj->rowid; $this->entity = $obj->entity; $this->name = $obj->name; $this->nom = $obj->name; // Deprecated $this->note = $obj->note; $this->datec = $obj->datec; $this->datem = $obj->datem; $this->members = $this->listUsersForGroup(); // Retreive all extrafield for group // fetch optionals attributes and labels dol_include_once('/core/class/extrafields.class.php'); $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id, $extralabels); // Sav current LDAP Current DN //$this->ldap_dn = $this->_load_ldap_dn($this->_load_ldap_info(),0); } $this->db->free($result); return 1; } else { $this->error = $this->db->lasterror(); return -1; } }
$form->select_date($timewithnohour, 'di', 1, 1, 0, "addinter"); print '</td>'; // Duration print '<td align="right">'; $selectmode = 'select'; if (!empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION)) { $selectmode = 'text'; } $form->select_duration('duration', !GETPOST('durationhour', 'int') && !GETPOST('durationmin', 'int') ? 3600 : 60 * 60 * GETPOST('durationhour', 'int') + 60 * GETPOST('durationmin', 'int'), 0, $selectmode); print '</td>'; print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="' . $langs->trans('Add') . '" name="addline"></td>'; print '</tr>'; //Line extrafield $lineadd = new FichinterLigne($db); $extrafieldsline = new ExtraFields($db); $extralabelslines = $extrafieldsline->fetch_name_optionals_label($lineadd->table_element); print $lineadd->showOptionals($extrafieldsline, 'edit', array('style' => $bc[$var], 'colspan' => 5)); if (!$num) { print '</table>'; } } if ($num) { print '</table>'; } } else { dol_print_error($db); } print '</form>' . "\n"; } dol_fiche_end(); print "\n";
*/ require DOL_DOCUMENT_ROOT . '/core/actions_extrafields.inc.php'; /* * View */ $textobject = $langs->transnoentitiesnoconv("Categories"); $help_url = 'EN:Module Categories|FR:Module Catégories|ES:Módulo Categorías'; llxHeader('', $langs->trans("Categories"), $help_url); $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>'; print_fiche_titre($langs->trans("CategoriesSetup"), $linkback, 'setup'); $head = categoriesadmin_prepare_head(); dol_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), 0, 'category'); print $langs->trans("DefineHereComplementaryAttributes", $textobject) . '<br>' . "\n"; print '<br>'; // Load attribute_label $extrafields->fetch_name_optionals_label($elementtype); print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">"; print '<tr class="liste_titre">'; print '<td>' . $langs->trans("Label") . '</td>'; print '<td>' . $langs->trans("AttributeCode") . '</td>'; print '<td>' . $langs->trans("Type") . '</td>'; print '<td align="right">' . $langs->trans("Size") . '</td>'; print '<td align="center">' . $langs->trans("Unique") . '</td>'; print '<td align="center">' . $langs->trans("Required") . '</td>'; print '<td width="80"> </td>'; print "</tr>\n"; $var = True; foreach ($extrafields->attribute_type as $key => $value) { $var = !$var; print "<tr " . $bc[$var] . ">"; print "<td>" . $extrafields->attribute_label[$key] . "</td>\n";
/** * Get object and lines from database * * @param int $id Id of object to load * @param string $ref Ref of object * @param string $ref_ext External reference of object * @param string $ref_int Internal reference of other object * @return int >0 if OK, 0 if not found, <0 if KO */ function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') { global $conf; // Check parameters if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) { return -1; } $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut"; $sql .= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; $sql .= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; $sql .= ", e.fk_shipping_method, e.tracking_number"; $sql .= ", el.fk_source as origin_id, el.sourcetype as origin"; $sql .= ", e.note_private, e.note_public"; $sql .= ', e.fk_incoterms, e.location_incoterms'; $sql .= ', i.libelle as libelle_incoterms'; $sql .= " FROM " . MAIN_DB_PREFIX . "expedition as e"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "element_element as el ON el.fk_target = e.rowid AND el.targettype = '" . $this->element . "'"; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_incoterms as i ON e.fk_incoterms = i.rowid'; $sql .= " WHERE e.entity IN (" . getEntity('expedition', 1) . ")"; if ($id) { $sql .= " AND e.rowid=" . $id; } if ($ref) { $sql .= " AND e.ref='" . $this->db->escape($ref) . "'"; } if ($ref_ext) { $sql .= " AND e.ref_ext='" . $this->db->escape($ref_ext) . "'"; } if ($ref_int) { $sql .= " AND e.ref_int='" . $this->db->escape($ref_int) . "'"; } dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; $this->ref = $obj->ref; $this->socid = $obj->socid; $this->ref_customer = $obj->ref_customer; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date = $this->db->jdate($obj->date_expedition); // TODO deprecated $this->date_expedition = $this->db->jdate($obj->date_expedition); // TODO deprecated $this->date_shipping = $this->db->jdate($obj->date_expedition); // Date real $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->fk_delivery_address = $obj->fk_address; $this->modelpdf = $obj->model_pdf; $this->shipping_method_id = $obj->fk_shipping_method; $this->tracking_number = $obj->tracking_number; $this->origin = $obj->origin ? $obj->origin : 'commande'; // For compatibility $this->origin_id = $obj->origin_id; $this->billed = $obj->fk_statut == 2 ? 1 : 0; $this->trueWeight = $obj->weight; $this->weight_units = $obj->weight_units; $this->trueWidth = $obj->width; $this->width_units = $obj->size_units; $this->trueHeight = $obj->height; $this->height_units = $obj->size_units; $this->trueDepth = $obj->size; $this->depth_units = $obj->size_units; $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; // A denormalized value $this->trueSize = $obj->size . "x" . $obj->width . "x" . $obj->height; $this->size_units = $obj->size_units; //Incoterms $this->fk_incoterms = $obj->fk_incoterms; $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; $this->db->free($result); if ($this->statut == 0) { $this->brouillon = 1; } $file = $conf->expedition->dir_output . "/" . get_exdir($this->id, 2, 0, 0, $this, 'shipment') . "/" . $this->id . ".pdf"; $this->pdf_filename = $file; // Tracking url $this->GetUrlTrackingStatus($obj->tracking_number); /* * Thirparty */ $result = $this->fetch_thirdparty(); // Retrieve all extrafields for expedition // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id, $extralabels); /* * Lines */ $result = $this->fetch_lines(); if ($result < 0) { return -3; } return 1; } else { dol_syslog(get_class($this) . '::Fetch no expedition found', LOG_ERR); $this->error = 'Delivery with id ' . $id . ' not found'; return 0; } } else { $this->error = $this->db->error(); return -1; } }
$adh->town = $_POST["town"]; $adh->email = $_POST["email"]; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { $adh->login = $_POST["login"]; $adh->pass = $_POST["pass1"]; } $adh->photo = $_POST["photo"]; $adh->note = $_POST["note"]; $adh->country_id = $_POST["country_id"]; $adh->state_id = $_POST["state_id"]; $adh->typeid = $_POST["type"]; $adh->note = $_POST["comment"]; $adh->morphy = $_POST["morphy"]; $adh->birth = $birthday; // Fill array 'array_options' with data from add form $extralabels = $extrafields->fetch_name_optionals_label($adh->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $adh); $result = $adh->create($user); if ($result > 0) { require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; // Send email to say it has been created and will be validated soon... if (!empty($conf->global->ADHERENT_AUTOREGISTER_MAIL) && !empty($conf->global->ADHERENT_AUTOREGISTER_MAIL_SUBJECT)) { $result = $adh->send_an_email($conf->global->ADHERENT_AUTOREGISTER_MAIL, $conf->global->ADHERENT_AUTOREGISTER_MAIL_SUBJECT, array(), array(), array(), "", "", 0, -1); } // Send email to the foundation to say a new member subscribed with autosubscribe form if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL) && !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT) && !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL)) { $to = $adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL); $from = $conf->global->ADHERENT_MAIL_FROM; $mailfile = new CMailFile($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT, $to, $from, $adh->makeSubstitution($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL), array(), array(), array(), "", "", 0, -1); if (!$mailfile->sendfile()) { dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
/** * Get object and lines from database * * @param int $id Id of order to load * @param string $ref Ref of object * @return int >0 if OK, <0 if KO, 0 if not found */ function fetch($id, $ref = '') { global $conf; // Check parameters if (empty($id) && empty($ref)) { return -1; } $sql = "SELECT c.rowid, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva,"; $sql .= " c.localtax1, c.localtax2, "; $sql .= " c.date_creation, c.date_valid, c.date_approve, c.date_approve2,"; $sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_approve, c.fk_user_approve2,"; $sql .= " c.date_commande as date_commande, c.date_livraison as date_livraison, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_projet as fk_project, c.remise_percent, c.source, c.fk_input_method,"; $sql .= " c.fk_account,"; $sql .= " c.note_private, c.note_public, c.model_pdf, c.extraparams, c.billed,"; $sql .= " cm.libelle as methode_commande,"; $sql .= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,"; $sql .= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle"; $sql .= ', c.fk_incoterms, c.location_incoterms'; $sql .= ', i.libelle as libelle_incoterms'; $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseur as c"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid)"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_paiement as p ON (c.fk_mode_reglement = p.id)"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_input_method as cm ON cm.rowid = c.fk_input_method"; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_incoterms as i ON c.fk_incoterms = i.rowid'; $sql .= " WHERE c.entity = " . $conf->entity; if ($ref) { $sql .= " AND c.ref='" . $this->db->escape($ref) . "'"; } else { $sql .= " AND c.rowid=" . $id; } dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); if (!$obj) { $this->error = 'Bill with id ' . $id . ' not found'; dol_syslog(get_class($this) . '::fetch ' . $this->error); return 0; } $this->id = $obj->rowid; $this->ref = $obj->ref; $this->ref_supplier = $obj->ref_supplier; $this->socid = $obj->fk_soc; $this->fourn_id = $obj->fk_soc; $this->statut = $obj->fk_statut; $this->billed = $obj->billed; $this->user_author_id = $obj->fk_user_author; $this->user_valid_id = $obj->fk_user_valid; $this->user_approve_id = $obj->fk_user_approve; $this->user_approve_id2 = $obj->fk_user_approve2; $this->total_ht = $obj->total_ht; $this->total_tva = $obj->tva; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; $this->total_ttc = $obj->total_ttc; $this->date = $this->db->jdate($obj->date_creation); $this->date_valid = $this->db->jdate($obj->date_valid); $this->date_approve = $this->db->jdate($obj->date_approve); $this->date_approve2 = $this->db->jdate($obj->date_approve2); $this->date_commande = $this->db->jdate($obj->date_commande); // date we make the order to supplier $this->date_livraison = $this->db->jdate($obj->date_livraison); $this->remise_percent = $obj->remise_percent; $this->methode_commande_id = $obj->fk_input_method; $this->methode_commande = $obj->methode_commande; $this->source = $obj->source; $this->fk_project = $obj->fk_project; $this->cond_reglement_id = $obj->fk_cond_reglement; $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement_libelle; $this->cond_reglement_doc = $obj->cond_reglement_libelle; $this->fk_account = $obj->fk_account; $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement = $obj->mode_reglement_libelle; $this->note = $obj->note_private; // deprecated $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->modelpdf = $obj->model_pdf; //Incoterms $this->fk_incoterms = $obj->fk_incoterms; $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; $this->extraparams = (array) json_decode($obj->extraparams, true); $this->db->free($resql); // Retreive all extrafield // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id, $extralabels); if ($this->statut == 0) { $this->brouillon = 1; } $this->fetchObjectLinked(); $sql = "SELECT l.rowid, l.ref as ref_supplier, l.fk_product, l.product_type, l.label, l.description,"; $sql .= " l.qty,"; $sql .= " l.tva_tx, l.remise_percent, l.subprice,"; $sql .= " l.localtax1_tx, l. localtax2_tx, l.total_localtax1, l.total_localtax2,"; $sql .= " l.total_ht, l.total_tva, l.total_ttc, l.special_code, l.fk_parent_line, l.rang,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,"; $sql .= " l.fk_unit,"; $sql .= " l.date_start, l.date_end"; $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet\tas l"; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product as p ON l.fk_product = p.rowid'; $sql .= " WHERE l.fk_commande = " . $this->id; $sql .= " ORDER BY l.rang, l.rowid"; //print $sql; dol_syslog(get_class($this) . "::fetch get lines", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); $i = 0; while ($i < $num) { $objp = $this->db->fetch_object($result); $line = new CommandeFournisseurLigne($this->db); $line->id = $objp->rowid; $line->desc = $objp->description; $line->description = $objp->description; $line->qty = $objp->qty; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; $line->subprice = $objp->subprice; $line->pu_ht = $objp->subprice; $line->remise_percent = $objp->remise_percent; $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; $line->total_localtax1 = $objp->total_localtax1; $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; $line->product_type = $objp->product_type; $line->fk_product = $objp->fk_product; $line->libelle = $objp->product_label; $line->product_label = $objp->product_label; $line->product_desc = $objp->product_desc; $line->ref = $objp->product_ref; $line->product_ref = $objp->product_ref; $line->ref_fourn = $objp->ref_supplier; $line->ref_supplier = $objp->ref_supplier; $line->date_start = $this->db->jdate($objp->date_start); $line->date_end = $this->db->jdate($objp->date_end); $line->fk_unit = $objp->fk_unit; $this->special_line = $objp->special_line; $this->fk_parent_line = $objp->fk_parent_line; $this->rang = $objp->rang; $this->lines[$i] = $line; $i++; } $this->db->free($result); return 1; } else { $this->error = $this->db->error() . " sql=" . $sql; return -1; } } else { $this->error = $this->db->error() . " sql=" . $sql; return -1; } }
// 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') : ''); // If buying_price is '0', we muste keep this value // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { unset($_POST["options_" . $key]); } } // Define special_code for special lines $special_code = GETPOST('special_code'); if (!GETPOST('qty')) { $special_code = 3; } $line = new FactureLigne($db); $line->fetch(GETPOST('lineid'));
/** * Load a proposal from database and its ligne array * * @param int $rowid id of object to load * @param string $ref Ref of proposal * @return int >0 if OK, <0 if KO */ function fetch($rowid, $ref = '') { global $conf; $sql = "SELECT p.rowid, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; $sql .= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; $sql .= ", p.datec"; $sql .= ", p.date_valid as datev"; $sql .= ", p.datep as dp"; $sql .= ", p.fin_validite as dfv"; $sql .= ", p.date_livraison as date_livraison"; $sql .= ", p.model_pdf, p.ref_client, p.extraparams"; $sql .= ", p.note_private, p.note_public"; $sql .= ", p.fk_projet, p.fk_statut"; $sql .= ", p.fk_user_author, p.fk_user_valid, p.fk_user_cloture"; $sql .= ", p.fk_delivery_address"; $sql .= ", p.fk_availability"; $sql .= ", p.fk_input_reason"; $sql .= ", p.fk_cond_reglement"; $sql .= ", p.fk_mode_reglement"; $sql .= ', p.fk_account'; $sql .= ", p.fk_shipping_method"; $sql .= ", c.label as statut_label"; $sql .= ", ca.code as availability_code, ca.label as availability"; $sql .= ", dr.code as demand_reason_code, dr.label as demand_reason"; $sql .= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; $sql .= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_propalst as c, " . MAIN_DB_PREFIX . "propal as p"; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_paiement as cp ON p.fk_mode_reglement = cp.id'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_availability as ca ON p.fk_availability = ca.rowid'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_input_reason as dr ON p.fk_input_reason = dr.rowid'; $sql .= " WHERE p.fk_statut = c.id"; $sql .= " AND p.entity = " . $conf->entity; if ($ref) { $sql .= " AND p.ref='" . $ref . "'"; } else { $sql .= " AND p.rowid=" . $rowid; } dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; $this->ref = $obj->ref; $this->ref_client = $obj->ref_client; $this->remise = $obj->remise; $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; $this->total = $obj->total; // TODO obsolete $this->total_ht = $obj->total_ht; $this->total_tva = $obj->tva; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; $this->total_ttc = $obj->total; $this->socid = $obj->fk_soc; $this->fk_project = $obj->fk_projet; $this->modelpdf = $obj->model_pdf; $this->note = $obj->note_private; // TODO obsolete $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->statut = $obj->fk_statut; $this->statut_libelle = $obj->statut_label; $this->datec = $this->db->jdate($obj->datec); // TODO obsolete $this->datev = $this->db->jdate($obj->datev); // TODO obsolete $this->date_creation = $this->db->jdate($obj->datec); //Creation date $this->date_validation = $this->db->jdate($obj->datev); //Validation date $this->date = $this->db->jdate($obj->dp); // Proposal date $this->datep = $this->db->jdate($obj->dp); // deprecated $this->fin_validite = $this->db->jdate($obj->dfv); $this->date_livraison = $this->db->jdate($obj->date_livraison); $this->shipping_method_id = $obj->fk_shipping_method > 0 ? $obj->fk_shipping_method : null; $this->availability_id = $obj->fk_availability; $this->availability_code = $obj->availability_code; $this->availability = $obj->availability; $this->demand_reason_id = $obj->fk_input_reason; $this->demand_reason_code = $obj->demand_reason_code; $this->demand_reason = $obj->demand_reason; $this->fk_address = $obj->fk_delivery_address; $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement = $obj->mode_reglement; $this->fk_account = $obj->fk_account > 0 ? $obj->fk_account : null; $this->cond_reglement_id = $obj->fk_cond_reglement; $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement; $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; $this->extraparams = (array) json_decode($obj->extraparams, true); $this->user_author_id = $obj->fk_user_author; $this->user_valid_id = $obj->fk_user_valid; $this->user_close_id = $obj->fk_user_cloture; if ($obj->fk_statut == 0) { $this->brouillon = 1; } // Retreive all extrafield for invoice // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id, $extralabels); $this->db->free($resql); $this->lines = array(); /* * Lignes propales liees a un produit ou non */ $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; $sql .= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; $sql .= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; $sql .= ' d.date_start, d.date_end'; $sql .= " FROM " . MAIN_DB_PREFIX . "propaldet as d"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON d.fk_product = p.rowid"; $sql .= " WHERE d.fk_propal = " . $this->id; $sql .= " ORDER by d.rang"; $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); $i = 0; while ($i < $num) { $objp = $this->db->fetch_object($result); $line = new PropaleLigne($this->db); $line->rowid = $objp->rowid; $line->fk_propal = $objp->fk_propal; $line->fk_parent_line = $objp->fk_parent_line; $line->product_type = $objp->product_type; $line->label = $objp->custom_label; $line->desc = $objp->description; // Description ligne $line->qty = $objp->qty; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; $line->subprice = $objp->subprice; $line->fk_remise_except = $objp->fk_remise_except; $line->remise_percent = $objp->remise_percent; $line->price = $objp->price; // TODO deprecated $line->info_bits = $objp->info_bits; $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; $line->total_localtax1 = $objp->total_localtax1; $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; $line->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); $line->pa_ht = $marginInfos[0]; $line->marge_tx = $marginInfos[1]; $line->marque_tx = $marginInfos[2]; $line->special_code = $objp->special_code; $line->rang = $objp->rang; $line->fk_product = $objp->fk_product; $line->ref = $objp->product_ref; // TODO deprecated $line->product_ref = $objp->product_ref; $line->libelle = $objp->product_label; // TODO deprecated $line->product_label = $objp->product_label; $line->product_desc = $objp->product_desc; // Description produit $line->fk_product_type = $objp->fk_product_type; $line->date_start = $objp->date_start; $line->date_end = $objp->date_end; $this->lines[$i] = $line; //dol_syslog("1 ".$line->fk_product); //print "xx $i ".$this->lines[$i]->fk_product; $i++; } $this->db->free($result); } else { $this->error = $this->db->error(); return -1; } // Retreive all extrafield for propal // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id, $extralabels); return 1; } $this->error = "Record Not Found"; return 0; } else { $this->error = $this->db->error(); return -1; } }
$upload_dir = $conf->societe->dir_output; $file = $upload_dir . '/' . GETPOST('file'); dol_delete_file($file,0,0,0,$object); $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>'; } } } /* * View */ // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label('company'); $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ThirdParty"),$help_url); $form = new Form($db); $formfile = new FormFile($db); $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // -----------------------------------------
/** * getListOfThirdParties * * @param array $authentication Array of authentication information * @param array $filterthirdparty Filter fields (key=>value to filer on. For example 'client'=>2, 'supplier'=>1, 'category'=>idcateg, 'name'=>'searchstring', ...) * @return array Array result */ function getListOfThirdParties($authentication, $filterthirdparty) { global $db, $conf, $langs; $now = dol_now(); dol_syslog("Function: getListOfThirdParties login="******"SELECT s.rowid as socRowid, s.nom as ref, s.ref_ext, s.address, s.zip, s.town, c.label as country, s.phone, s.fax, s.url, extra.*"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as c ON s.fk_pays = c.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_extrafields as extra ON s.rowid=fk_object"; $sql .= " WHERE entity=" . $conf->entity; foreach ($filterthirdparty as $key => $val) { if ($key == 'name' && $val != '') { $sql .= " AND s.name LIKE '%" . $db->escape($val) . "%'"; } if ($key == 'client' && $val != '') { $sql .= " AND s.client = " . $db->escape($val); } if ($key == 'supplier' && $val != '') { $sql .= " AND s.fournisseur = " . $db->escape($val); } if ($key == 'category' && $val != '') { $sql .= " AND s.rowid IN (SELECT fk_societe FROM " . MAIN_DB_PREFIX . "categorie_societe WHERE fk_categorie=" . $db->escape($val) . ") "; } } dol_syslog("Function: getListOfThirdParties", LOG_DEBUG); $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label('societe', true); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $extrafieldsOptions = array(); $obj = $db->fetch_object($resql); foreach ($extrafields->attribute_label as $key => $label) { $extrafieldsOptions['options_' . $key] = $obj->{$key}; } $arraythirdparties[] = array('id' => $obj->socRowid, 'ref' => $obj->ref, 'ref_ext' => $obj->ref_ext, 'adress' => $obj->adress, 'zip' => $obj->zip, 'town' => $obj->town, 'country' => $obj->country, 'phone' => $obj->phone, 'fax' => $obj->fax, 'url' => $obj->url); $arraythirdparties[$i] = array_merge($arraythirdparties[$i], $extrafieldsOptions); $i++; } } else { $error++; $errorcode = $db->lasterrno(); $errorlabel = $db->lasterror(); } } if ($error) { $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel), 'thirdparties' => $arraythirdparties); } else { $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'thirdparties' => $arraythirdparties); } return $objectresp; }
$contextpage = 'servicelist'; if ($search_type == '') { $search_type = '1'; } } if ($type === '0') { $contextpage = 'productlist'; if ($search_type == '') { $search_type = '0'; } } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('product'); $search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_'); if (empty($action)) { $action = 'list'; } // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $canvas = GETPOST("canvas"); $objcanvas = null; if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('product', 'list', $canvas); } // Security check if ($type == '0') { $result = restrictedArea($user, 'produit', '', '', '', '', '', $objcanvas);
if (!$sortorder) { $sortorder = "DESC"; } if (!$sortfield) { $sortfield = "d.lastname"; } $label = GETPOST("libelle", "alpha"); $cotisation = GETPOST("cotisation", "int"); $vote = GETPOST("vote", "int"); $comment = GETPOST("comment"); $mail_valid = GETPOST("mail_valid"); // Security check $result = restrictedArea($user, 'adherent', $rowid, 'adherent_type'); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('adherent_type'); if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { $search_lastname = ""; $search_login = ""; $search_email = ""; $type = ""; $sall = ""; } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('membertypecard', 'globalcard')); /* * Actions */ if ($action == 'add' && $user->rights->adherent->configurer) { if (!$cancel) { $object = new AdherentType($db);