/**
  *  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 $conf, $user, $langs, $db;
     $langs->load("boxes");
     $this->max = $max;
     include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
     $supplierorderstatic = new CommandeFournisseur($db);
     $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestSupplierOrders", $max));
     if ($user->rights->fournisseur->commande->lire) {
         $sql = "SELECT s.nom, s.rowid as socid,";
         $sql .= " c.ref, c.tms, c.rowid,";
         $sql .= " c.fk_statut";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
         $sql .= ", " . MAIN_DB_PREFIX . "commande_fournisseur as c";
         if (!$user->rights->societe->client->voir && !$user->societe_id) {
             $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
         }
         $sql .= " WHERE c.fk_soc = s.rowid";
         $sql .= " AND c.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 c.date_commande DESC, c.ref DESC ";
         $sql .= $db->plimit($max, 0);
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);
             $i = 0;
             while ($i < $num) {
                 $objp = $db->fetch_object($result);
                 $datem = $db->jdate($objp->tms);
                 $urlo = DOL_URL_ROOT . "/fourn/commande/fiche.php?id=" . $objp->rowid;
                 $urls = DOL_URL_ROOT . "/fourn/fiche.php?socid=" . $objp->socid;
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => $urlo);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->ref, 'url' => $urlo);
                 $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => $urls);
                 $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => $objp->nom, 'url' => $urls);
                 $this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => dol_print_date($datem, 'day'));
                 $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', 'text' => $supplierorderstatic->LibStatut($objp->fk_statut, 3));
                 $i++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoSupplierOrder"));
             }
             $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"));
     }
 }
Exemplo n.º 2
0
 /**
  *    Return combo list of differents status of a orders
  *
  *    @param	string	$selected   Preselected value
  *    @param	int		$short		Use short labels
  *    @param	string	$hmlname	Name of HTML select element
  *    @return	void
  */
 function selectSupplierOrderStatus($selected = '', $short = 0, $hmlname = 'order_status')
 {
     $tmpsupplierorder = new CommandeFournisseur($db);
     print '<select class="flat" name="' . $hmlname . '">';
     print '<option value="-1">&nbsp;</option>';
     $statustohow = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6,7', '9' => '9');
     // 7 is same label than 6. 8 does not exists (billed is another field)
     foreach ($statustohow as $key => $value) {
         print '<option value="' . $value . '"' . ($selected == $key || $selected == $value ? ' selected' : '') . '>';
         $tmpsupplierorder->statut = $key;
         print $tmpsupplierorder->getLibStatut($short);
         print '</option>';
     }
     print '</select>';
 }
Exemplo n.º 3
0
 /**
  *    Return combo list of differents status of a orders
  *
  *    @param	string	$selected   Preselected value
  *    @param	int		$short		Use short labels
  *    @param	string	$hmlname	Name of HTML select element
  *    @return	void
  */
 function selectSupplierOrderStatus($selected = '', $short = 0, $hmlname = 'order_status')
 {
     print '<select class="flat" name="' . $hmlname . '">';
     print '<option value="-1">&nbsp;</option>';
     $statustohow = array(0, 1, 2, 3, 4, 5, 6, 9);
     // 7 is same label than 6. 8 does not exist.
     foreach ($statustohow as $key) {
         print '<option value="' . $key . '"' . ($selected == $key ? ' selected="selected"' : '') . '>';
         print CommandeFournisseur::LibStatut($key, $short);
         print '</option>';
     }
     print '</select>';
 }
 /**
  *    Return combo list of differents status of a orders
  *
  *    @param	array	$selected   Preselected values
  *    @param	string	$selected   Preselected value
  *    @param	int		$short		Use short labels
  *    @param	string	$hmlname	Name of HTML select element
  *    @return	void
  */
 function selectSupplierOrderStatus($selected = array(), $short = 0, $hmlname = 'order_status')
 {
     /*print '<select class="flat" name="'.$hmlname.'">';
             print '<option value="-1">&nbsp;</option>';
             $statustohow=array(0,1,2,3,4,5,6,9);	// 7 is same label than 6. 8 does not exist.
     
             foreach($statustohow as $key)
             {
     			print '<option value="'.$key.'"'.($selected == $key?' selected="selected"':'').'>';
     			print CommandeFournisseur::LibStatut($key,$short);
     	        print '</option>';
     	        */
     $statustohow = array(0, 1, 2, 3, 4, 5, 6, 9);
     // 7 is same label than 6. 8 does not exist.
     foreach ($statustohow as $key) {
         $stat = CommandeFournisseur::LibStatut($key, $short);
         print '<input name="statuts[]" type="checkbox"  value="' . $key . '"' . ($selected[$key] == $key ? ' selected="selected"' : '') . '>&nbsp;' . $stat . ' - ';
         print $key;
     }
 }
