public function getList($order, $critere, $debut, $nbres)
 {
     $query = $this->getRequest('list', $order, $critere, $debut, $nbres);
     $resul = $this->query($query);
     $retour = array();
     while ($resul && ($row = $this->fetch_object($resul))) {
         $thisClient = array();
         $thisClient['ref'] = $row->ref;
         $thisClient['entreprise'] = $row->entreprise;
         $thisClient['nom'] = $row->nom;
         $thisClient['prenom'] = $row->prenom;
         $thisClient['email'] = $row->email;
         $commande = new Commande();
         $devise = new Devise();
         $querycom = "SELECT id FROM {$commande->table} WHERE client={$row->id} AND statut NOT IN(" . Commande::NONPAYE . "," . Commande::ANNULE . ") ORDER BY date DESC LIMIT 0,1";
         $resulcom = $commande->query($querycom);
         if ($commande->num_rows($resulcom) > 0) {
             $idcom = $commande->get_result($resulcom, 0, "id");
             $commande->charger($idcom);
             $devise->charger($commande->devise);
             $thisClient['date'] = strftime("%d/%m/%Y %H:%M:%S", strtotime($commande->date));
             $thisClient['somme'] = formatter_somme($commande->total(true, true)) . ' ' . $devise->symbole;
         } else {
             $thisClient['date'] = '';
             $thisClient['somme'] = '';
         }
         $retour[] = $thisClient;
     }
     return $retour;
 }
 /**
  *  Load data for box to show them 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 . '/commande/class/commande.class.php';
     $commandestatic = new Commande($db);
     $this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerOrders", $max));
     if ($user->rights->commande->lire) {
         $sql = "SELECT s.nom, s.rowid as socid,";
         $sql .= " c.ref, c.tms, c.rowid,";
         $sql .= " c.fk_statut, c.facture";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
         $sql .= ", " . MAIN_DB_PREFIX . "commande 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);
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/commande/fiche.php?id=" . $objp->rowid);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->ref, 'url' => DOL_URL_ROOT . "/commande/fiche.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' => $objp->nom, 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $objp->socid);
                 $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' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3));
                 $i++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedOrders"));
             }
             $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('align' => 'left', 'text' => $langs->trans("ReadPermissionNotAllowed"));
     }
 }
Пример #3
0
 public static function getInstance($typeMatch, $phase, $place, $typeBillet, $nomUtilisateur, $password)
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new Commande($typeMatch, $phase, $place, $typeBillet, $nomUtilisateur, $password);
     }
     return self::$_instance;
 }
Пример #4
0
 public function confirmedCart()
 {
     //on récupère l'id du client
     $id = Session::get('client_id');
     //on trouve le client avec son id
     $user = User::find($id);
     //on charge les données pour la création de la commande
     $data = array('id_client' => $user->id);
     //on créer une nouvelle commande
     $commande = Commande::create($data);
     //on récupère les données de la session cart
     $cart_aray = Session::get('cart');
     foreach ($cart_aray as $c_array) {
         foreach ($c_array as $cart_line) {
             //on charge les données avant de créer une nouvelle ligne de commande
             $data = array('id_client' => $user->id, 'id_produit' => $cart_line['id'], 'quantite' => 1, 'id_command' => $commande->id);
             // pour chaque tour, on crée une nouvelle ligne de commande dans la base
             $ligne_commande = LigneCommande::create($data);
         }
     }
     //on supprime la session cart, et on la recrée vide.
     Session::forget('cart');
     Session::put('cart.items', '');
     return View::make('confirmed_cart');
 }
Пример #5
0
function substitcommande($texte)
{
    global $commande;
    if ($commande) {
        $refs = $commande;
    } else {
        $refs = $_SESSION['navig']->commande->ref;
    }
    $texte = str_replace("#COMMANDE_TRANSPORT", $_SESSION['navig']->commande->transport, $texte);
    $tcommande = new Commande();
    $tcommande->charger_ref($refs);
    $texte = str_replace("#COMMANDE_ID", $tcommande->id, $texte);
    $texte = str_replace("#COMMANDE_REF", $tcommande->ref, $texte);
    $texte = str_replace("#COMMANDE_TRANSACTION", $tcommande->transaction, $texte);
    return $texte;
}
Пример #6
0
	public function update(Commande $commande){
    	$query = $this->_db->prepare(
    	'UPDATE t_commande SET 
		idFournisseur=:idFournisseur, idProjet=:idProjet, dateCommande=:dateCommande, 
		numeroCommande=:numeroCommande, designation=:designation, updated=:updated, 
		updatedBy=:updatedBy
		WHERE id=:id')
		or die (print_r($this->_db->errorInfo()));
		$query->bindValue(':id', $commande->id());
		$query->bindValue(':idFournisseur', $commande->idFournisseur());
		$query->bindValue(':idProjet', $commande->idProjet());
		$query->bindValue(':dateCommande', $commande->dateCommande());
		$query->bindValue(':numeroCommande', $commande->numeroCommande());
		$query->bindValue(':designation', $commande->designation());
		$query->bindValue(':updated', $commande->updated());
		$query->bindValue(':updatedBy', $commande->updatedBy());
		$query->execute();
		$query->closeCursor();
	}
Пример #7
0
 /**
  * Validate an order
  * 
  * @param   int $id             Order ID
  * @param   int $idwarehouse    Warehouse ID
  * 
  * @url GET     order/{id}/validate
  * @url POST    order/{id}/validate
  *  
  * @return  array
  * 
  */
 function validOrder($id, $idwarehouse = 0)
 {
     if (!DolibarrApiAccess::$user->rights->commande->creer) {
         throw new RestException(401);
     }
     $result = $this->commande->fetch($id);
     if (!$result) {
         throw new RestException(404, 'Order not found');
     }
     if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
         throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
     }
     if (!$this->commande->valid(DolibarrApiAccess::$user, $idwarehouse)) {
         throw new RestException(500, 'Error when validate order');
     }
     return array('success' => array('code' => 200, 'message' => 'Order validated'));
 }
 /**
  * Affiche la liste de commandes
  * @return renvoie true si le tableau n'est pas vide
  */
 function afficherListeCommandes()
 {
     //requete sql
     $fin_req = "";
     if ($this->numclient) {
         $fin_req .= " AND numclient='{$this->numclient}'";
     }
     if ($this->erreur_paiement) {
         $fin_req .= " AND erreur_paiement='{$this->erreur_paiement}'";
     }
     if ($this->type_reg) {
         $fin_req .= " AND tpereg='{$this->type_reg}'";
     }
     if ($this->date_du && $this->date_au) {
         $fin_req .= " AND hcrea BETWEEN {$this->date_du} AND {$this->date_au}";
     } else {
         if ($this->date_du) {
             $fin_req .= " AND hcrea >= {$this->date_du}";
         } else {
             if ($this->date_au) {
                 $fin_req .= " AND hcrea <= {$this->date_au}";
             }
         }
     }
     /*if ($this->formation) $result=mysql_query("SELECT if_bo_com.numcom FROM if_bo_com,if_bo_detail WHERE if_bo_com.numcom=if_bo_detail.numcom AND if_bo_detail.designation='Inscription formation' $fin_req ORDER BY hcrea DESC");
     	 else $result=mysql_query("SELECT if_bo_com.numcom FROM if_bo_com,if_bo_detail WHERE etat $this->etat $fin_req AND if_bo_com.numcom=if_bo_detail.numcom ORDER BY hcrea DESC");*/
     if ($this->formation) {
         $result = mysql_query("SELECT if_bo_com.numcom FROM if_bo_com,if_bo_detail WHERE if_bo_com.numcom=if_bo_detail.numcom AND if_bo_detail.designation='Inscription formation' {$fin_req} ORDER BY hcrea DESC");
     } else {
         //$result=mysql_query("SELECT if_bo_com.numcom FROM if_bo_com,if_bo_detail WHERE etat $this->etat $fin_req AND if_bo_com.numcom=if_bo_detail.numcom ORDER BY hcrea DESC");
         $result = mysql_query("SELECT if_bo_com.numcom FROM if_bo_com WHERE etat {$this->etat} {$fin_req} ORDER BY hcrea DESC");
     }
     // echo "SELECT numcom FROM if_bo_com WHERE etat $this->etat $fin_req ORDER BY hcrea DESC";
     while ($row = mysql_fetch_row($result)) {
         $uneCommande = new Commande();
         $uneCommande->numcom = $row[0];
         $uneCommande->infosCommande();
         $this->commandes[] = $uneCommande;
     }
     if (count($this->commandes) >= 1) {
         return true;
     }
 }
