Ejemplo n.º 1
0
    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)) {
        $tag = $TAG;
        $fulltag .= '.TAG=' . $TAG;
    }
    $fulltag = dol_string_unaccent($fulltag);
    // Creditor
    $var = !$var;
Ejemplo n.º 2
0
         print '<td width="12%" align="center">' . $langs->trans("Stock") . '</td>';
     }
     print "</tr>\n";
 }
 $var = true;
 while ($i < $num) {
     $product = new Product($db);
     $line = $commande->lines[$i];
     $var = !$var;
     print "<tr " . $bc[$var] . ">\n";
     if ($line->fk_product > 0) {
         $product->fetch($line->fk_product);
         $product->load_stock();
         // Define output language
         if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
             $commande->fetch_thirdparty();
             $outputlangs = $langs;
             $newlang = '';
             if (empty($newlang) && !empty($_REQUEST['lang_id'])) {
                 $newlang = $_REQUEST['lang_id'];
             }
             if (empty($newlang)) {
                 $newlang = $commande->client->default_lang;
             }
             if (!empty($newlang)) {
                 $outputlangs = new Translate("", $conf);
                 $outputlangs->setDefaultLang($newlang);
             }
             $label = !empty($product->multilangs[$outputlangs->defaultlang]["label"]) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $product->label;
         } else {
             $label = !empty($line->label) ? $line->label : $product->label;
Ejemplo n.º 3
0
if (! $sortfield) $sortfield="name";


$object = new Commande($db);


/*
 * Actions
 */

// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
	if ($object->fetch($id))
    {
        $object->fetch_thirdparty();

	    $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);

		if (create_exdir($upload_dir) >= 0)
		{
			$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
			if (is_numeric($resupload) && $resupload > 0)
			{
				$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
			}
			else
			{
				$langs->load("errors");
				if ($resupload < 0)	// Unknown error
				{
Ejemplo n.º 4
0
$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 (!empty($user->societe_id)) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'commande', $id);
$object = new Commande($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);
    $ret = $object->fetch_thirdparty();
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('ordercard'));
$permissionnote = $user->rights->commande->creer;
// Used by the include of actions_setnotes.inc.php
/*
 * Actions
 */
$parameters = array('socid' => $socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
// Note that $action and $object may have been modified by some hooks
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php';
// Must be include, not includ_once
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) {
Ejemplo n.º 5
0
/**
 * Valid an order
 *
 * @param	array		$authentication		Array of authentication information
 * @param	int			$id					Id of order to validate
 * @return	array							Array result
 */
function validOrder($authentication, $id = '')
{
    global $db, $conf, $langs;
    dol_syslog("Function: validOrder login="******" id=" . $id . " ref=" . $ref . " ref_ext=" . $ref_ext);
    // Init and check authentication
    $objectresp = array();
    $errorcode = '';
    $errorlabel = '';
    $error = 0;
    if ($authentication['entity']) {
        $conf->entity = $authentication['entity'];
    }
    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
    if (!$error) {
        $fuser->getrights();
        if ($fuser->rights->commande->lire) {
            $order = new Commande($db);
            $result = $order->fetch($id, $ref, $ref_ext);
            $order->fetch_thirdparty();
            $db->begin();
            if ($result > 0) {
                $result = $order->valid($fuser);
                if ($result >= 0) {
                    // Define output language
                    $outputlangs = $langs;
                    $order->generateDocument($order->modelpdf, $outputlangs);
                } else {
                    $db->rollback();
                    $error++;
                    $errorcode = 'KO';
                    $errorlabel = $newobject->error;
                }
            } else {
                $db->rollback();
                $error++;
                $errorcode = 'KO';
                $errorlabel = $newobject->error;
            }
        } else {
            $db->rollback();
            $error++;
            $errorcode = 'KO';
            $errorlabel = $newobject->error;
        }
    }
    if ($error) {
        $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
    } else {
        $db->commit();
        $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''));
    }
    return $objectresp;
}
Ejemplo n.º 6
0
 /**
  *  testFetchThirdParty
  *
  *  @return void
  */
 public function testFetchThirdParty()
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localobject = new Commande($this->savdb);
     $localobject->fetch(1);
     $result = $localobject->fetch_thirdparty();
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThanOrEqual($result, 0);
     return $result;
 }