Exemplo n.º 5
0
 */

llxHeader('',$langs->trans("OrderCard"),"CommandeFournisseur");

$html =	new Form($db);
$warehouse_static = new Entrepot($db);

$now=dol_now();

$id = $_GET['id'];
$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref))
{
	//if ($mesg) print $mesg.'<br>';

	$commande = new CommandeFournisseur($db);

	$result=$commande->fetch($_GET['id'],$_GET['ref']);
	if ($result >= 0)
	{
		$soc = new Societe($db);
		$soc->fetch($commande->socid);

		$author = new User($db);
		$author->fetch($commande->user_author_id);

		$head = ordersupplier_prepare_head($commande);

		$title=$langs->trans("SupplierOrder");
		dol_fiche_head($head, 'dispatch', $title, 0, 'order');
Exemplo n.º 6
0
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
// Security check
$socid = '';
if (!empty($user->societe_id)) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'fournisseur', $id, '', 'commande');
/*
 * View
 */
$form = new Form($db);
$now = dol_now();
if ($id > 0 || !empty($ref)) {
    $soc = new Societe($db);
    $commande = new CommandeFournisseur($db);
    $result = $commande->fetch($id, $ref);
    if ($result >= 0) {
        $soc->fetch($commande->socid);
        $author = new User($db);
        $author->fetch($commande->user_author_id);
        llxHeader('', $langs->trans("History"), "CommandeFournisseur");
        $head = ordersupplier_prepare_head($commande);
        $title = $langs->trans("SupplierOrder");
        dol_fiche_head($head, 'info', $title, 0, 'order');
        /*
         *   Commande
         */
        print '<table class="border" width="100%">';
        $linkback = '<a href="' . DOL_URL_ROOT . '/fourn/commande/list.php' . (!empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
        // Ref
Exemplo n.º 7
0
$origin = GETPOST('origin', 'alpha');
$originid = GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int');
// For backward compatibility
//PDF
$hidedetails = GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
$hidedesc = GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
$hideref = GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
$datelivraison = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), GETPOST('liv_sec', 'int'), GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int'));
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'fournisseur', $id, '', 'commande');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('ordersuppliercard', 'globalcard'));
$object = new CommandeFournisseur($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || !empty($ref)) {
    $ret = $object->fetch($id, $ref);
    if ($ret < 0) {
        dol_print_error($db, $object->error);
    }
    $ret = $object->fetch_thirdparty();
    if ($ret < 0) {
        dol_print_error($db, $object->error);
    }
} else {
    if (!empty($socid) && $socid > 0) {
Exemplo n.º 8
0
             print '<td class="nowrap">';
             print $productstatic->getNomUrl(1);
             print '</td>';
             print '<td align="center">';
             print dol_trunc(dol_htmlentities($objp->label), 30);
             print '</td>';
             print '<td align="right" class="nowrap">' . dol_print_date($objp->tms) . '</td>';
             print '</tr>';
         }
     }
     print '</table>';
 }
 /*
  * Last supplier orders
  */
 $orderstatic = new CommandeFournisseur($db);
 if ($user->rights->fournisseur->commande->lire) {
     // TODO move to DAO class
     // Check if there are supplier orders billable
     $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
     $sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
     $sql2 .= ' FROM ' . MAIN_DB_PREFIX . 'societe as s';
     $sql2 .= ', ' . MAIN_DB_PREFIX . 'commande_fournisseur as c';
     $sql2 .= ' WHERE c.fk_soc = s.rowid';
     $sql2 .= ' AND s.rowid = ' . $object->id;
     // Show orders with status validated, shipping started and delivered (well any order we can bill)
     $sql2 .= " AND c.fk_statut IN (5)";
     $sql2 .= " AND c.billed = 0";
     // Find order that are not already invoiced
     // just need to check received status because we have the billed status now
     //$sql2 .= " AND c.rowid NOT IN (SELECT fk_source FROM " . MAIN_DB_PREFIX . "element_element WHERE targettype='invoice_supplier')";
Exemplo n.º 9
0
// mode de reglement
if ($action == 'setmode' && $user->rights->fournisseur->commande->creer) {
    $object->fetch($id);
    $result = $object->mode_reglement($_POST['mode_reglement_id']);
}
// Set project
if ($action == 'classin') {
    $object->fetch($id);
    $object->setProject($projectid);
}
if ($action == 'setremisepercent' && $user->rights->fournisseur->commande->creer) {
    $object->fetch($id);
    $result = $object->set_remise($user, $_POST['remise_percent']);
}
if ($action == 'reopen' && $user->rights->fournisseur->commande->approuver) {
    $order = new CommandeFournisseur($db);
    $result = $order->fetch($id);
    if ($order->statut == 5 || $order->statut == 6 || $order->statut == 7 || $order->statut == 9) {
        if ($order->statut == 5) {
            $newstatus = 4;
        }
        // Received->Received partially
        if ($order->statut == 6) {
            $newstatus = 2;
        }
        // Canceled->Approved
        if ($order->statut == 7) {
            $newstatus = 3;
        }
        // Canceled->Process running
        if ($order->statut == 9) {
Exemplo n.º 10
0
 /*
  * List of products
  */
 if ($conf->product->enabled || $conf->service->enabled) {
     $langs->load("products");
     print '<table class="noborder" width="100%">';
     print '<tr class="liste_titre">';
     print '<td>' . $langs->trans("ProductsAndServices") . '</td><td align="right">';
     print '<a href="' . DOL_URL_ROOT . '/fourn/product/liste.php?fourn_id=' . $object->id . '">' . $langs->trans("All") . ' (' . $object->nbOfProductRefs() . ')';
     print '</a></td></tr></table>';
 }
 print '<br>';
 /*
  * Last orders
  */
 $orderstatic = new CommandeFournisseur($db);
 if ($user->rights->fournisseur->commande->lire) {
     // TODO move to DAO class
     $sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut";
     $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseur as p ";
     $sql .= " WHERE p.fk_soc =" . $object->id;
     $sql .= " ORDER BY p.date_commande DESC";
     $sql .= " " . $db->plimit($MAXLIST);
     $resql = $db->query($sql);
     if ($resql) {
         $i = 0;
         $num = $db->num_rows($resql);
         if ($num > 0) {
             print '<table class="noborder" width="100%">';
             print '<tr class="liste_titre">';
             print '<td colspan="3">';
 /**
  *	Load indicators for dashboard (this->nbtodo and this->nbtodolate)
  *
  *	@param          User	$user   Objet user
  *	@return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
  */
 function load_board($user)
 {
     global $conf, $langs;
     $clause = " WHERE";
     $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.fk_statut, c.date_livraison as delivery_date";
     $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseur as c";
     if (!$user->rights->societe->client->voir && !$user->societe_id) {
         $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON c.fk_soc = sc.fk_soc";
         $sql .= " WHERE sc.fk_user = "******" AND";
     }
     $sql .= $clause . " c.entity = " . $conf->entity;
     $sql .= " AND (c.fk_statut BETWEEN 1 AND 2)";
     if ($user->societe_id) {
         $sql .= " AND c.fk_soc = " . $user->societe_id;
     }
     $resql = $this->db->query($sql);
     if ($resql) {
         $commandestatic = new CommandeFournisseur($this->db);
         $response = new WorkboardResponse();
         $response->warning_delay = $conf->commande->fournisseur->warning_delay / 60 / 60 / 24;
         $response->label = $langs->trans("SuppliersOrdersToProcess");
         $response->url = DOL_URL_ROOT . '/fourn/commande/list.php?statut=1,2,3';
         $response->img = img_object($langs->trans("Orders"), "order");
         while ($obj = $this->db->fetch_object($resql)) {
             $response->nbtodo++;
             $commandestatic->date_livraison = $this->db->jdate($obj->delivery_date);
             $commandestatic->date_commande = $this->db->jdate($obj->date_commande);
             $commandestatic->statut = $obj->fk_statut;
             if ($commandestatic->hasDelay()) {
                 $response->nbtodolate++;
             }
         }
         return $response;
     } else {
         $this->error = $this->db->error();
         return -1;
     }
 }
Exemplo n.º 12
0
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$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 CommandeFournisseur($db);
if ($object->fetch($id, $ref) < 0) {
    dol_print_error($db);
    exit;
}
$upload_dir = $conf->fournisseur->dir_output . '/commande/' . dol_sanitizeFileName($object->ref);
$object->fetch_thirdparty();
/*
 * Actions
 */
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
 * View
 */
$form = new Form($db);
if ($object->id > 0) {
Exemplo n.º 13
0
    $search_status = '';
}
if ($search_status == '') {
    $search_status = -1;
}
/*
 *	View
 */
$title = $langs->trans("SuppliersOrders");
if ($socid > 0) {
    $fourn = new Fournisseur($db);
    $fourn->fetch($socid);
    $title .= ' (' . $fourn->name . ')';
}
llxHeader('', $title);
$commandestatic = new CommandeFournisseur($db);
$formfile = new FormFile($db);
$formorder = new FormOrder($db);
if ($sortorder == "") {
    $sortorder = "DESC";
}
if ($sortfield == "") {
    $sortfield = "cf.date_creation";
}
$offset = $conf->liste_limit * $page;
/*
 * Mode Liste
 */
$sql = "SELECT s.rowid as socid, s.nom as name, cf.date_commande as dc,";
$sql .= " cf.rowid,cf.ref, cf.ref_supplier, cf.fk_statut, cf.total_ttc, cf.fk_user_author,cf.date_livraison,";
$sql .= " u.login";
Exemplo n.º 14
0
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'societe', $socid, '');
/*
 * View
 */
$commandestatic = new CommandeFournisseur($db);
$facturestatic = new FactureFournisseur($db);
$companystatic = new Societe($db);
llxHeader("", $langs->trans("SuppliersArea"));
print_fiche_titre($langs->trans("SuppliersArea"));
//print '<table border="0" width="100%" class="notopnoleftnoright">';
//print '<tr><td valign="top" width="30%" class="notopnoleft">';
print '<div class="fichecenter"><div class="fichethirdleft">';
// Orders
$commande = new CommandeFournisseur($db);
$sql = "SELECT count(cf.rowid), cf.fk_statut";
$sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseur as cf,";
$sql .= " " . MAIN_DB_PREFIX . "societe as s";
if (!$user->rights->societe->client->voir && !$socid) {
    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON s.rowid = sc.fk_soc";
}
$sql .= " WHERE cf.fk_soc = s.rowid ";
if (!$user->rights->societe->client->voir && !$socid) {
    $sql .= " AND sc.fk_user = "******" AND cf.entity = " . $conf->entity;
$sql .= " GROUP BY cf.fk_statut";
$resql = $db->query($sql);
if ($resql) {
    $num = $db->num_rows($resql);
Exemplo n.º 15
0
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/fourn.lib.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');
$action = GETPOST('action', 'alpha');
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'fournisseur', $id, '', 'commande');
$object = new CommandeFournisseur($db);
/*
 * Ajout d'un nouveau contact
 */
if ($action == 'addcontact' && $user->rights->fournisseur->commande->creer) {
    $result = $object->fetch($id);
    if ($result > 0 && $id > 0) {
        $contactid = GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid');
        $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");
Exemplo n.º 16
0
 * View
 */
$form = new Form($db);
$formfile = new FormFile($db);
$companystatic = new Societe($db);
if (!empty($conf->propal->enabled)) {
    $propalstatic = new Propal($db);
}
if (!empty($conf->supplier_proposal->enabled)) {
    $supplierproposalstatic = new SupplierProposal($db);
}
if (!empty($conf->commande->enabled)) {
    $orderstatic = new Commande($db);
}
if (!empty($conf->fournisseur->enabled)) {
    $supplierorderstatic = new CommandeFournisseur($db);
}
llxHeader();
print load_fiche_titre($langs->trans("CommercialArea"), '', 'title_commercial.png');
print '<div class="fichecenter"><div class="fichethirdleft">';
// Search proposal
if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
    $listofsearchfields['search_proposal'] = array('text' => 'Proposal');
}
// Search customer order
if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
    $listofsearchfields['search_customer_order'] = array('text' => 'CustomerOrder');
}
// Search supplier order
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) {
    $listofsearchfields['search_supplier_order'] = array('text' => 'SupplierOrder');
Exemplo n.º 17
0
// Number of actions to do (late)
if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) {
    include_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
    $board = new ActionComm($db);
    $dashboardlines[] = $board->load_board($user);
}
// 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");
Exemplo n.º 18
0
// Security check
$orderid = isset($_GET["orderid"])?$_GET["orderid"]:'';
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'commande_fournisseur', $orderid,'');

$langs->load("suppliers");
$langs->load("orders");


/*
 * 	View
 */

llxHeader('',$langs->trans("SuppliersOrdersArea"));

$commandestatic = new CommandeFournisseur($db);
$userstatic=new User($db);
$formfile = new FormFile($db);

print_barre_liste($langs->trans("SuppliersOrdersArea"), $page, "index.php", "", $sortfield, $sortorder, '', $num);

print '<table class="notopnoleftnoright" width="100%">';
print '<tr valign="top"><td class="notopnoleft" width="30%">';


/*
 * Search form
 */
$var=false;
print '<table class="noborder" width="100%">';
print '<form method="post" action="liste.php">';
Exemplo n.º 19
0
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'commande_fournisseur', $id,'');

// Get parameters
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$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";


$commande = new CommandeFournisseur($db);
if ($commande->fetch($_GET['id'],$_GET['ref']) < 0)
{
	dol_print_error($db);
	exit;
}



/*
 * Actions
 */

// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
Exemplo n.º 20
0
	function ProductCommande($user, $fk_product)
	{
		include_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php");
		include_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");

		$commf = new CommandeFournisseur($this->db);

		$nbc = $this->nb_open_commande();

		dol_syslog("Fournisseur::ProductCommande : nbc = ".$nbc);

		if ($nbc == 0)
		{
			if ( $this->create_commande($user) == 0 )
			{
				$idc = $this->single_open_commande;
			}
		}
		elseif ($nbc == 1)
		{

			$idc = $this->single_open_commande;
		}

		if ($idc > 0)
		{
			$prod = new ProductFournisseur($this->db);
			$prod->fetch($fk_product);
			$prod->fetch_fourn_data($this->id);

			$commf->fetch($idc);
			$commf->addline("Toto",120,1,$prod->tva, $prod->id, 0, $prod->ref_fourn);
		}
	}
/**
 *  Create a document onto disk according to template model.
 *
 *  @param	    DoliDB		$db  			Database handler
 *  @param	    Object		$object			Object supplier order
 *  @param	    string		$modele			Force template to use ('' to not force)
 *  @param		Translate	$outputlangs	Object lang to use for traduction
 *  @param      int			$hidedetails    Hide details of lines
 *  @param      int			$hidedesc       Hide description
 *  @param      int			$hideref        Hide ref
 *  @return     int          				0 if KO, 1 if OK
 * @deprecated Use the new function generateDocument of CommandeFournisseur class
 */
function supplier_order_pdf_create(DoliDB $db, CommandeFournisseur $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
    return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
Exemplo n.º 22
0
 print '<td class="liste_titre" align="right"><input type="text" size="6" class="flat" name="search_ht" value="' . $search_ht . '"></td>';
 print '<td class="liste_titre" align="right"><input type="text" size="6" class="flat" name="search_ttc" value="' . $search_ttc . '"></td>';
 print '<td class="liste_titre">&nbsp;</td>';
 print '<td class="liste_titre">&nbsp;</td>';
 print '<td class="liste_titre" align="right">';
 $formorder->selectSupplierOrderStatus(strstr($search_status, ',') ? -1 : $search_status, 1, 'search_status');
 print '</td>';
 print '<td align="center">';
 print $form->selectyesno('billed', $billed, 1, 0, 1);
 print '</td>';
 print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
 print '<input type="image" class="liste_titre" name="button_removefilter" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
 print "</td></tr>\n";
 $var = true;
 $userstatic = new User($db);
 $objectstatic = new CommandeFournisseur($db);
 $projectstatic = new Project($db);
 while ($i < min($num, $conf->liste_limit)) {
     $obj = $db->fetch_object($resql);
     $var = !$var;
     $objectstatic->id = $obj->rowid;
     $objectstatic->ref = $obj->ref;
     $objectstatic->ref_supplier = $obj->ref_supplier;
     $objectstatic->total_ht = $obj->total_ht;
     $objectstatic->total_tva = $obj->total_tva;
     $objectstatic->total_ttc = $obj->total_ttc;
     print "<tr " . $bc[$var] . ">";
     // Ref
     print '<td class="nobordernopadding nowrap">';
     print $objectstatic->getNomUrl(1);
     $filename = dol_sanitizeFileName($obj->ref);
/**
 *  Create a document onto disk according to template model.
 *
 *  @param	    DoliDB		$db  			Database handler
 *  @param	    CommandeFournisseur		$object			Object supplier order
 *  @param	    string		$modele			Force template to use ('' to not force)
 *  @param		Translate	$outputlangs	Object lang to use for traduction
 *  @param      int			$hidedetails    Hide details of lines
 *  @param      int			$hidedesc       Hide description
 *  @param      int			$hideref        Hide ref
 *  @return     int          				0 if KO, 1 if OK
 * @deprecated Use the new function generateDocument of CommandeFournisseur class
 * @see CommandeFournisseur::generateDocument()
 */
function supplier_order_pdf_create(DoliDB $db, CommandeFournisseur $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
    dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
    return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
/**
 * getProducts
 *
 * @param 	int		$order_id		Order id
 * @return	void
 */
function getProducts($order_id)
{
    global $db;
    $order = new CommandeFournisseur($db);
    $f = $order->fetch($order_id);
    $products = array();
    if ($f) {
        foreach ($order->lines as $line) {
            if (!in_array($line->fk_product, $products)) {
                $products[] = $line->fk_product;
            }
        }
    }
    return $products;
}
Exemplo n.º 25
0
     $langs->load("errors");
     print '<div class="error">' . $langs->trans($tmp) . '</div>';
 } elseif ($tmp == 'NotConfigured') {
     print $langs->trans($tmp);
 } else {
     print $tmp;
 }
 print '</td>' . "\n";
 print '<td align="center">';
 if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER == "{$file}") {
     print img_picto($langs->trans("Activated"), 'switch_on');
 } else {
     print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setmod&amp;value=' . $file . '" alt="' . $langs->trans("Default") . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</a>';
 }
 print '</td>';
 $commande = new CommandeFournisseur($db);
 $commande->initAsSpecimen();
 // Info
 $htmltooltip = '';
 $htmltooltip .= '' . $langs->trans("Version") . ': <b>' . $module->getVersion() . '</b><br>';
 $nextval = $module->getNextValue($mysoc, $commande);
 if ("{$nextval}" != $langs->trans("NotAvailable")) {
     // Keep " on nextval
     $htmltooltip .= '' . $langs->trans("NextValue") . ': ';
     if ($nextval) {
         if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
             $nextval = $langs->trans($nextval);
         }
         $htmltooltip .= $nextval . '<br>';
     } else {
         $htmltooltip .= $langs->trans($module->error) . '<br>';
Exemplo n.º 26
0
$confirm = GETPOST('confirm', 'alpha');
$comclientid = GETPOST('comid', 'int');
$socid = GETPOST('socid', 'int');
$projectid = GETPOST('projectid', 'int');
//PDF
$hidedetails = GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
$hidedesc = GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
$hideref = GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'fournisseur', $id, '', 'commande');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('ordersuppliercard'));
$object = new CommandeFournisseur($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || !empty($ref)) {
    $ret = $object->fetch($id, $ref);
    if ($ret < 0) {
        dol_print_error($db, $object->error);
    }
    $ret = $object->fetch_thirdparty();
    if ($ret < 0) {
        dol_print_error($db, $object->error);
    }
} else {
    if (!empty($socid) && $socid > 0) {
Exemplo n.º 27
0
 $result = $db->query($sql);
 if ($result) {
     $num = $db->num_rows($result);
     print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], "&amp;id={$product->id}", $sortfield, $sortorder, '', $num, 0, '');
     $i = 0;
     print "<table class=\"noborder\" width=\"100%\">";
     print '<tr class="liste_titre">';
     print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid", "", "&amp;id=" . $product->id, '', $sortfield, $sortorder);
     print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"], "s.nom", "", "&amp;id=" . $product->id, '', $sortfield, $sortorder);
     print_liste_field_titre($langs->trans("SupplierCode"), $_SERVER["PHP_SELF"], "s.code_client", "", "&amp;id=" . $product->id, '', $sortfield, $sortorder);
     print_liste_field_titre($langs->trans("OrderDate"), $_SERVER["PHP_SELF"], "c.date_commande", "", "&amp;id=" . $product->id, 'align="center"', $sortfield, $sortorder);
     print_liste_field_titre($langs->trans("Qty"), $_SERVER["PHP_SELF"], "d.qty", "", "&amp;id=" . $product->id, 'align="center"', $sortfield, $sortorder);
     print_liste_field_titre($langs->trans("AmountHT"), $_SERVER["PHP_SELF"], "c.total_ht", "", "&amp;id=" . $product->id, 'align="right"', $sortfield, $sortorder);
     print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"], "c.fk_statut", "", "&amp;id=" . $product->id, 'align="right"', $sortfield, $sortorder);
     print "</tr>\n";
     $commandestatic = new CommandeFournisseur($db);
     if ($num > 0) {
         $var = True;
         while ($i < $num && $i < $conf->liste_limit) {
             $objp = $db->fetch_object($result);
             $var = !$var;
             $commandestatic->id = $objp->commandeid;
             $commandestatic->ref = $objp->ref;
             $commandestatic->statut = $objp->statut;
             print "<tr " . $bc[$var] . ">";
             print '<td>' . $commandestatic->getNomUrl(1) . "</td>\n";
             print "</a></td>\n";
             print '<td><a href="' . DOL_URL_ROOT . '/fourn/card.php?socid=' . $objp->socid . '">' . img_object($langs->trans("ShowCompany"), "company") . ' ' . dol_trunc($objp->name, 44) . '</a></td>';
             print "<td>" . $objp->code_client . "</td>\n";
             print '<td align="center">' . dol_print_date($db->jdate($objp->date_commande)) . "</td>";
             print "<td align=\"center\">" . $objp->qty . "</td>\n";
Exemplo n.º 28
0
             }
         } else {
             $error = $db->lasterror();
             dol_print_error($db);
         }
         $db->free($resql);
         unset($_POST['fourn' . $i]);
     }
     unset($_POST[$i]);
 }
 //we now know how many orders we need and what lines they have
 $i = 0;
 $orders = array();
 $suppliersid = array_keys($suppliers);
 foreach ($suppliers as $supplier) {
     $order = new CommandeFournisseur($db);
     // Check if an order for the supplier exists
     $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "commande_fournisseur";
     $sql .= " WHERE fk_soc = " . $suppliersid[$i];
     $sql .= " AND source = 42 AND fk_statut = 0";
     $sql .= " ORDER BY date_creation DESC";
     $resql = $db->query($sql);
     if ($resql && $db->num_rows($resql) > 0) {
         $obj = $db->fetch_object($resql);
         $order->fetch($obj->rowid);
         foreach ($supplier['lines'] as $line) {
             $result = $order->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, 0, $line->ref_fourn, $line->remise_percent, 'HT', 0, $line->info_bits);
         }
         if ($result < 0) {
             $fail++;
             $msg = $langs->trans('OrderFail') . "&nbsp;:&nbsp;";
Exemplo n.º 29
0
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
// Security check
$orderid = GETPOST('orderid');
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande');
$langs->load("suppliers");
$langs->load("orders");
/*
 * 	View
 */
llxHeader('', $langs->trans("SuppliersOrdersArea"));
$commandestatic = new CommandeFournisseur($db);
$userstatic = new User($db);
$formfile = new FormFile($db);
print load_fiche_titre($langs->trans("SuppliersOrdersArea"));
print '<table class="notopnoleftnoright" width="100%">';
print '<tr valign="top"><td class="notopnoleft" width="30%">';
/*
 * Search form
 */
$var = false;
print '<form method="post" action="list.php">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<table class="noborder nohover" width="100%">';
print '<tr class="liste_titre"><td colspan="3">' . $langs->trans("Search") . '</td></tr>';
print '<tr ' . $bc[$var] . '><td>';
print $langs->trans("SupplierOrder") . ':</td><td><input type="text" class="flat" name="search_all" size="18"></td><td><input type="submit" value="' . $langs->trans("Search") . '" class="button"></td></tr>';
/**
 * Delete preview files, pour le cas de regeneration de commande
 * @param   $db		   data base object
 * @param   $comfournid  id de la commande a effacer
 * @param   $comfournref reference de la commande si besoin
 * @return  int
 */
function supplier_order_delete_preview($db, $comfournid, $comfournref='')
{
	global $langs,$conf;
    require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");

	if (!$comfournref)
	{
		$comfourn = new CommandeFournisseur($db,"",$comfournid);
		$comfourn->fetch($comfournid);
		$comfournref = $comfourn->ref;
		$soc = new Societe($db);
		$soc->fetch($comfourn->socid);
	}
	
	

	if ($conf->fournisseur->dir_output.'/commande')
	{
		$suppordref = dol_sanitizeFileName($comfournref);
		$dir = $conf->fournisseur->dir_output . "/" . $suppordref ;
		$file = $dir . "/" . $suppordref . ".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 ( ! dol_delete_file($preview,1) )
					{
						$this->error=$langs->trans("ErrorFailedToOpenFile",$preview);
						return 0;
					}
				}
			}
		}
	}

	return 1;
}