?>
</th>
                                <th><?php 
echo trad('MONTANT_euro', 'admin');
?>
</th>
                                <th><?php 
echo trad('STATUT', 'admin');
?>
</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
<?php 
$commande = new Commande();
$query = "SELECT * FROM " . Commande::TABLE . " WHERE client='" . $client->id . "' ORDER BY date DESC";
$resul = $commande->query($query);
while ($resul && ($cmd = $commande->fetch_object($resul, 'Commande'))) {
    $statutdesc = new Statutdesc();
    $statutdesc->charger($cmd->statut);
    switch ($cmd->statut) {
        case '1':
            $trClass = 'warning';
            break;
        case '4':
            $trClass = 'success';
            break;
        case '5':
            $trClass = 'error';
            break;
Пример #10
0
 /**
  *	Create invoice in database
  *  Note: this->ref can be set or empty. If empty, we will use "(PROV)"
  *
  *	@param	User	$user      		Object user that create
  *	@param  int		$notrigger		1=Does not execute triggers, 0 otherwise
  * 	@param	int		$forceduedate	1=Do not recalculate due date from payment condition but force it with value
  *	@return	int						<0 if KO, >0 if OK
  */
 function create($user, $notrigger = 0, $forceduedate = 0)
 {
     global $langs, $conf, $mysoc, $hookmanager;
     $error = 0;
     // Clean parameters
     if (empty($this->type)) {
         $this->type = self::TYPE_STANDARD;
     }
     $this->ref_client = trim($this->ref_client);
     $this->note = isset($this->note) ? trim($this->note) : trim($this->note_private);
     // deprecated
     $this->note_private = isset($this->note_private) ? trim($this->note_private) : trim($this->note_private);
     $this->note_public = trim($this->note_public);
     if (!$this->cond_reglement_id) {
         $this->cond_reglement_id = 0;
     }
     if (!$this->mode_reglement_id) {
         $this->mode_reglement_id = 0;
     }
     $this->brouillon = 1;
     dol_syslog(get_class($this) . "::create user="******"ErrorBadParameter";
         dol_syslog(get_class($this) . "::create Try to create an invoice with an empty parameter (user, date, ...)", LOG_ERR);
         return -3;
     }
     $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;
     }
     $now = dol_now();
     $this->db->begin();
     // Create invoice from a predefined invoice
     if ($this->fac_rec > 0) {
         require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture-rec.class.php';
         $_facrec = new FactureRec($this->db);
         $result = $_facrec->fetch($this->fac_rec);
         $this->fk_project = $_facrec->fk_project;
         $this->cond_reglement_id = $_facrec->cond_reglement_id;
         $this->mode_reglement_id = $_facrec->mode_reglement_id;
         $this->remise_absolue = $_facrec->remise_absolue;
         $this->remise_percent = $_facrec->remise_percent;
         $this->fk_incoterms = $_facrec->fk_incoterms;
         $this->location_incoterms = $_facrec->location_incoterms;
         // Clean parameters
         if (!$this->type) {
             $this->type = self::TYPE_STANDARD;
         }
         $this->ref_client = trim($this->ref_client);
         $this->note_private = trim($this->note_private);
         $this->note_public = trim($this->note_public);
         //if (! $this->remise) $this->remise = 0;
         if (!$this->mode_reglement_id) {
             $this->mode_reglement_id = 0;
         }
         $this->brouillon = 1;
     }
     // Define due date if not already defined
     $datelim = empty($forceduedate) ? $this->calculate_date_lim_reglement() : $forceduedate;
     // Insert into database
     $socid = $this->socid;
     $sql = "INSERT INTO " . MAIN_DB_PREFIX . "facture (";
     $sql .= " facnumber";
     $sql .= ", entity";
     $sql .= ", ref_ext";
     $sql .= ", type";
     $sql .= ", fk_soc";
     $sql .= ", datec";
     $sql .= ", remise_absolue";
     $sql .= ", remise_percent";
     $sql .= ", datef";
     $sql .= ", note_private";
     $sql .= ", note_public";
     $sql .= ", ref_client, ref_int";
     $sql .= ", fk_account";
     $sql .= ", fk_facture_source, fk_user_author, fk_projet";
     $sql .= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf";
     $sql .= ", situation_cycle_ref, situation_counter, situation_final";
     $sql .= ", fk_incoterms, location_incoterms";
     $sql .= ")";
     $sql .= " VALUES (";
     $sql .= "'(PROV)'";
     $sql .= ", " . $conf->entity;
     $sql .= ", " . ($this->ref_ext ? "'" . $this->db->escape($this->ref_ext) . "'" : "null");
     $sql .= ", '" . $this->db->escape($this->type) . "'";
     $sql .= ", '" . $socid . "'";
     $sql .= ", '" . $this->db->idate($now) . "'";
     $sql .= ", " . ($this->remise_absolue > 0 ? $this->remise_absolue : 'NULL');
     $sql .= ", " . ($this->remise_percent > 0 ? $this->remise_percent : 'NULL');
     $sql .= ", '" . $this->db->idate($this->date) . "'";
     $sql .= ", " . ($this->note_private ? "'" . $this->db->escape($this->note_private) . "'" : "null");
     $sql .= ", " . ($this->note_public ? "'" . $this->db->escape($this->note_public) . "'" : "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->fk_account > 0 ? $this->fk_account : 'NULL');
     $sql .= ", " . ($this->fk_facture_source ? "'" . $this->db->escape($this->fk_facture_source) . "'" : "null");
     $sql .= ", " . ($user->id > 0 ? "'" . $user->id . "'" : "null");
     $sql .= ", " . ($this->fk_project ? $this->fk_project : "null");
     $sql .= ", " . $this->cond_reglement_id;
     $sql .= ", " . $this->mode_reglement_id;
     $sql .= ", '" . $this->db->idate($datelim) . "', '" . $this->db->escape($this->modelpdf) . "'";
     $sql .= ", " . ($this->situation_cycle_ref ? "'" . $this->db->escape($this->situation_cycle_ref) . "'" : "null");
     $sql .= ", " . ($this->situation_counter ? "'" . $this->db->escape($this->situation_counter) . "'" : "null");
     $sql .= ", " . ($this->situation_final ? $this->situation_final : 0);
     $sql .= ", " . (int) $this->fk_incoterms;
     $sql .= ", '" . $this->db->escape($this->location_incoterms) . "'";
     $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 . 'facture');
         // Update ref with new one
         $this->ref = '(PROV' . $this->id . ')';
         $sql = 'UPDATE ' . MAIN_DB_PREFIX . "facture SET facnumber='" . $this->ref . "' WHERE rowid=" . $this->id;
         dol_syslog(get_class($this) . "::create", LOG_DEBUG);
         $resql = $this->db->query($sql);
         if (!$resql) {
             $error++;
         }
         // Add object linked
         if (!$error && $this->id && 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 == 'commande') {
                     // On recupere les differents contact interne et externe
                     $order = new Commande($this->db);
                     $order->id = $origin_id;
                     // On recupere le commercial suivi propale
                     $this->userid = $order->getIdcontact('internal', 'SALESREPFOLL');
                     if ($this->userid) {
                         //On passe le commercial suivi commande en commercial suivi paiement
                         $this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
                     }
                     // On recupere le contact client facturation commande
                     $this->contactid = $order->getIdcontact('external', 'BILLING');
                     if ($this->contactid) {
                         //On passe le contact client facturation commande en contact client facturation
                         $this->add_contact($this->contactid[0], 'BILLING', 'external');
                     }
                 }
             }
         }
         /*
          *  Insert lines of invoices into database
          */
         if (count($this->lines) && is_object($this->lines[0])) {
             $fk_parent_line = 0;
             dol_syslog("There is " . count($this->lines) . " lines that are invoice lines objects");
             foreach ($this->lines as $i => $val) {
                 $newinvoiceline = $this->lines[$i];
                 $newinvoiceline->fk_facture = $this->id;
                 $newinvoiceline->origin = $this->element;
                 $newinvoiceline->origin_id = $this->lines[$i]->id;
                 if ($result >= 0 && ($newinvoiceline->info_bits & 0x1) == 0) {
                     // Reset fk_parent_line for no child products and special product
                     if ($newinvoiceline->product_type != 9 && empty($newinvoiceline->fk_parent_line) || $newinvoiceline->product_type == 9) {
                         $fk_parent_line = 0;
                     }
                     $newinvoiceline->fk_parent_line = $fk_parent_line;
                     $result = $newinvoiceline->insert();
                     // Defined the new fk_parent_line
                     if ($result > 0 && $newinvoiceline->product_type == 9) {
                         $fk_parent_line = $result;
                     }
                 }
                 if ($result < 0) {
                     $this->error = $newinvoiceline->error;
                     $error++;
                     break;
                 }
             }
         } else {
             $fk_parent_line = 0;
             dol_syslog("There is " . count($this->lines) . " lines that are array lines");
             foreach ($this->lines as $i => $val) {
                 if (($this->lines[$i]->info_bits & 0x1) == 0) {
                     // 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]->date_start, $this->lines[$i]->date_end, $this->lines[$i]->fk_code_ventilation, $this->lines[$i]->info_bits, $this->lines[$i]->fk_remise_except, 'HT', 0, $this->lines[$i]->product_type, $this->lines[$i]->rang, $this->lines[$i]->special_code, $this->element, $this->lines[$i]->id, $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]->situation_percent, $this->lines[$i]->fk_prev_id, $this->lines[$i]->fk_unit);
                     if ($result < 0) {
                         $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;
                     }
                 }
             }
         }
         /*
          * Insert lines of predefined invoices
          */
         if (!$error && $this->fac_rec > 0) {
             foreach ($_facrec->lines as $i => $val) {
                 if ($_facrec->lines[$i]->fk_product) {
                     $prod = new Product($this->db);
                     $res = $prod->fetch($_facrec->lines[$i]->fk_product);
                 }
                 $tva_tx = get_default_tva($mysoc, $soc, $prod->id);
                 $localtax1_tx = get_localtax($tva_tx, 1, $soc);
                 $localtax2_tx = get_localtax($tva_tx, 2, $soc);
                 $result_insert = $this->addline($_facrec->lines[$i]->desc, $_facrec->lines[$i]->subprice, $_facrec->lines[$i]->qty, $tva_tx, $localtax1_tx, $localtax2_tx, $_facrec->lines[$i]->fk_product, $_facrec->lines[$i]->remise_percent, '', '', 0, 0, '', 'HT', 0, $_facrec->lines[$i]->product_type, $_facrec->lines[$i]->rang, $_facrec->lines[$i]->special_code, '', 0, 0, null, 0, $_facrec->lines[$i]->label, null, $_facrec->lines[$i]->situation_percent, '', $_facrec->lines[$i]->fk_unit);
                 if ($result_insert < 0) {
                     $error++;
                     $this->error = $this->db->error();
                     break;
                 }
             }
         }
         if (!$error) {
             $result = $this->update_price(1);
             if ($result > 0) {
                 $action = 'create';
                 // Actions on extra fields (by external module or standard code)
                 // TODO le hook fait double emploi avec le trigger !!
                 $hookmanager->initHooks(array('invoicedao'));
                 $parameters = array('invoiceid' => $this->id);
                 $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action);
                 // Note that $action and $object may have been modified by some hooks
                 if (empty($reshook)) {
                     if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
                         $result = $this->insertExtraFields();
                         if ($result < 0) {
                             $error++;
                         }
                     }
                 } else {
                     if ($reshook < 0) {
                         $error++;
                     }
                 }
                 // Call trigger
                 $result = $this->call_trigger('BILL_CREATE', $user);
                 if ($result < 0) {
                     $error++;
                 }
                 // End call triggers
                 if (!$error) {
                     $this->db->commit();
                     return $this->id;
                 } else {
                     $this->db->rollback();
                     return -4;
                 }
             } else {
                 $this->error = $langs->trans('FailedToUpdatePrice');
                 $this->db->rollback();
                 return -3;
             }
         } else {
             dol_syslog(get_class($this) . "::create error " . $this->error, LOG_ERR);
             $this->db->rollback();
             return -2;
         }
     } else {
         $this->error = $this->db->error();
         $this->db->rollback();
         return -1;
     }
 }
