/** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $user, $langs, $db, $conf; $this->max = $max; include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; $propalstatic = new Propal($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastPropals", $max)); if ($user->rights->propale->lire) { $sql = "SELECT s.nom, s.rowid as socid,"; $sql .= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; $sql .= ", " . MAIN_DB_PREFIX . "propal as p"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.entity = " . $conf->entity; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } $sql .= " ORDER BY p.datep DESC, p.ref DESC "; $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $now = dol_now(); $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); $datec = $db->jdate($objp->datec); $dateterm = $db->jdate($objp->fin_validite); $dateclose = $db->jdate($objp->date_cloture); $late = ''; if ($objp->fk_statut == 1 && $dateterm < $now - $conf->propal->cloture->warning_delay) { $late = img_warning($langs->trans("Late")); } $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/comm/propal.php?id=" . $objp->rowid); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->ref, 'text2' => $late, 'url' => DOL_URL_ROOT . "/comm/propal.php?id=" . $objp->rowid); $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $objp->socid); $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => dol_trunc($objp->nom, 40), 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $objp->socid); $this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => dol_print_date($datec, 'day')); $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($objp->fk_statut, 3)); $i++; } if ($num == 0) { $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedProposals")); } $db->free($result); } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }
function enteteexpedition(&$expedition) { global $langs, $db, $user, $hookmanager, $conf; $form = new Form($db); $soc = new Societe($db); $soc->fetch($expedition->socid); if (!empty($expedition->origin)) { $typeobject = $expedition->origin; $origin = $expedition->origin; $expedition->fetch_origin(); } print '<table class="border" width="100%">'; $linkback = '<a href="' . DOL_URL_ROOT . '/expedition/liste.php">' . $langs->trans("BackToList") . '</a>'; // Ref print '<tr><td width="20%">' . $langs->trans("Ref") . '</td>'; print '<td colspan="3">'; print $form->showrefnav($expedition, 'ref', $linkback, 1, 'ref', 'ref'); print '</td></tr>'; // Customer print '<tr><td width="20%">' . $langs->trans("Customer") . '</td>'; print '<td colspan="3">' . $soc->getNomUrl(1) . '</td>'; print "</tr>"; // Linked documents if ($typeobject == 'commande' && $expedition->{$typeobject}->id && !empty($conf->commande->enabled)) { print '<tr><td>'; $objectsrc = new Commande($db); $objectsrc->fetch($expedition->{$typeobject}->id); print $langs->trans("RefOrder") . '</td>'; print '<td colspan="3">'; print $objectsrc->getNomUrl(1, 'commande'); print "</td>\n"; print '</tr>'; } if ($typeobject == 'propal' && $expedition->{$typeobject}->id && !empty($conf->propal->enabled)) { print '<tr><td>'; $objectsrc = new Propal($db); $objectsrc->fetch($expedition->{$typeobject}->id); print $langs->trans("RefProposal") . '</td>'; print '<td colspan="3">'; print $objectsrc->getNomUrl(1, 'expedition'); print "</td>\n"; print '</tr>'; } // Ref customer print '<tr><td>' . $langs->trans("RefCustomer") . '</td>'; print '<td colspan="3">' . $expedition->ref_customer . "</a></td>\n"; print '</tr>'; // Date creation print '<tr><td>' . $langs->trans("DateCreation") . '</td>'; print '<td colspan="3">' . dol_print_date($expedition->date_creation, "day") . "</td>\n"; print '</tr>'; // Delivery date planed print '<tr><td height="10">'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans('DateDeliveryPlanned'); print '</td>'; print '</tr></table>'; print '</td><td colspan="2">'; print $expedition->date_delivery ? dol_print_date($expedition->date_delivery, 'dayhourtext') : ' '; print '</td>'; print '</tr>'; // Status print '<tr><td>' . $langs->trans("Status") . '</td>'; print '<td colspan="3">' . $expedition->getLibStatut(4) . "</td>\n"; print '</tr>'; // Sending method print '<tr><td height="10">'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans('SendingMethod'); print '</td>'; print '</tr></table>'; print '</td><td colspan="2">'; if ($expedition->shipping_method_id > 0) { // Get code using getLabelFromKey $code = $langs->getLabelFromKey($db, $expedition->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); print $langs->trans("SendingMethod" . strtoupper($code)); } print '</td>'; print '</tr>'; print "</table>\n"; }
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = " . $search_user; } $sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder . ', p.ref DESC'; $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } //print $sql; $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) { $objectstatic = new Propal($db); $userstatic = new User($db); $num = $db->num_rows($result); if ($socid) { $soc = new Societe($db); $soc->fetch($socid); } $param = '&socid=' . $socid . '&viewstatut=' . $viewstatut; if ($month) { $param .= '&month=' . $month; } if ($year) { $param .= '&year=' . $year; } if ($search_ref) { $param .= '&search_ref=' . $search_ref;
{ $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=".$_GET["bid"]; $result = $db->query($sql); } /* * View */ $now=dol_now(); $html = new Form($db); $formfile = new FormFile($db); $companystatic=new Societe($db); if ($conf->propal->enabled) $propalstatic=new Propal($db); llxHeader(); print_fiche_titre($langs->trans("CustomerArea")); print '<table border="0" width="100%" class="notopnoleftnoright">'; print '<tr>'; if (($conf->propal->enabled && $user->rights->propale->lire) || ($conf->contrat->enabled && $user->rights->contrat->lire) || ($conf->commande->enabled && $user->rights->commande->lire)) { print '<td valign="top" width="30%" class="notopnoleft">'; }
$formmail->withbody = 1; $formmail->withdeliveryreceipt = 1; $formmail->withcancel = 1; // Tableau des substitutions $formmail->substit['__SHIPPINGREF__'] = $object->ref; $formmail->substit['__SIGNATURE__'] = $user->signature; $formmail->substit['__PERSONALIZED__'] = ''; $formmail->substit['__CONTACTCIVNAME__'] = ''; //Find the good contact adress //Find the good contact adress if ($typeobject == 'commande' && $object->{$typeobject}->id && !empty($conf->commande->enabled)) { $objectsrc = new Commande($db); $objectsrc->fetch($object->{$typeobject}->id); } if ($typeobject == 'propal' && $object->{$typeobject}->id && !empty($conf->propal->enabled)) { $objectsrc = new Propal($db); $objectsrc->fetch($object->{$typeobject}->id); } $custcontact = ''; $contactarr = array(); $contactarr = $objectsrc->liste_contact(-1, 'external'); if (is_array($contactarr) && count($contactarr) > 0) { foreach ($contactarr as $contact) { if ($contact['libelle'] == $langs->trans('TypeContact_commande_external_CUSTOMER')) { require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; $contactstatic = new Contact($db); $contactstatic->fetch($contact['id']); $custcontact = $contactstatic->getFullName($langs, 1); } } if (!empty($custcontact)) {
/** * \brief Classe la commande comme facturee * \return int <0 si ko, >0 si ok */ function classer_facturee() { global $conf; $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'commande SET facture = 1'; $sql .= ' WHERE rowid = ' . $this->id . ' AND fk_statut > 0 ;'; if ($this->db->query($sql)) { if ($conf->global->PROPALE_CLASSIFIED_INVOICED_WITH_ORDER == 1 && $this->propale_id) { $propal = new Propal($this->db); $propal->fetch($this->propale_id); $propal->classer_facturee(); } return 1; } else { dol_print_error($this->db); return -1; } }
$langs->load('compta'); // Security check $socid = 0; $id = GETPOST('id', 'int'); $ref = GETPOST("ref"); if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'propal', $id); /* * View Mode */ $form = new Form($db); llxHeader(); if ($id > 0 || !empty($ref)) { $object = new Propal($db); if ($object->fetch($id, $ref) > 0) { $soc = new Societe($db); $soc->fetch($object->socid); $head = propal_prepare_head($object); dol_fiche_head($head, 'preview', $langs->trans('Proposal'), 0, 'propal'); /* * Propal */ print '<table class="border" width="100%">'; $linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php' . (!empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; // Ref print '<tr><td>' . $langs->trans('Ref') . '</td><td colspan="5">'; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); print '</td></tr>'; // Ref client
} elseif ($tmp == 'NotConfigured') { print $langs->trans($tmp); } else { print $tmp; } print '</td>' . "\n"; print '<td align="center">'; if ($conf->global->PROPALE_ADDON == "{$file}") { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setmod&value=' . $file . '">'; print img_picto($langs->trans("Disabled"), 'switch_off'); print '</a>'; } print '</td>'; $propal = new Propal($db); $propal->initAsSpecimen(); // Info $htmltooltip = ''; $htmltooltip .= '' . $langs->trans("Version") . ': <b>' . $module->getVersion() . '</b><br>'; $propal->type = 0; $nextval = $module->getNextValue($mysoc, $propal); if ("{$nextval}" != $langs->trans("NotAvailable")) { $htmltooltip .= '' . $langs->trans("NextValue") . ': '; if ($nextval) { $htmltooltip .= $nextval . '<br>'; } else { $htmltooltip .= $langs->trans($module->error) . '<br>'; } } print '<td align="center">';
/** * Delete preview files * @param db objet base de donnee * @param propalid id de la propal a effacer * @param propalref reference de la propal si besoin */ function propale_delete_preview($db, $propalid, $propalref = '') { global $langs, $conf; require_once DOL_DOCUMENT_ROOT . "/lib/files.lib.php"; if (!$propalref) { $propal = new Propal($db, "", $propalid); $propal->fetch($propalid); $propalref = $propal->ref; } if ($conf->propale->dir_output) { $propalref = dol_sanitizeFileName($propalref); $dir = $conf->propale->dir_output . "/" . $propalref; $file = $dir . "/" . $propalref . ".pdf.png"; $multiple = $file . "."; if (file_exists($file) && is_writable($file)) { if (!dol_delete_file($file, 1)) { $this->error = $langs->trans("ErrorFailedToOpenFile", $file); return 0; } } else { for ($i = 0; $i < 20; $i++) { $preview = $multiple . $i; if (file_exists($preview) && is_writable($preview)) { if (!unlink($preview)) { $this->error = $langs->trans("ErrorFailedToOpenFile", $preview); return 0; } } } } } return 1; }
// Number of customer orders a deal if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; $board = new Commande($db); $dashboardlines[] = $board->load_board($user); } // Number of suppliers orders a deal if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) { include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; $board = new CommandeFournisseur($db); $dashboardlines[] = $board->load_board($user); } // Number of commercial proposals opened (expired) if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; $board = new Propal($db); $dashboardlines[] = $board->load_board($user, "opened"); // Number of commercial proposals CLOSED signed (billed) $dashboardlines[] = $board->load_board($user, "signed"); } // Number of services enabled (delayed) if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { include_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php'; $board = new Contrat($db); $dashboardlines[] = $board->load_board($user, "inactives"); // Number of active services (expired) $dashboardlines[] = $board->load_board($user, "expired"); } // Number of invoices customers (has paid) if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
* \brief Page d'affichage des infos d'une proposition commerciale */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/propal.lib.php'; $langs->load('propal'); $langs->load('compta'); $id = GETPOST('id', 'int'); $socid = GETPOST('socid', 'int'); // Security check if (!empty($user->societe_id)) { $socid = $user->societe_id; } $result = restrictedArea($user, 'propal', $id); /* * View */ llxHeader('', $langs->trans('Proposal'), 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); $object = new Propal($db); $object->fetch($id); $object->fetch_thirdparty(); $head = propal_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans('Proposal'), 0, 'propal'); $object->info($object->id); print '<table width="100%"><tr><td>'; dol_print_object_info($object); print '</td></tr></table>'; print '</div>'; llxFooter(); $db->close();
/** * Charge les donnees en memoire pour affichage ulterieur * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $conf, $user, $langs, $db; include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $totalMnt = 0; $totalnb = 0; $line = 0; $cachetime = 3600; $fileid = '-e' . $conf->entity . '-u' . $user->id . '-s' . $user->societe_id . '-r' . ($user->rights->societe->client->voir ? '1' : '0') . '.cache'; $now = dol_now(); $nbofyears = 2; if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) { $nbofyears = $conf->global->MAIN_BOX_ACTIVITY_DURATION; } $textHead = $langs->trans("Activity") . ' - ' . $langs->trans("LastXMonthRolling", $nbofyears * 12); $this->info_box_head = array('text' => $textHead, 'limit' => dol_strlen($textHead)); // compute the year limit to show $tmpdate = dol_time_plus_duree(dol_now(), -1 * $nbofyears, "y"); $cumuldata = array(); // list the summary of the bills if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; $facturestatic = new Facture($db); $cachedir = DOL_DATA_ROOT . '/facture/temp'; $filename = '/boxactivity-invoice' . $fileid; $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); $data = array(); if ($refresh) { $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s," . MAIN_DB_PREFIX . "facture as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= ")"; $sql .= " WHERE f.entity = " . $conf->entity; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } $sql .= " AND f.fk_soc = s.rowid"; $sql .= " AND f.datef >= '" . $db->idate($tmpdate) . "' AND paye=1"; $sql .= " GROUP BY f.fk_statut"; $sql .= " ORDER BY f.fk_statut DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $j = 0; while ($j < $num) { $data[$j] = $db->fetch_object($result); $j++; } if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } $db->free($result); } else { dol_print_error($db); } } else { $data = dol_readcachefile($cachedir, $filename); } $cumuldata = array_merge($cumuldata, $data); if (!empty($data)) { $j = 0; while ($line < count($cumuldata)) { $billurl = "viewstatut=2&paye=1&year=" . $data[$j]->annee; $this->info_box_contents[$line][0] = array('td' => 'align="left" width="16"', 'tooltip' => $langs->trans('Bills') . ' ' . $facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&leftmenu=customers_bills", 'logo' => 'bill'); $this->info_box_contents[$line][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills") . " " . $facturestatic->LibStatut(1, $data[$j]->fk_statut, 0) . " " . $data[$j]->annee); $this->info_box_contents[$line][2] = array('td' => 'align="right"', 'tooltip' => $langs->trans('Bills') . ' ' . $facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), 'text' => $data[$j]->nb, 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&leftmenu=customers_bills"); $this->info_box_contents[$line][3] = array('td' => 'align="right"', 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)); // We add only for the current year if ($data[$j]->annee == date("Y")) { $totalnb += $data[$j]->nb; $totalMnt += $data[$j]->Mnttot; } $this->info_box_contents[$line][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3)); $line++; $j++; } if (count($data) == 0) { $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedInvoices")); } } $cachedir = DOL_DATA_ROOT . '/facture/temp'; $filename = '/boxactivity-invoice2' . $fileid; $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); if ($refresh) { $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s," . MAIN_DB_PREFIX . "facture as f"; $sql .= " WHERE f.entity = " . $conf->entity; $sql .= " AND f.fk_soc = s.rowid"; $sql .= " AND paye=0"; $sql .= " GROUP BY f.fk_statut"; $sql .= " ORDER BY f.fk_statut DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $j = 0; while ($j < $num) { $data[$j] = $db->fetch_object($result); $j++; } if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } $db->free($result); } else { dol_print_error($db); } } else { $data = dol_readcachefile($cachedir, $filename); } $cumuldata = array_merge($cumuldata, $data); if (!empty($data)) { $j = 0; while ($line < count($cumuldata)) { $billurl = "viewstatut=" . $data[$j]->fk_statut . "&paye=0"; $this->info_box_contents[$line][0] = array('td' => 'align="left" width="16"', 'tooltip' => $langs->trans('Bills') . ' ' . $facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&leftmenu=customers_bills", 'logo' => 'bill'); $this->info_box_contents[$line][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills") . " " . $facturestatic->LibStatut(0, $data[$j]->fk_statut, 0)); $this->info_box_contents[$line][2] = array('td' => 'align="right"', 'text' => $data[$j]->nb, 'tooltip' => $langs->trans('Bills') . ' ' . $facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&leftmenu=customers_bills"); $totalnb += $data[$j]->nb; $this->info_box_contents[$line][3] = array('td' => 'align="right"', 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)); $totalMnt += $objp->Mnttot; $this->info_box_contents[$line][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(0, $data[$j]->fk_statut, 3)); $line++; $j++; } if ($num == 0) { $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedInvoices")); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } // list the summary of the orders if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; $commandestatic = new Commande($db); $cachedir = DOL_DATA_ROOT . '/commande/temp'; $filename = '/boxactivity-order' . $fileid; $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); $data = array(); if ($refresh) { $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb"; $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "commande as c"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= ")"; $sql .= " WHERE c.entity = " . $conf->entity; $sql .= " AND c.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } $sql .= " AND c.date_commande >= '" . $db->idate($tmpdate) . "'"; $sql .= " AND c.facture=0"; $sql .= " GROUP BY c.fk_statut"; $sql .= " ORDER BY c.fk_statut DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $j = 0; while ($j < $num) { $data[$j] = $db->fetch_object($result); $j++; } if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } $db->free($result); } else { dol_print_error($db); } } else { $data = dol_readcachefile($cachedir, $filename); } $cumuldata = array_merge($cumuldata, $data); if (!empty($data)) { $j = 0; while ($line < count($cumuldata)) { $this->info_box_contents[$line][0] = array('td' => 'align="left" width="16"', 'url' => DOL_URL_ROOT . "/commande/list.php?mainmenu=commercial&leftmenu=orders&viewstatut=" . $data[$j]->fk_statut, 'tooltip' => $langs->trans("Orders") . " " . $commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), 'logo' => 'object_order'); $this->info_box_contents[$line][1] = array('td' => 'align="left"', 'text' => $langs->trans("Orders") . " " . $commandestatic->LibStatut($data[$j]->fk_statut, 0, 0)); $this->info_box_contents[$line][2] = array('td' => 'align="right"', 'text' => $data[$j]->nb, 'tooltip' => $langs->trans("Orders") . " " . $commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), 'url' => DOL_URL_ROOT . "/commande/list.php?mainmenu=commercial&leftmenu=orders&viewstatut=" . $data[$j]->fk_statut); $totalnb += $data[$j]->nb; $this->info_box_contents[$line][3] = array('td' => 'align="right"', 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)); $totalMnt += $data[$j]->Mnttot; $this->info_box_contents[$line][4] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($data[$j]->fk_statut, 0, 3)); $line++; $j++; } } } // list the summary of the propals if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; $propalstatic = new Propal($db); $cachedir = DOL_DATA_ROOT . '/propale/temp'; $filename = '/boxactivity-propal' . $fileid; $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); $data = array(); if ($refresh) { $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "propal as p"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= ")"; $sql .= " WHERE p.entity = " . $conf->entity; $sql .= " AND p.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } $sql .= " AND p.datep >= '" . $db->idate($tmpdate) . "'"; $sql .= " AND p.date_cloture IS NULL"; // just unclosed $sql .= " GROUP BY p.fk_statut"; $sql .= " ORDER BY p.fk_statut DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $j = 0; while ($j < $num) { $data[$j] = $db->fetch_object($result); $j++; } if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } $db->free($result); } else { dol_print_error($db); } } else { $data = dol_readcachefile($cachedir, $filename); } $cumuldata = array_merge($cumuldata, $data); if (!empty($data)) { $j = 0; while ($line < count($cumuldata)) { $this->info_box_contents[$line][0] = array('td' => 'align="left" width="16"', 'url' => DOL_URL_ROOT . "/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=" . $data[$j]->fk_statut, 'tooltip' => $langs->trans("Proposals") . " " . $propalstatic->LibStatut($data[$j]->fk_statut, 0), 'logo' => 'object_propal'); $this->info_box_contents[$line][1] = array('td' => 'align="left"', 'text' => $langs->trans("Proposals") . " " . $propalstatic->LibStatut($data[$j]->fk_statut, 0)); $this->info_box_contents[$line][2] = array('td' => 'align="right"', 'text' => $data[$j]->nb, 'tooltip' => $langs->trans("Proposals") . " " . $propalstatic->LibStatut($data[$j]->fk_statut, 0), 'url' => DOL_URL_ROOT . "/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=" . $data[$j]->fk_statut); $totalnb += $data[$j]->nb; $this->info_box_contents[$line][3] = array('td' => 'align="right"', 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)); $totalMnt += $data[$j]->Mnttot; $this->info_box_contents[$line][4] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($data[$j]->fk_statut, 3)); $line++; $j++; } } } // Add the sum in the bottom of the boxes $this->info_box_contents[$line][0] = array('tr' => 'class="liste_total"'); $this->info_box_contents[$line][1] = array('td' => 'align="left" class="liste_total" ', 'text' => $langs->trans("Total") . " " . $textHead); $this->info_box_contents[$line][2] = array('td' => 'align="right" class="liste_total" ', 'text' => $totalnb); $this->info_box_contents[$line][3] = array('td' => 'align="right" class="liste_total" ', 'text' => ''); $this->info_box_contents[$line][4] = array('td' => 'align="right" class="liste_total" ', 'text' => ""); }
*/ require "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT . "/comm/propal/class/propal.class.php"; require_once DOL_DOCUMENT_ROOT . "/core/lib/propal.lib.php"; $langs->load('propal'); $langs->load('compta'); $langs->load('bills'); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); // Security check if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'propale', $id, 'propal'); $object = new Propal($db); /******************************************************************************/ /* Actions */ /******************************************************************************/ if ($action == 'setnote_public' && $user->rights->propale->creer) { $object->fetch($id); $result = $object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); if ($result < 0) { dol_print_error($db, $object->error); } } else { if ($action == 'setnote' && $user->rights->propale->creer) { $object->fetch($id); $result = $object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); if ($result < 0) { dol_print_error($db, $object->error);
/** * Charge les donnees en memoire pour affichage ulterieur * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $conf, $user, $langs, $db; $totalMnt = 0; $totalnb = 0; $i = 0; include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; $nbofyears = 2; if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) { $nbofyears = $conf->global->MAIN_BOX_ACTIVITY_DURATION; } $textHead = $langs->trans("Activity") . ' (' . $nbofyears . ' ' . $langs->trans("DurationYears") . ')'; $this->info_box_head = array('text' => $textHead, 'limit' => dol_strlen($textHead)); // compute the year limit to show $tmpdate = dol_time_plus_duree(dol_now(), -1 * $nbofyears, "y"); // list the summary of the bills if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; $facturestatic = new Facture($db); $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s," . MAIN_DB_PREFIX . "facture as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= ")"; $sql .= " WHERE f.entity = " . $conf->entity; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } $sql .= " AND f.fk_soc = s.rowid"; $sql .= " AND f.datef >= '" . $db->idate($tmpdate) . "' AND paye=1"; $sql .= " GROUP BY f.fk_statut"; $sql .= " ORDER BY f.fk_statut DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); while ($i < $num) { $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'bill'); $objp = $db->fetch_object($result); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills") . " " . $facturestatic->LibStatut(1, $objp->fk_statut, 0) . " " . $objp->annee); $billurl = "viewstatut=2&paye=1&year=" . $objp->annee; $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&leftmenu=customers_bills"); $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => price($objp->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)); // We add only for the current year if ($objp->annee == date("Y")) { $totalnb += $objp->nb; $totalMnt += $objp->Mnttot; } $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(1, $objp->fk_statut, 3)); $i++; } if ($num == 0) { $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedInvoices")); } $db->free($result); } else { dol_print_error($db); } $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s," . MAIN_DB_PREFIX . "facture as f"; $sql .= " WHERE f.entity = " . $conf->entity; $sql .= " AND f.fk_soc = s.rowid"; $sql .= " AND paye=0"; $sql .= " GROUP BY f.fk_statut"; $sql .= " ORDER BY f.fk_statut DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result) + $i; $now = dol_now(); while ($i < $num) { $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'bill'); $objp = $db->fetch_object($result); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills") . " " . $facturestatic->LibStatut(0, $objp->fk_statut, 0)); $billurl = "viewstatut=" . $objp->fk_statut . "&paye=0"; $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&leftmenu=customers_bills"); $totalnb += $objp->nb; $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => price($objp->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)); $totalMnt += $objp->Mnttot; $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(0, $objp->fk_statut, 3)); $i++; } if ($num == 0) { $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedInvoices")); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } // list the summary of the orders if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; $commandestatic = new Commande($db); $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb"; $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "commande as c"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= ")"; $sql .= " WHERE c.entity = " . $conf->entity; $sql .= " AND c.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } $sql .= " AND c.date_commande >= '" . $db->idate($tmpdate) . "'"; $sql .= " AND c.facture=0"; $sql .= " GROUP BY c.fk_statut"; $sql .= " ORDER BY c.fk_statut DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result) + $i; while ($i < $num) { $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'object_order'); $objp = $db->fetch_object($result); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Orders") . " " . $commandestatic->LibStatut($objp->fk_statut, 0, 0)); $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/commande/liste.php?mainmenu=commercial&leftmenu=orders&viewstatut=" . $objp->fk_statut); $totalnb += $objp->nb; $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => price($objp->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)); $totalMnt += $objp->Mnttot; $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut, 0, 3)); $i++; } } else { dol_print_error($db); } } // list the summary of the propals if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; $propalstatic = new Propal($db); $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "propal as p"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= ")"; $sql .= " WHERE p.entity = " . $conf->entity; $sql .= " AND p.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } $sql .= " AND p.datep >= '" . $db->idate($tmpdate) . "'"; $sql .= " AND p.date_cloture IS NULL"; // just unclosed $sql .= " GROUP BY p.fk_statut"; $sql .= " ORDER BY p.fk_statut DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result) + $i; while ($i < $num) { $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'object_propal'); $objp = $db->fetch_object($result); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Proposals") . " " . $propalstatic->LibStatut($objp->fk_statut, 0)); $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=" . $objp->fk_statut); $totalnb += $objp->nb; $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => price($objp->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)); $totalMnt += $objp->Mnttot; $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($objp->fk_statut, 3)); $i++; } } else { dol_print_error($db); } } // Add the sum in the bottom of the boxes $this->info_box_contents[$i][1] = array('td' => 'align="left" ', 'text' => $langs->trans("Total") . " " . $textHead); $this->info_box_contents[$i][2] = array('td' => 'align="right" ', 'text' => price($totalnb, 1, $langs, 0, 0, -1, $conf->currency)); $this->info_box_contents[$i][3] = array('td' => 'align="right" ', 'text' => price($totalMnt, 1, $langs, 0, 0, -1, $conf->currency)); $this->info_box_contents[$i][4] = array('td' => 'align="right" ', 'text' => ""); $this->info_box_contents[$i][5] = array('td' => 'align="right"', 'text' => ""); }
/* *************************************************************************** */ if ($id > 0 || !empty($ref)) { $object = new Commande($db); if ($object->fetch($id, $ref) > 0) { $soc = new Societe($db); $soc->fetch($object->socid); $head = commande_prepare_head($object); dol_fiche_head($head, 'preview', $langs->trans("CustomerOrder"), 0, 'order'); print '<table class="border" width="100%">'; // Ref print '<tr><td width="18%">' . $langs->trans("Ref") . "</td>"; print '<td colspan="2">' . $object->ref . '</td>'; print '<td width="50%">' . $langs->trans("Source") . ' : ' . $object->getLabelSource(); if ($object->source == 0) { // Propale $propal = new Propal($db); $propal->fetch($object->propale_id); print ' -> <a href="' . DOL_URL_ROOT . '/comm/propal.php?id=' . $propal->id . '">' . $propal->ref . '</a>'; } print "</td></tr>"; // Ref cde client print '<tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td nowrap>'; print $langs->trans('RefCustomer') . '</td><td align="left">'; print '</td>'; print '</tr></table>'; print '</td>'; print '<td colspan="2">'; print $object->ref_client; print '</td>'; $nbrow = 6;
} else { print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans("NotEnoughPermissions") . '">' . $langs->trans("Delete") . '</a></div>'; } } } print "\n</div>\n"; /* * All the "Add to" areas */ if ($object->id && ($action == '' || $action == 'view') && $object->status) { //Variable used to check if any text is going to be printed $html = ''; //print '<div class="fichecenter"><div class="fichehalfleft">'; // Propals if (!empty($conf->propal->enabled) && $user->rights->propale->creer) { $propal = new Propal($db); $langs->load("propal"); $var = true; $otherprop = $propal->liste_array(2, 1, 0); if (is_array($otherprop) && count($otherprop)) { $var = !$var; $html .= '<tr><td style="width: 200px;">'; $html .= $langs->trans("AddToDraftProposals") . '</td><td colspan="2">'; $html .= $form->selectarray("propalid", $otherprop, 0, 1); $html .= '</td></tr>'; } else { $html .= '<tr><td style="width: 200px;">'; $html .= $langs->trans("AddToDraftProposals") . '</td><td colspan="2">'; $html .= $langs->trans("NoDraftProposals"); $html .= '</td></tr>'; }
/** * testVerifyNumRef * * @return void */ public function testVerifyNumRef() { global $conf,$user,$langs,$db; $conf=$this->savconf; $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; $localobject=new Propal($this->savdb); $result=$localobject->ref='refthatdoesnotexists'; $result=$localobject->VerifyNumRef(); print __METHOD__." result=".$result."\n"; $this->assertEquals($result, 0); return $result; }
/** * Charge les donnees en memoire pour affichage ulterieur * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $conf, $user, $langs, $db; $totalMnt = 0; $totalnb = 0; include_once DOL_DOCUMENT_ROOT . "/compta/facture/class/facture.class.php"; include_once DOL_DOCUMENT_ROOT . "/comm/propal/class/propal.class.php"; include_once DOL_DOCUMENT_ROOT . "/commande/class/commande.class.php"; $facturestatic = new Facture($db); $propalstatic = new Propal($db); $commandestatic = new Commande($db); $textHead = $langs->trans("Activity") . " " . date("Y"); $this->info_box_head = array('text' => $textHead, 'limit' => dol_strlen($textHead)); // list the summary of the bills if ($conf->facture->enabled && $user->rights->facture->lire) { $sql = "SELECT f.paye, f.fk_statut, sum(f.total_ttc) as Mnttot, count(*) as nb"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s," . MAIN_DB_PREFIX . "facture as f"; $sql .= " WHERE f.entity = " . $conf->entity; $sql .= " AND f.fk_soc = s.rowid"; $sql .= " AND (DATE_FORMAT(f.datef,'%Y') = " . date("Y") . " or paye=0)"; $sql .= " GROUP BY f.paye, f.fk_statut "; $sql .= " ORDER BY f.fk_statut DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $now = dol_now(); $i = 0; while ($i < $num) { $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'bill'); $objp = $db->fetch_object($result); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills") . " " . $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 0)); if ($objp->fk_statut == 0) { // draft $billurl = "viewstatut=0&paye=0"; } elseif ($objp->fk_statut == 1) { // unpaid $billurl = "viewstatut=1&paye=0"; } else { // paid for current year $billurl = "viewstatut=2&paye=1"; } $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&leftmenu=customers_bills"); $totalnb += $objp->nb; $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '), 40) . " " . getCurrencySymbol($conf->currency)); $totalMnt += $objp->Mnttot; $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3)); $i++; } if ($num == 0) { $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedInvoices")); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } // list the summary of the orders if ($conf->commande->enabled && $user->rights->commande->lire) { $sql = "SELECT c.fk_statut,c.facture, sum(c.total_ttc) as Mnttot, count(*) as nb"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "commande as c"; $sql .= " WHERE c.entity = " . $conf->entity; $sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.facture=0"; $sql .= " GROUP BY c.fk_statut"; $sql .= " ORDER BY c.fk_statut DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result) + $i; while ($i < $num) { $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'object_order'); $objp = $db->fetch_object($result); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Orders") . " " . $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 0)); $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/commande/liste.php?mainmenu=commercial&leftmenu=orders&viewstatut=" . $objp->fk_statut); $totalnb += $objp->nb; $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '), 40) . " " . getCurrencySymbol($conf->currency)); $totalMnt += $objp->Mnttot; $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3)); $i++; } } } // list the summary of the propals if ($conf->propal->enabled && $user->rights->propal->lire) { $sql = "SELECT p.fk_statut, sum(p.total) as Mnttot, count(*) as nb"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "propal as p"; $sql .= " WHERE p.entity = " . $conf->entity; $sql .= " AND p.fk_soc = s.rowid"; $sql .= " AND DATE_FORMAT(p.datep,'%Y') = " . date("Y"); $sql .= " AND p.date_cloture IS NULL "; // just unclosed $sql .= " GROUP BY p.fk_statut"; $sql .= " ORDER BY p.fk_statut DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result) + $i; while ($i < $num) { $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'object_propal'); $objp = $db->fetch_object($result); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Proposals") . " " . $propalstatic->LibStatut($objp->fk_statut, 0)); $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=" . $objp->fk_statut); $totalnb += $objp->nb; $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '), 40) . " " . getCurrencySymbol($conf->currency)); $totalMnt += $objp->Mnttot; $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($objp->fk_statut, 3)); $i++; } } } // Add the sum in the bottom of the boxes $this->info_box_contents[$i][1] = array('td' => 'align="left" ', 'text' => $langs->trans("Total") . " " . $textHead); $this->info_box_contents[$i][2] = array('td' => 'align="right" ', 'text' => number_format($totalnb, 0, ',', ' ')); $this->info_box_contents[$i][3] = array('td' => 'align="right" ', 'text' => number_format($totalMnt, 0, ',', ' ') . " " . getCurrencySymbol($conf->currency)); $this->info_box_contents[$i][4] = array('td' => 'align="right" ', 'text' => ""); $this->info_box_contents[$i][5] = array('td' => 'align="right"', 'text' => ""); }
/** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $user, $langs, $db, $conf; $this->max = $max; include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $propalstatic = new Propal($db); $societestatic = new Societe($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLast" . ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified") . "Propals", $max)); if ($user->rights->propale->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo,"; $sql .= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; $sql .= ", " . MAIN_DB_PREFIX . "propal as p"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.entity = " . $conf->entity; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) { $sql .= " ORDER BY p.datep DESC, p.ref DESC "; } else { $sql .= " ORDER BY p.tms DESC, p.ref DESC "; } $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $now = dol_now(); $line = 0; while ($line < $num) { $objp = $db->fetch_object($result); $date = $db->jdate($objp->dp); $datec = $db->jdate($objp->datec); $datem = $db->jdate($objp->tms); $dateterm = $db->jdate($objp->fin_validite); $dateclose = $db->jdate($objp->date_cloture); $propalstatic->id = $objp->rowid; $propalstatic->ref = $objp->ref; $propalstatic->total_ht = $objp->total_ht; $propalstatic->total_tva = $objp->total_tva; $propalstatic->total_ttc = $objp->total_ttc; $societestatic->id = $objp->socid; $societestatic->name = $objp->name; $societestatic->code_client = $objp->code_client; $societestatic->logo = $objp->logo; $late = ''; if ($objp->fk_statut == 1 && $dateterm < $now - $conf->propal->cloture->warning_delay) { $late = img_warning($langs->trans("Late")); } $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $propalstatic->getNomUrl(1), 'text2' => $late, 'asis' => 1); $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $societestatic->getNomUrl(1, '', 40), 'asis' => 1); $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency)); $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => dol_print_date($date, 'day')); $this->info_box_contents[$line][] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($objp->fk_statut, 3)); $line++; } if ($num == 0) { $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedProposals")); } $db->free($result); } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }
print "\n</div><br>\n"; /* * All the "Add to" areas */ if ($product->id && $action == '' && $product->status) { print '<table width="100%" class="noborder">'; // Propals if($conf->propal->enabled && $user->rights->propale->creer) { $propal = new Propal($db); $langs->load("propal"); print '<tr class="liste_titre"><td width="50%" class="liste_titre">'; print $langs->trans("AddToMyProposals") . '</td>'; if ($user->rights->societe->client->voir) { print '<td width="50%" class="liste_titre">'; print $langs->trans("AddToOtherProposals").'</td>'; } else { print '<td width="50%" class="liste_titre"> </td>'; }
print '<td colspan="3">' . $soc->getNomUrl(1) . '</td>'; print "</tr>"; // Linked documents if ($typeobject == 'commande' && $object->{$typeobject}->id && $conf->commande->enabled) { print '<tr><td>'; $objectsrc = new Commande($db); $objectsrc->fetch($object->{$typeobject}->id); print $langs->trans("RefOrder") . '</td>'; print '<td colspan="3">'; print $objectsrc->getNomUrl(1, 'commande'); print "</td>\n"; print '</tr>'; } if ($typeobject == 'propal' && $object->{$typeobject}->id && $conf->propal->enabled) { print '<tr><td>'; $objectsrc = new Propal($db); $objectsrc->fetch($object->{$typeobject}->id); print $langs->trans("RefProposal") . '</td>'; print '<td colspan="3">'; print $objectsrc->getNomUrl(1, 'expedition'); print "</td>\n"; print '</tr>'; } // Ref customer print '<tr><td>' . $langs->trans("RefCustomer") . '</td>'; print '<td colspan="3">' . $object->ref_customer . "</a></td>\n"; print '</tr>'; // Date creation print '<tr><td>' . $langs->trans("DateCreation") . '</td>'; print '<td colspan="3">' . dol_print_date($object->date_creation, "daytext") . "</td>\n"; print '</tr>';
/** * Create order * Note that this->ref can be set or empty. If empty, we will use "(PROV)" * * @param User $user Objet user that make creation * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ function create($user, $notrigger = 0) { global $conf, $langs, $mysoc, $hookmanager; $error = 0; // Clean parameters $this->brouillon = 1; // set command as draft dol_syslog(get_class($this) . "::create user="******"::create " . $this->error, LOG_WARNING); $this->db->rollback(); return -1; } } $soc = new Societe($this->db); $result = $soc->fetch($this->socid); if ($result < 0) { $this->error = "Failed to fetch company"; dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR); return -2; } if (!empty($conf->global->COMMANDE_REQUIRE_SOURCE) && $this->source < 0) { $this->error = $langs->trans("ErrorFieldRequired", $langs->trans("Source")); dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR); return -1; } // $date_commande is deprecated $date = $this->date_commande ? $this->date_commande : $this->date; $now = dol_now(); $this->db->begin(); $sql = "INSERT INTO " . MAIN_DB_PREFIX . "commande ("; $sql .= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_ext, ref_client, ref_int"; $sql .= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address"; $sql .= ", fk_shipping_method"; $sql .= ", fk_warehouse"; $sql .= ", remise_absolue, remise_percent"; $sql .= ", fk_incoterms, location_incoterms"; $sql .= ", entity"; $sql .= ")"; $sql .= " VALUES ('(PROV)'," . $this->socid . ", '" . $this->db->idate($now) . "', " . $user->id; $sql .= ", " . ($this->fk_project > 0 ? $this->fk_project : "null"); $sql .= ", '" . $this->db->idate($date) . "'"; $sql .= ", " . ($this->source >= 0 && $this->source != '' ? $this->db->escape($this->source) : 'null'); $sql .= ", '" . $this->db->escape($this->note_private) . "'"; $sql .= ", '" . $this->db->escape($this->note_public) . "'"; $sql .= ", " . ($this->ref_ext ? "'" . $this->db->escape($this->ref_ext) . "'" : "null"); $sql .= ", " . ($this->ref_client ? "'" . $this->db->escape($this->ref_client) . "'" : "null"); $sql .= ", " . ($this->ref_int ? "'" . $this->db->escape($this->ref_int) . "'" : "null"); $sql .= ", '" . $this->db->escape($this->modelpdf) . "'"; $sql .= ", " . ($this->cond_reglement_id > 0 ? "'" . $this->cond_reglement_id . "'" : "null"); $sql .= ", " . ($this->mode_reglement_id > 0 ? "'" . $this->mode_reglement_id . "'" : "null"); $sql .= ", " . ($this->fk_account > 0 ? $this->fk_account : 'NULL'); $sql .= ", " . ($this->availability_id > 0 ? "'" . $this->availability_id . "'" : "null"); $sql .= ", " . ($this->demand_reason_id > 0 ? "'" . $this->demand_reason_id . "'" : "null"); $sql .= ", " . ($this->date_livraison ? "'" . $this->db->idate($this->date_livraison) . "'" : "null"); $sql .= ", " . ($this->fk_delivery_address > 0 ? $this->fk_delivery_address : 'NULL'); $sql .= ", " . ($this->shipping_method_id > 0 ? $this->shipping_method_id : 'NULL'); $sql .= ", " . ($this->warehouse_id > 0 ? $this->warehouse_id : 'NULL'); $sql .= ", " . ($this->remise_absolue > 0 ? $this->db->escape($this->remise_absolue) : 'NULL'); $sql .= ", " . ($this->remise_percent > 0 ? $this->db->escape($this->remise_percent) : 0); $sql .= ", " . (int) $this->fk_incoterms; $sql .= ", '" . $this->db->escape($this->location_incoterms) . "'"; $sql .= ", " . $conf->entity; $sql .= ")"; dol_syslog(get_class($this) . "::create", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . 'commande'); if ($this->id) { $fk_parent_line = 0; $num = count($this->lines); /* * Insert products details into db */ for ($i = 0; $i < $num; $i++) { // Reset fk_parent_line for no child products and special product if ($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line) || $this->lines[$i]->product_type == 9) { $fk_parent_line = 0; } $result = $this->addline($this->lines[$i]->desc, $this->lines[$i]->subprice, $this->lines[$i]->qty, $this->lines[$i]->tva_tx, $this->lines[$i]->localtax1_tx, $this->lines[$i]->localtax2_tx, $this->lines[$i]->fk_product, $this->lines[$i]->remise_percent, $this->lines[$i]->info_bits, $this->lines[$i]->fk_remise_except, 'HT', 0, $this->lines[$i]->date_start, $this->lines[$i]->date_end, $this->lines[$i]->product_type, $this->lines[$i]->rang, $this->lines[$i]->special_code, $fk_parent_line, $this->lines[$i]->fk_fournprice, $this->lines[$i]->pa_ht, $this->lines[$i]->label, $this->lines[$i]->array_options, $this->lines[$i]->fk_unit, $this->element, $this->lines[$i]->id); if ($result < 0) { if ($result != self::STOCK_NOT_ENOUGH_FOR_ORDER) { $this->error = $this->db->lasterror(); dol_print_error($this->db); } $this->db->rollback(); return -1; } // Defined the new fk_parent_line if ($result > 0 && $this->lines[$i]->product_type == 9) { $fk_parent_line = $result; } } // update ref $initialref = '(PROV' . $this->id . ')'; if (!empty($this->ref)) { $initialref = $this->ref; } $sql = 'UPDATE ' . MAIN_DB_PREFIX . "commande SET ref='" . $this->db->escape($initialref) . "' WHERE rowid=" . $this->id; if ($this->db->query($sql)) { if ($this->id) { $this->ref = $initialref; // Add object linked if (is_array($this->linked_objects) && !empty($this->linked_objects)) { foreach ($this->linked_objects as $origin => $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); if (!$ret) { dol_print_error($this->db); $error++; } // TODO mutualiser if ($origin == 'propal' && $origin_id) { // On recupere les differents contact interne et externe $prop = new Propal($this->db); $prop->fetch($origin_id); // We get ids of sales representatives of proposal $this->userid = $prop->getIdcontact('internal', 'SALESREPFOLL'); if ($this->userid) { //On passe le commercial suivi propale en commercial suivi commande $this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal'); } // We get ids of customer follower of proposal $this->contactid = $prop->getIdcontact('external', 'CUSTOMER'); if ($this->contactid) { //On passe le contact client suivi propale en contact client suivi commande $this->add_contact($this->contactid[0], 'CUSTOMER', 'external'); } } } } } if (!$error) { //$action='create'; // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! /*$hookmanager->initHooks(array('orderdao')); $parameters=array('socid'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used {*/ $result = $this->insertExtraFields(); if ($result < 0) { $error++; } /* } } else if ($reshook < 0) $error++;*/ } if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('ORDER_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } if (!$error) { $this->db->commit(); return $this->id; } else { $this->db->rollback(); return -1 * $error; } } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } } } else { dol_print_error($this->db); $this->db->rollback(); return -1; } }
require_once DOL_DOCUMENT_ROOT . "/core/class/html.formother.class.php"; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; $langs->load("facture"); $langs->load("orders"); $langs->load("sendings"); $langs->load("companies"); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $lineid = GETPOST('lineid', 'int'); $action = GETPOST('action', 'alpha'); // Security check if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'propale', $id, 'propal'); $object = new Propal($db); /* * Ajout d'un nouveau contact */ if ($action == 'addcontact' && $user->rights->propale->creer) { $result = $object->fetch($id); if ($result > 0 && $id > 0) { $contactid = GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) { Header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); exit; } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors");
$objectsrc->fetch_thirdparty(); $projectid = !empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''; $ref_client = !empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''; $ref_int = !empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''; $soc = $objectsrc->thirdparty; $cond_reglement_id = !empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 1); $mode_reglement_id = !empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0); $remise_percent = !empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0); $remise_absolue = !empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0); $dateinvoice = empty($dateinvoice) ? empty($conf->global->MAIN_AUTOFILL_DATE) ? -1 : '' : $dateinvoice; // Replicate extrafields $objectsrc->fetch_optionals($originid); $object->array_options = $objectsrc->array_options; } } $object = new Propal($db); print '<form name="addprop" action="' . $_SERVER["PHP_SELF"] . '" method="POST">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="action" value="add">'; if ($origin != 'project' && $originid) { print '<input type="hidden" name="origin" value="' . $origin . '">'; print '<input type="hidden" name="originid" value="' . $originid . '">'; } dol_fiche_head(); print '<table class="border" width="100%">'; // Reference print '<tr><td width="25%" class="fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans("Draft") . '</td></tr>'; // Ref customer print '<tr><td>' . $langs->trans('RefCustomer') . '</td><td colspan="2">'; print '<input type="text" name="ref_client" value="' . GETPOST('ref_client') . '"></td>'; print '</tr>';
/* * View */ $now=gmmktime(); llxHeader(); $html = new Form($db); $htmlother = new FormOther($db); $formfile = new FormFile($db); $societestatic=new Societe($db); $propalstatic=new Propal($db); $now=gmmktime(); $id = $_GET["id"]; $ref= $_GET["ref"]; if ($id > 0 || ! empty($ref)) { if ($mesg) print "$mesg<br>"; $product_static=new Product($db); $object->fetch($_GET["id"],$_GET["ref"]); $societe = new Societe($db); $societe->fetch($object->socid);
} if ($absolute_creditnote) { print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->monnaie)).'. '; } if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; print '</td></tr>'; // Date print '<tr><td>'.$langs->trans('Date').'</td>'; print '<td colspan="2">'.dol_print_date($commande->date,'daytext').'</td>'; print '<td width="50%">'.$langs->trans('Source').' : '.$commande->getLabelSource(); if ($commande->source == 0 && $conf->propal->enabled && $commande->propale_id) { // Si source = propal $propal = new Propal($db); $propal->fetch($commande->propale_id); print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$propal->id.'">'.$propal->ref.'</a>'; } print '</td>'; print '</tr>'; // Delivery date planned print '<tr><td height="10">'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans('DateDeliveryPlanned'); print '</td>'; if ($_GET['action'] != 'editdate_livraison') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="2">';
$MAXLIST = 4; $tableaushown = 1; // Lien recap print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>' . $langs->trans("Summary") . '</td>'; print '<td align="right"><a href="' . DOL_URL_ROOT . '/compta/recap-compta.php?socid=' . $objsoc->id . '">' . $langs->trans("ShowCustomerPreview") . '</a></td></tr></table></td>'; print '</tr>'; print '</table>'; print '<br>'; $now = dol_now(); /* * Last proposals */ if ($conf->propal->enabled && $user->rights->propale->lire) { $propal_static = new Propal($db); $proposals = $propal_static->liste_array(0, 0, 0, $objsoc->id, $MAXLIST); //var_dump($proposals); print '<table class="noborder" width="100%">'; $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; $sql .= " p.datep as dp, p.fin_validite as datelimite"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "propal as p, " . MAIN_DB_PREFIX . "c_propalst as c"; $sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; $sql .= " AND s.rowid = " . $objsoc->id; $sql .= " ORDER BY p.datep DESC"; $resql = $db->query($sql); if ($resql) { $var = true; $num = $db->num_rows($resql); if ($num > 0) { print '<tr class="liste_titre">';
accessforbidden(); } $langs->load("propal"); // Security check $socid = ''; if ($_GET["socid"]) { $socid = $_GET["socid"]; } if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } /* * View */ $propalstatic = new Propal($db); $companystatic = new Societe($db); $form = new Form($db); $formfile = new FormFile($db); $help_url = "EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo Presupuestos"; llxHeader("", $langs->trans("ProspectionArea"), $help_url); print_fiche_titre($langs->trans("ProspectionArea")); print '<table width="100%" class="notopnoleftnoright">'; print '<tr><td valign="top" width="30%" class="notopnoleft">'; /* * Search form */ $var = false; print '<table class="noborder" width="100%">'; print '<form method="post" action="' . DOL_URL_ROOT . '/comm/propal.php">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print "</tr>"; // Document origine if ($typeobject == 'commande' && $expedition->origin_id && $conf->commande->enabled) { print '<tr><td>'.$langs->trans("RefOrder").'</td>'; $order=new Commande($db); $order->fetch($expedition->origin_id); print '<td colspan="3">'; print $order->getNomUrl(1,'commande'); print "</td>\n"; print '</tr>'; } if ($typeobject == 'propal' && $expedition->origin_id && $conf->propal->enabled) { $propal=new Propal($db); $propal->fetch($expedition->origin_id); print '<tr><td>'.$langs->trans("RefProposal").'</td>'; print '<td colspan="3">'; print $propal->getNomUrl(1,'expedition'); print "</td>\n"; print '</tr>'; } // Ref client print '<tr><td>'.$langs->trans("RefCustomer").'</td>'; print '<td colspan="3">'.$delivery->ref_customer."</a></td>\n"; print '</tr>'; // Date print '<tr><td>'.$langs->trans("DateCreation").'</td>';
/* Affichage fiche */ /******************************************************************************/ llxHeader(); $html = new Form($db); $id = $_GET["id"]; $ref= $_GET["ref"]; if ($id > 0 || ! empty($ref)) { if ($mesg) print $mesg; $now=gmmktime(); $propal = new Propal($db); if ($propal->fetch($id, $ref)) { $societe = new Societe($db); if ( $societe->fetch($propal->socid) ) { $head = propal_prepare_head($propal); dol_fiche_head($head, 'note', $langs->trans('Proposal'), 0, 'propal'); print '<table class="border" width="100%">'; $linkback="<a href=\"".$_SERVER["PHP_SELF"]."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder\">".$langs->trans("BackToList")."</a>"; // Ref print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'; print $html->showrefnav($propal,'ref',$linkback,1,'ref','ref','');