Beispiel #1
0
 /**
  * Load object in memory from database
  *
  * @param int $id ID
  * @param string $tablename Name of the table
  *
  * @return int if KO, >0 if OK
  */
 public function fetchLeadLink($id, $tablename)
 {
     global $langs;
     $this->doclines = array();
     $sql = "SELECT";
     $sql .= " t.rowid,";
     $sql .= " t.fk_source,";
     $sql .= " t.sourcetype,";
     $sql .= " t.fk_target,";
     $sql .= " t.targettype";
     $sql .= " FROM " . MAIN_DB_PREFIX . "element_element as t";
     $sql .= " WHERE t.fk_source = " . $id;
     $sql .= " AND t.targettype='lead'";
     if (!empty($tablename)) {
         $sql .= " AND t.sourcetype='" . $tablename . "'";
     }
     $sql .= " ORDER BY t.sourcetype";
     dol_syslog(get_class($this) . "::fetchDocumentLink sql=" . $sql, LOG_DEBUG);
     $resql = $this->db->query($sql);
     if ($resql) {
         while ($obj = $this->db->fetch_object($resql)) {
             $line = new Lead($this->db);
             $line->fetch($obj->fk_target);
             $this->doclines[] = $line;
         }
         $this->db->free($resql);
         return 1;
     } else {
         $this->error = "Error " . $this->db->lasterror();
         dol_syslog(get_class($this) . "::fetchDocumentLink " . $this->error, LOG_ERR);
         return -1;
     }
 }
Beispiel #2
0
    $result = $usergroup->fetch($conf->global->LEAD_GRP_USER_AFFECT);
    if ($result < 0) {
        setEventMessages(null, $usergroup->errors, 'errors');
    }
    $includeuserlisttmp = $usergroup->listUsersForGroup();
    if (is_array($includeuserlisttmp) && count($includeuserlisttmp) > 0) {
        foreach ($includeuserlisttmp as $usertmp) {
            $includeuserlist[] = $usertmp->id;
        }
    }
}
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0) {
    $ret = $object->fetch($id);
    if ($ret < 0) {
        setEventMessages(null, $object->errors, 'errors');
    }
    if ($ret > 0) {
        $ret = $object->fetch_thirdparty();
    }
    if ($ret < 0) {
        setEventMessages(null, $object->errors, 'errors');
    }
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('leadcard'));
/*
 * Actions
 */
Beispiel #3
0
dol_include_once('/lead/class/lead.class.php');
$object = new Lead($db);
/*
 * Actions
 */
$tablename = GETPOST("tablename");
$leadid = GETPOST("leadid");
$elementselectid = GETPOST("elementselect");
$redirect = GETPOST('redirect', 'alpha');
$action = GETPOST('action');
if (empty($leadid) || $leadid == -1) {
    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lead")), null, 'errors');
    $error++;
}
if (!$error) {
    $result = $object->fetch($leadid);
    if ($result < 0) {
        setEventMessages(null, $object->errors, 'errors');
        $error++;
    }
}
if (!$error) {
    if ($action == 'link') {
        $result = $object->add_object_linked($tablename, $elementselectid);
        if ($result < 0) {
            setEventMessages(null, $object->errors, 'errors');
        }
    }
    if ($action == 'unlink') {
        $sourceid = GETPOST('sourceid');
        $sourcetype = GETPOST('sourcetype');
Beispiel #4
0
 llxHeader('', $langs->trans('Product'), 'EN:Commercial_Products|FR:Liste_des_produits|ES:Presupuestos');
 $id = GETPOST('id');
 $ref = GETPOST('ref');
 if ($id > 0 || !empty($ref)) {
     /*
      * Show object in view mode
      */
     if ($mesg) {
         if (!preg_match('/div class=/', $mesg)) {
             print '<div class="ok">' . $mesg . '</div><br>';
         } else {
             print $mesg . "<br>";
         }
     }
     $object = new Lead($db);
     $object->fetch($id, $ref);
     $soc = new Societe($db);
     $soc->fetch($object->socid);
     $head = lead_prepare_head($object);
     dol_fiche_head($head, 'category', $langs->trans('Products'), 0, 'lead');
     /*
      * Fiche Affaire
      *
      */
     print '<table class="border" width="100%">';
     $linkback = "<a href=\"product.php?page={$page}&socid={$socid}&viewstatut={$viewstatut}&sortfield={$sortfield}&{$sortorder}\">" . $langs->trans("BackToList") . "</a>";
     // Ref
     print '<tr><td>' . $langs->trans('Ref') . '</td><td colspan="5">';
     print $html->showrefnav($object, 'ref', '', 1, 'ref', 'ref', '');
     print '</td></tr>';
     $rowspan = 9;
Beispiel #5
0
$page = GETPOST("page", 'int');
if ($page == -1) {
    $page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
    $sortorder = "ASC";
}
if (!$sortfield) {
    $sortfield = "name";
}
$object = new Lead($db);
if ($id > 0) {
    $ret = $object->fetch($id);
    if ($ret < 0) {
        setEventMessage($object->error, 'errors');
    }
    if ($ret > 0) {
        $ret = $object->fetch_thirdparty();
    }
    if ($ret < 0) {
        setEventMessage($object->error, 'errors');
    }
    $upload_dir = $conf->lead->dir_output . "/" . dol_sanitizeFileName($object->ref);
}
/*
 * Actions
 */
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
Beispiel #6
0
     if ($act->contact->id && $act->type_code == 'AC_TEL') {
         if ($act->contact->fetch($act->contact->id)) {
             print "<br>" . dol_print_phone($act->contact->phone_pro);
         }
     }
 } else {
     print $langs->trans("None");
 }
 print '</td></tr>';
 $var = !$var;
 // Lead
 if ($conf->lead->enabled && $act->fk_lead) {
     print '<tr ' . $bc[$var] . '><td valign="top" id="label">' . $langs->trans("Lead") . '</td><td colspan="1" id="value">';
     if ($act->fk_lead) {
         $lead = new Lead($db);
         $lead->fetch($act->fk_lead);
         print $lead->getNomUrl(1);
     }
     print '</td></tr>';
     $var = !$var;
 }
 // Project
 if ($conf->projet->enabled) {
     print '<tr><td valign="top">' . $langs->trans("Project") . '</td><td colspan="3">';
     if ($act->fk_project) {
         $project = new Project($db);
         $project->fetch($act->fk_project);
         print $project->getNomUrl(1);
     }
     print '</td></tr>';
     $var = !$var;