Пример #11
0
 public function actionPaypalPayment()
 {
     $customer_model = new Customer();
     $commande_model = new Commande();
     $customer_model->attributes = Yii::app()->user->getState('Customer');
     $commande_model->attributes = Yii::app()->user->getState('Commande');
     if (sizeof($customer_model->search()->getData()) == 0) {
         $customer_model->bilsignupip = CHttpRequest::getUserHostAddress();
         $customer_model->save();
         $commande_model->bilkey = $customer_model->bilkey;
         $commande_model->comdebut = date("Y-m-d");
         $commande_model->save();
     } else {
         $customerTemp = $customer_model->search()->getData();
         $customer_model->bilkey = $customerTemp[0]->attributes['bilkey'];
     }
     if (isset($_POST['payment_status'])) {
         if ($_POST['payment_status'] == "Completed" || $_POST['payment_status'] == "Pending") {
             $city = Goodcity::model()->findByPk($_POST['item_number']);
             $this->sendEmailConfirmation($customer_model, $city, $commande_model, $_POST['txn_id'], $this->getInvoiceTotals($customer_model, $commande_model));
             $this->render('application/2-orderform', array('goodcity' => $city, 'thanks' => true, 'payment_type' => "paypal", 'payment_method' => "email", 'order_totals' => $this->getInvoiceTotals($customer_model, $commande_model), 'customer_model' => $customer_model, 'commande_model' => $commande_model, 'auth_code' => $_POST['txn_id']));
         } else {
             $this->redirect(array('user/order', 'transactionError' => true));
         }
     } else {
         $city = Goodcity::model()->findByPk($commande_model['comgoodcitykey']);
         $this->redirect(array('user/signup', 'city' => $commande_model['comgoodcitykey']));
     }
 }
Пример #12
0
	$var=!$var;
	print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("YourEMail");
	print ' ('.$langs->trans("ToComplete").')';
	print '</td><td class="CTableRow'.($var?'1':'2').'"><input class="flat" type="text" name="email" size="48" value="'.GETPOST("email").'"></td></tr>'."\n";
}


// Payment on customer order
if (GETPOST("source") == 'order')
{
	$found=true;
	$langs->load("orders");

	require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");

	$order=new Commande($db);
	$result=$order->fetch('',$_REQUEST["ref"]);
	if ($result < 0)
	{
		$mesg=$order->error;
		$error++;
	}
	else
	{
		$result=$order->fetch_thirdparty($order->socid);
	}

	$amount=$order->total_ttc;
    if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
    $amount=price2num($amount);
Пример #13
0
 $formmail->withtocc = $liste;
 $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
 $formmail->withtopic = $outputlangs->trans('SendShippingRef', '__SHIPPINGREF__');
 $formmail->withfile = 2;
 $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']);
Пример #14
0
 print '<td align="right">';
 $liststatus = array('0' => $langs->trans("StatusOrderDraftShort"), '1' => $langs->trans("StatusOrderValidated"), '2' => $langs->trans("StatusOrderSentShort"), '3' => $langs->trans("StatusOrderDelivered"), '-1' => $langs->trans("StatusOrderCanceledShort"));
 print $form->selectarray('viewstatut', $liststatus, $viewstatut, -4);
 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;
 $total = 0;
 $subtotal = 0;
 $productstat_cache = array();
 $i = 0;
 $generic_commande = new Commande($db);
 $generic_product = new Product($db);
 while ($i < min($num, $limit)) {
     $objp = $db->fetch_object($resql);
     $var = !$var;
     print '<tr ' . $bc[$var] . '>';
     print '<td class="nowrap">';
     $generic_commande->id = $objp->rowid;
     $generic_commande->ref = $objp->ref;
     $generic_commande->statut = $objp->fk_statut;
     $generic_commande->date_commande = $db->jdate($objp->date_commande);
     $generic_commande->date_livraison = $db->jdate($objp->date_delivery);
     $generic_commande->ref_client = $objp->ref_client;
     $generic_commande->total_ht = $objp->total_ht;
     $generic_commande->total_tva = $objp->total_tva;
     $generic_commande->total_ttc = $objp->total_ttc;
Пример #15
0
 /**
  *		Load an object from its id and create a new one in database
  *		@param      fromid     		Id of object to clone
  *		@param		invertdetail	Reverse sign of amounts for lines
  *		@param		socid			Id of thirdparty
  * 	 	@return		int				New id of clone
  */
 function createFromClone($fromid, $invertdetail = 0, $socid = 0)
 {
     global $conf, $user, $langs;
     $error = 0;
     $object = new Commande($this->db);
     // Instantiate hooks of thirdparty module
     if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) {
         $object->callHooks('ordercard');
     }
     $this->db->begin();
     // Load source object
     $object->fetch($fromid);
     $objFrom = $object;
     // Change socid if needed
     if (!empty($socid) && $socid != $object->socid) {
         $objsoc = new Societe($this->db);
         if ($objsoc->fetch($socid) > 0) {
             $object->socid = $objsoc->id;
             $object->cond_reglement_id = !empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0;
             $object->mode_reglement_id = !empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0;
             $object->fk_project = '';
             $object->fk_delivery_address = '';
         }
         // TODO Change product price if multi-prices
     }
     $object->id = 0;
     $object->statut = 0;
     // Clear fields
     $object->user_author_id = $user->id;
     $object->user_valid = '';
     $object->date_creation = '';
     $object->date_validation = '';
     $object->ref_client = '';
     // Create clone
     $result = $object->create($user);
     // Other options
     if ($result < 0) {
         $this->error = $object->error;
         $error++;
     }
     if (!$error) {
         // Hook of thirdparty module
         if (!empty($object->hooks)) {
             foreach ($object->hooks as $hook) {
                 if (!empty($hook['modules'])) {
                     foreach ($hook['modules'] as $module) {
                         if (method_exists($module, 'createfrom')) {
                             $result = $module->createfrom($objFrom, $result, $object->element);
                             if ($result < 0) {
                                 $error++;
                             }
                         }
                     }
                 }
             }
         }
         // Appel des triggers
         include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
         $interface = new Interfaces($this->db);
         $result = $interface->run_triggers('ORDER_CLONE', $object, $user, $langs, $conf);
         if ($result < 0) {
             $error++;
             $this->errors = $interface->errors;
         }
         // Fin appel triggers
     }
     // End
     if (!$error) {
         $this->db->commit();
         return $object->id;
     } else {
         $this->db->rollback();
         return -1;
     }
 }
Пример #16
0
                print '</tr>';
            } else {
                print '<tr ' . $bc[$var] . '><td colspan="5">' . $langs->trans("None") . '</td></tr>';
            }
            print "</table><br>";
            $db->free($resql);
        } else {
            dol_print_error($db);
        }
    }
}
/*
 * Customers orders to be billed
 */
if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user->rights->commande->lire) {
    $commandestatic = new Commande($db);
    $langs->load("orders");
    $sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc,";
    $sql .= " s.nom, s.rowid as socid,";
    $sql .= " c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.total_ttc";
    $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
    if (!$user->rights->societe->client->voir && !$socid) {
        $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
    }
    $sql .= ", " . MAIN_DB_PREFIX . "commande as c";
    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "element_element as el ON el.fk_source = c.rowid AND el.sourcetype = 'commande'";
    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture AS f ON el.fk_target = f.rowid AND el.targettype = 'facture'";
    $sql .= " WHERE c.fk_soc = s.rowid";
    $sql .= " AND c.entity = " . $conf->entity;
    if (!$user->rights->societe->client->voir && !$socid) {
        $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;
Пример #17
0
			print '<table class="border" width="100%">';

			// Ref
			print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
			print '<td colspan="3">'.$delivery->ref.'</td></tr>';

			// Client
			print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
			print '<td align="3">'.$soc->getNomUrl(1).'</td>';
			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>';
    $prenom = $post['prenom'];
} else {
    $prenom = null;
}
if (!empty($post['login'])) {
    $login = $post['login'];
} else {
    $login = null;
}
if (!empty($post['dateDeb'])) {
    $date_com_deb = $post['dateDeb'];
} else {
    $date_com_deb = null;
}
if (!empty($post['dateFin'])) {
    $date_com_fin = $post['dateFin'];
} else {
    $date_com_fin = null;
}
try {
    $listeCom = Commande::getCommandesBy($id_com, $id_utilisateur, $nom, $prenom, $login, $date_com_deb, $date_com_fin);
    $parameters['commande'] = $listeCom;
} catch (Exception $e) {
    $parameters['error'] = $e->getMessage();
}
$smarty->assign('parameters', $parameters);
$ligneCom = array();
foreach ($parameters['commande'] as $key => $value) {
    $ligneCom[] = Commande::getLigneCom($value['id_com']);
}
$smarty->assign('ligneCom', $ligneCom);
Пример #19
0
 /**
  *  Initialise an instance with random values.
  *  Used to build previews or test instances.
  *	id must be 0 if object instance is a specimen.
  *
  *  @return	void
  */
 function initAsSpecimen()
 {
     global $user, $langs, $conf;
     $now = dol_now();
     dol_syslog(get_class($this) . "::initAsSpecimen");
     // Charge tableau des produits prodids
     $prodids = array();
     $sql = "SELECT rowid";
     $sql .= " FROM " . MAIN_DB_PREFIX . "product";
     $sql .= " WHERE entity IN (" . getEntity('product', 1) . ")";
     $resql = $this->db->query($sql);
     if ($resql) {
         $num_prods = $this->db->num_rows($resql);
         $i = 0;
         while ($i < $num_prods) {
             $i++;
             $row = $this->db->fetch_row($resql);
             $prodids[$i] = $row[0];
         }
     }
     $order = new Commande($this->db);
     $order->initAsSpecimen();
     // Initialise parametres
     $this->id = 0;
     $this->ref = 'SPECIMEN';
     $this->specimen = 1;
     $this->statut = 1;
     $this->livraison_id = 0;
     $this->date = $now;
     $this->date_creation = $now;
     $this->date_valid = $now;
     $this->date_delivery = $now;
     $this->date_expedition = $now + 24 * 3600;
     $this->entrepot_id = 0;
     $this->fk_delivery_address = 0;
     $this->socid = 1;
     $this->commande_id = 0;
     $this->commande = $order;
     $this->origin_id = 1;
     $this->origin = 'commande';
     $this->note_private = 'Private note';
     $this->note_public = 'Public note';
     $nbp = 5;
     $xnbp = 0;
     while ($xnbp < $nbp) {
         $line = new ExpeditionLigne($this->db);
         $line->desc = $langs->trans("Description") . " " . $xnbp;
         $line->libelle = $langs->trans("Description") . " " . $xnbp;
         $line->qty = 10;
         $line->qty_asked = 5;
         $line->qty_shipped = 4;
         $line->fk_product = $this->commande->lines[$xnbp]->fk_product;
         $this->lines[] = $line;
         $xnbp++;
     }
 }
Пример #20
0
}
$langs->load('orders');
$langs->load('sendings');
$langs->load('companies');
$langs->load('bills');
$langs->load('propal');
$langs->load('deliveries');
$langs->load('products');
$id = GETPOST("id") ? GETPOST("id") : GETPOST("orderid");
$ref = GETPOST('ref');
$socid = GETPOST('socid');
$action = GETPOST('action');
$confirm = GETPOST('confirm');
$lineid = GETPOST('lineid');
$mesg = GETPOST('mesg');
$object = new Commande($db);
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'commande', $id, '');
// Instantiate hooks of thirdparty module
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) {
    $object->callHooks('ordercard');
}
/******************************************************************************/
/*                     Actions                                                */
/******************************************************************************/
// Hook of actions
if (!empty($object->hooks)) {
    foreach ($object->hooks as $hook) {
Пример #21
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			&$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $langs, $conf, $mysoc;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $mysoc->logo;
     if ($mysoc->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
         }
     } else {
         $pdf->MultiCell(100, 4, $this->emetteur->name, 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 2);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryOrder") . " " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $pdf->SetFont('', '', $default_font_size + 2);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     if ($object->date_valid) {
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date_delivery ? $object->date_delivery : $date->valid, "%d %b %Y", false, $outputlangs, true), '', 'R');
     } else {
         $pdf->SetTextColor(255, 0, 0);
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryNotValidated"), '', 'R');
         $pdf->SetTextColor(0, 0, 60);
     }
     if ($object->client->code_client) {
         $posy += 5;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     $pdf->SetTextColor(0, 0, 60);
     // Add origin linked objects
     // TODO extend to other objects
     $object->fetchObjectLinked('', '', $object->id, 'delivery');
     if (!empty($object->linkedObjects)) {
         $outputlangs->load('orders');
         foreach ($object->linkedObjects as $elementtype => $objects) {
             $object->fetchObjectLinked('', '', $objects[0]->id, $objects[0]->element);
             foreach ($object->linkedObjects as $elementtype => $objects) {
                 $num = count($objects);
                 for ($i = 0; $i < $num; $i++) {
                     $order = new Commande($this->db);
                     $result = $order->fetch($objects[$i]->id);
                     if ($result >= 0) {
                         $posy += 5;
                         $pdf->SetXY($posx, $posy);
                         $pdf->SetFont('', '', $default_font_size - 1);
                         $text = $order->ref;
                         if ($order->ref_client) {
                             $text .= ' (' . $order->ref_client . ')';
                         }
                         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder") . " : " . $outputlangs->transnoentities($text), '', 'R');
                     }
                 }
             }
         }
     }
     if ($showaddress) {
         // Emetteur
         $posy = 42;
         $hautcadre = 40;
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($this->marge_gauche, $posy - 5);
         $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":");
         $pdf->SetXY($this->marge_gauche, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetXY($this->marge_gauche + 2, $posy + 3);
         // Nom emetteur
         $pdf->SetTextColor(0, 0, 60);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($this->marge_gauche + 2, $posy + 9);
         $pdf->MultiCell(80, 3, $carac_emetteur, 0, 'L');
         // Client destinataire
         $posy = 42;
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY(102, $posy - 5);
         $pdf->MultiCell(80, 5, $outputlangs->transnoentities("DeliveryAddress") . ":", 0, 'L');
         // Cadre client destinataire
         $pdf->Rect(100, $posy, 100, $hautcadre);
         // If SHIPPING contact defined on invoice, we use it
         $usecontact = false;
         $arrayidcontact = $object->commande->getIdContact('external', 'SHIPPING');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->nom;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $object->contact, $usecontact, 'target');
         // Show customer/recipient
         $pdf->SetXY(102, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(106, 4, $carac_client_name, 0, 'L');
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY(102, $posy + 8);
         $pdf->MultiCell(86, 4, $carac_client, 0, 'L');
     }
 }
 /**
  *  Update a supplier order from a customer order
  *
  *  @param  User	$user           User that create
  *  @param  int		$idc			Id of supplier order to update
  *  @param	int		$comclientid	Id of customer order to use as template
  *	@return	int						<0 if KO, >0 if OK
  */
 function updateFromCommandeClient($user, $idc, $comclientid)
 {
     $comclient = new Commande($this->db);
     $comclient->fetch($comclientid);
     $this->id = $idc;
     $this->lines = array();
     $num = count($comclient->lines);
     for ($i = 0; $i < $num; $i++) {
         $prod = new Product($this->db);
         if ($prod->fetch($comclient->lines[$i]->fk_product) > 0) {
             $libelle = $prod->libelle;
             $ref = $prod->ref;
         }
         $sql = "INSERT INTO " . MAIN_DB_PREFIX . "commande_fournisseurdet";
         $sql .= " (fk_commande,label,description,fk_product, price, qty, tva_tx, localtax1_tx, localtax2_tx, remise_percent, subprice, remise, ref)";
         $sql .= " VALUES (" . $idc . ", '" . $this->db->escape($libelle) . "','" . $this->db->escape($comclient->lines[$i]->desc) . "'";
         $sql .= "," . $comclient->lines[$i]->fk_product . ",'" . price2num($comclient->lines[$i]->price) . "'";
         $sql .= ", '" . $comclient->lines[$i]->qty . "', " . $comclient->lines[$i]->tva_tx . ", " . $comclient->lines[$i]->localtax1_tx . ", " . $comclient->lines[$i]->localtax2_tx . ", " . $comclient->lines[$i]->remise_percent;
         $sql .= ", '" . price2num($comclient->lines[$i]->subprice) . "','0','" . $ref . "');";
         if ($this->db->query($sql)) {
             $this->update_price();
         }
     }
     return 1;
 }
Пример #23
0
    // Tag
    $var = !$var;
    print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("PaymentCode");
    print '</td><td class="CTableRow' . ($var ? '1' : '2') . '"><b>' . $fulltag . '</b>';
    print '<input type="hidden" name="tag" value="' . $tag . '">';
    print '<input type="hidden" name="fulltag" value="' . $fulltag . '">';
    print '</td></tr>' . "\n";
    // We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum
    // as they don't exists (buyer is unknown, tag is free).
}
// Payment on customer order
if (GETPOST("source") == 'order' && $valid) {
    $found = true;
    $langs->load("orders");
    require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
    $order = new Commande($db);
    $result = $order->fetch('', $ref);
    if ($result < 0) {
        $mesg = $order->error;
        $error++;
    } else {
        $result = $order->fetch_thirdparty($order->socid);
    }
    $amount = $order->total_ttc;
    if (GETPOST("amount", 'int')) {
        $amount = GETPOST("amount", 'int');
    }
    $amount = price2num($amount);
    $fulltag = 'ORD=' . $order->ref . '.CUS=' . $order->thirdparty->id;
    //$fulltag.='.NAM='.strtr($order->thirdparty->name,"-"," ");
    if (!empty($TAG)) {
Пример #24
0
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
/**
 *       \file       htdocs/expedition/index.php
 *       \ingroup    expedition
 *       \brief      Home page of shipping area.
 */
require '../main.inc.php';
require DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
require DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
$langs->load("orders");
$langs->load("sendings");
/*
 *	View
 */
$orderstatic = new Commande($db);
$companystatic = new Societe($db);
$shipment = new Expedition($db);
$helpurl = 'EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
llxHeader('', $langs->trans("Shipment"), $helpurl);
print load_fiche_titre($langs->trans("SendingsArea"));
print '<div class="fichecenter"><div class="fichethirdleft">';
$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("SearchASending") . '</td></tr>';
print '<tr ' . $bc[$var] . '><td>';
print $langs->trans("Ref") . ':</td><td><input type="text" class="flat" name="sf_ref" size="18"></td><td><input type="submit" value="' . $langs->trans("Search") . '" class="button"></td></tr>';
print "</table></form><br>\n";
/*
Пример #25
0
             print '<td align="right" width="120">' . price($objp->total_ht) . '</td>';
             print '<td align="right" nowrap="nowrap">' . $propal_static->LibStatut($objp->fk_statut, 5) . '</td></tr>';
             $var = !$var;
             $i++;
         }
         $db->free($resql);
     } else {
         dol_print_error($db);
     }
     print "</table>";
 }
 /*
  * Last orders
  */
 if ($conf->commande->enabled && $user->rights->commande->lire) {
     $commande_static = new Commande($db);
     print '<table class="noborder" width="100%">';
     $sql = "SELECT s.nom, s.rowid,";
     $sql .= " c.rowid as cid, c.total_ht, c.ref, c.fk_statut, c.facture,";
     $sql .= " c.date_commande as dc";
     $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "commande as c";
     $sql .= " WHERE c.fk_soc = s.rowid ";
     $sql .= " AND s.rowid = " . $objsoc->id;
     $sql .= " ORDER BY c.date_commande DESC";
     $resql = $db->query($sql);
     if ($resql) {
         $var = true;
         $num = $db->num_rows($resql);
         if ($num > 0) {
             print '<tr class="liste_titre">';
             print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>' . $langs->trans("LastOrders", $num <= $MAXLIST ? "" : $MAXLIST) . '</td><td align="right"><a href="' . DOL_URL_ROOT . '/commande/liste.php?socid=' . $objsoc->id . '">' . $langs->trans("AllOrders") . ' (' . $num . ')</a></td>';
Пример #26
0
if (!$user->rights->commande->lire) accessforbidden();

$langs->load("companies");
$langs->load("bills");
$langs->load("orders");

// Security check
$socid=0;
$comid = isset($_GET["id"])?$_GET["id"]:'';
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'commande',$comid,'');


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


/*
 * Actions
 */

if ($_POST["action"] == 'update' && $user->rights->commande->creer)
{
	$db->begin();

	$resPrivateNote=$commande->update_note($_POST["note"]);
 } elseif ($tmp == 'NotConfigured') {
     print $langs->trans($tmp);
 } else {
     print $tmp;
 }
 print '</td>' . "\n";
 print '<td align="center">';
 if ($conf->global->COMMANDE_ADDON == $file) {
     print img_picto($langs->trans("Activated"), 'switch_on');
 } else {
     print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setmod&amp;value=' . $file . '">';
     print img_picto($langs->trans("Disabled"), 'switch_off');
     print '</a>';
 }
 print '</td>';
 $commande = new Commande($db);
 $commande->initAsSpecimen();
 // Info
 $htmltooltip = '';
 $htmltooltip .= '' . $langs->trans("Version") . ': <b>' . $module->getVersion() . '</b><br>';
 $commande->type = 0;
 $nextval = $module->getNextValue($mysoc, $commande);
 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">';
Пример #28
0
 $totalVolume = $totalVolume;
 //print "totalVolume=".$totalVolume." volumeUnit=".$volumeUnit;
 print '<table class="border" width="100%">';
 // Ref
 print '<tr><td width="20%">' . $langs->trans("Ref") . '</td>';
 print '<td colspan="3">';
 print $html->showrefnav($object, 'ref', '', 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' && $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";
Пример #29
0
function liste_clients($order, $critere, $debut)
{
    $i = 0;
    $client = new Client();
    $query = "select * from {$client->table} order by {$critere} {$order} limit {$debut},20";
    $resul = $client->query($query);
    while ($resul && ($row = $client->fetch_object($resul))) {
        $fond = "ligne_" . ($i++ % 2 ? "claire" : "fonce") . "_rub";
        $commande = new Commande();
        $devise = new Devise();
        $querycom = "select id from {$commande->table} where client={$row->id} and statut not in(" . Commande::NONPAYE . "," . Commande::ANNULE . ") order by date DESC limit 0,1";
        $resulcom = $commande->query($querycom);
        $existe = 0;
        if ($commande->num_rows($resulcom) > 0) {
            $existe = 1;
            $idcom = $commande->get_result($resulcom, 0, "id");
            $commande->charger($idcom);
            $devise->charger($commande->devise);
            $date = strftime("%d/%m/%y %H:%M:%S", strtotime($commande->date));
        }
        $creation = strftime("%d/%m/%y %H:%M:%S", strtotime($row->datecrea));
        ?>
<ul class="<?php 
        echo $fond;
        ?>
">
	<li style="width:122px;"><?php 
        echo $row->ref;
        ?>
</li>
	<li style="width:110px;"><?php 
        echo $creation;
        ?>
</li>
	<li style="width:143px;"><?php 
        echo $row->entreprise;
        ?>
</li>
	<li style="width:243px;"><?php 
        echo $row->nom;
        ?>
 <?php 
        echo $row->prenom;
        ?>
</li>
	<li style="width:110px;"><?php 
        if ($existe) {
            echo $date;
        }
        ?>
</li>
	<li style="width:63px;"><?php 
        if ($existe) {
            echo formatter_somme($commande->total(true, true)) . ' ' . $devise->symbole;
        }
        ?>
</li>
	<li style="width:40px;"><a href="client_visualiser.php?ref=<?php 
        echo $row->ref;
        ?>
" class="txt_vert_11"><?php 
        echo trad('editer', 'admin');
        ?>
</a></li>
	<li style="width:25px; text-align:center;"><a href="#" onclick="confirmSupp('<?php 
        echo $row->ref;
        ?>
')"><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></li>
</ul>
<?php 
    }
}
Пример #30
0
function _genInfoEtiquette(&$db, &$PDOdb, &$TPrintTicket)
{
    global $conf;
    $TInfoEtiquette = array();
    if (empty($TPrintTicket)) {
        return $TInfoEtiquette;
    }
    dol_include_once('/commande/class/commande.class.php');
    $assetOf = new TAssetOF();
    $cmd = new Commande($db);
    $product = new Product($db);
    $pos = 1;
    $cpt = 0;
    foreach ($TPrintTicket as $fk_assetOf => $qty) {
        if ($qty <= 0) {
            continue;
        }
        $load = $assetOf->load($PDOdb, $fk_assetOf);
        if ($load === true) {
            $cmd->fetch($assetOf->fk_commande);
            foreach ($assetOf->TAssetOFLine as &$assetOfLine) {
                if ($assetOfLine->type == 'TO_MAKE' && $product->fetch($assetOfLine->fk_product) > 0) {
                    for ($i = 0; $i < $qty; $i++) {
                        $cpt++;
                        if ($cpt % 2 == 0) {
                            $div = 'pair';
                        } else {
                            $div = 'impair';
                        }
                        $TInfoEtiquette[] = array('numOf' => $assetOf->numero, 'float' => $div, 'refCmd' => $cmd->ref, 'refCliCmd' => $cmd->ref_client, 'refProd' => $product->ref, 'qty_to_print' => $qty, 'qty_to_make' => $assetOfLine->qty, 'label' => wordwrap(preg_replace('/\\s\\s+/', ' ', $product->label), 20, $conf->global->DEFAULT_ETIQUETTES == 2 ? "\n" : "</br>"), 'pos' => ceil($pos / 8));
                        //var_dump($TInfoEtiquette);exit;
                        $pos++;
                        //var_dump($TInfoEtiquette);
                    }
                }
            }
        }
    }
    //exit;
    return $TInfoEtiquette;
}