Esempio n. 1
0
 public function insert_item()
 {
     $sql = "INSERT INTO " . TB_PREFIX . "invoice_items \n\t\t\t\t(\n\t\t\t\t\tinvoice_id, \n\t\t\t\t\tquantity, \n\t\t\t\t\tproduct_id, \n\t\t\t\t\tunit_price, \n\t\t\t\t\ttax_amount, \n\t\t\t\t\tgross_total, \n\t\t\t\t\tdescription, \n\t\t\t\t\ttotal\n\t\t\t\t) \n\t\t\t\tVALUES \n\t\t\t\t(\n\t\t\t\t\t:invoice_id, \n\t\t\t\t\t:quantity, \n\t\t\t\t\t:product_id, \n\t\t\t\t\t:unit_price, \n\t\t\t\t\t:tax_amount, \n\t\t\t\t\t:gross_total, \n\t\t\t\t\t:description, \n\t\t\t\t\t:total\n\t\t\t\t)";
     //echo $sql;
     dbQuery($sql, ':invoice_id', $this->invoice_id, ':quantity', $this->quantity, ':product_id', $this->product_id, ':unit_price', $this->unit_price, ':tax_amount', $this->tax_amount, ':gross_total', $this->gross_total, ':description', $this->description, ':total', $this->total);
     invoice_item_tax(lastInsertId(), $this->tax, $this->unit_price, $this->quantity, "insert");
 }
Esempio n. 2
0
 public function insert_item()
 {
     $sql = "INSERT INTO " . TB_PREFIX . "invoice_items \n\t\t\t\t(\n\t\t\t\t\tinvoice_id, \n\t\t\t\t\tdomain_id, \n\t\t\t\t\tquantity, \n\t\t\t\t\tproduct_id, \n\t\t\t\t\tunit_price, \n\t\t\t\t\ttax_amount, \n\t\t\t\t\tgross_total, \n\t\t\t\t\tdescription, \n\t\t\t\t\ttotal,\n\t\t\t\t\tattribute\n\t\t\t\t) \n\t\t\t\tVALUES \n\t\t\t\t(\n\t\t\t\t\t:invoice_id, \n\t\t\t\t\t:domain_id, \n\t\t\t\t\t:quantity, \n\t\t\t\t\t:product_id, \n\t\t\t\t\t:unit_price, \n\t\t\t\t\t:tax_amount, \n\t\t\t\t\t:gross_total, \n\t\t\t\t\t:description, \n\t\t\t\t\t:total,\n\t\t\t\t\t:attribute\n\t\t\t\t)";
     dbQuery($sql, ':invoice_id', $this->invoice_id, ':domain_id', $this->domain_id, ':quantity', $this->quantity, ':product_id', $this->product_id, ':unit_price', $this->unit_price, ':tax_amount', $this->tax_amount, ':gross_total', $this->gross_total, ':description', trim($this->description), ':total', $this->total, ':attribute', $this->attribute);
     $inv_item_id = lastInsertId();
     invoice_item_tax($inv_item_id, $this->tax, $this->unit_price, $this->quantity, 'insert', $this->domain_id);
     return $inv_item_id;
 }
Esempio n. 3
0
 public function save()
 {
     global $logger;
     $sql = "INSERT into\n            " . TB_PREFIX . "expense\n            (\n                domain_id,\n                amount,\n                expense_account_id,\n                biller_id,\n                customer_id,\n                invoice_id,\n                product_id,\n                date,\n                status,\n                note\n            )\n        VALUES\n            (\t\n                :domain_id,\n                :amount,\n                :expense_account_id,\n                :biller_id,\n                :customer_id,\n                :invoice_id,\n                :product_id,\n                :date,\n                :status,\n                :note\n            )";
     dbQuery($sql, ':domain_id', $this->domain_id, ':amount', $_POST['amount'], ':expense_account_id', $_POST['expense_account_id'], ':biller_id', $_POST['biller_id'], ':invoice_id', $_POST['invoice_id'], ':product_id', $_POST['product_id'], ':customer_id', $_POST['customer_id'], ':date', $_POST['date'], ':status', $_POST['status'], ':note', $_POST['note']);
     $logger->log("Exp ITEM tax- last insert ID-" . lastInsertId(), Zend_Log::INFO);
     $this->expense_item_tax(lastInsertId(), $_POST['tax_id'][0], $_POST['amount'], "1", "insert");
     return true;
 }
Esempio n. 4
0
$op = !empty($_POST['op']) ? addslashes($_POST['op']) : NULL;
$include_online_payment = '';
foreach ($_POST['include_online_payment'] as $k => $v) {
    $include_online_payment .= $v;
    if ($k != end(array_keys($_POST['include_online_payment']))) {
        $include_online_payment .= ',';
    }
}
#insert invoice_preference
if ($op === 'insert_preference') {
    $sql = "INSERT into\n\t\t" . TB_PREFIX . "preferences\n\t\t(\n\t\t\tdomain_id,\n\t\t\tpref_description,\n\t\t\tpref_currency_sign,\n\t\t\tcurrency_code,\n\t\t\tpref_inv_heading,\n\t\t\tpref_inv_wording,\n\t\t\tpref_inv_detail_heading,\n\t\t\tpref_inv_detail_line,\n\t\t\tpref_inv_payment_method,\n\t\t\tpref_inv_payment_line1_name,\n\t\t\tpref_inv_payment_line1_value,\n\t\t\tpref_inv_payment_line2_name,\n\t\t\tpref_inv_payment_line2_value,\n\t\t\tpref_enabled,\n\t\t        status,\n\t\t        locale,\n\t\t        language,\n\t\t        index_group,\n\t\t\tinclude_online_payment\n\t\t)\n\tVALUES\n\t\t(\n\t\t\t:domain_id,\n\t\t\t:description,\n\t\t\t:currency_sign,\n\t\t\t:currency_code,\n\t\t\t:heading,\n\t\t\t:wording,\n\t\t\t:detail_heading,\n\t\t\t:detail_line,\n\t\t\t:payment_method,\n\t\t\t:payment_line1_name,\n\t\t\t:payment_line1_value,\n\t\t\t:payment_line2_name,\n\t\t\t:payment_line2_value,\n\t\t\t:enabled,\n            :status,\n            :locale,\n            :language,\n            :index_group,\n\t\t\t:include_online_payment\n\t\t )";
    if (dbQuery($sql, ':domain_id', $auth_session->domain_id, ':description', $_POST['p_description'], ':currency_sign', $_POST['p_currency_sign'], ':currency_code', $_POST['currency_code'], ':heading', $_POST['p_inv_heading'], ':wording', $_POST['p_inv_wording'], ':detail_heading', $_POST['p_inv_detail_heading'], ':detail_line', $_POST['p_inv_detail_line'], ':payment_method', $_POST['p_inv_payment_method'], ':payment_line1_name', $_POST['p_inv_payment_line1_name'], ':payment_line1_value', $_POST['p_inv_payment_line1_value'], ':payment_line2_name', $_POST['p_inv_payment_line2_name'], ':payment_line2_value', $_POST['p_inv_payment_line2_value'], ':status', $_POST['status'], ':locale', $_POST['locale'], ':language', $_POST['locale'], ':index_group', empty($_POST['index_group']) ? lastInsertId() : $_POST['index_group'], ':include_online_payment', $include_online_payment, ':enabled', $_POST['pref_enabled'])) {
        $saved = true;
        if (empty($_POST['index_group'])) {
            $sql_update = "UPDATE\n                    " . TB_PREFIX . "preferences\n                SET\n                    index_group = :index_group\n                WHERE \n                    pref_id = :pref_id\n            ";
            dbQuery($sql_update, ':index_group', lastInsertId(), ':pref_id', lastInsertId());
        }
        //$display_block = $LANG['save_preference_success'];
    } else {
        $saved = false;
        //$display_block =  $LANG['save_preference_failure'];
    }
    //header( 'refresh: 2; url=manage_preferences.php' );
} else {
    if ($op === 'edit_preference') {
        if (isset($_POST['save_preference'])) {
            $sql = "UPDATE\n\t\t\t\t" . TB_PREFIX . "preferences\n\t\t\tSET\n\t\t\t\tpref_description = :description,\n\t\t\t\tpref_currency_sign = :currency_sign,\n\t\t\t\tcurrency_code = :currency_code,\n\t\t\t\tpref_inv_heading = :heading,\n\t\t\t\tpref_inv_wording = :wording,\n\t\t\t\tpref_inv_detail_heading = :detail_heading,\n\t\t\t\tpref_inv_detail_line = :detail_line,\n\t\t\t\tpref_inv_payment_method = :payment_method,\n\t\t\t\tpref_inv_payment_line1_name = :line1_name,\n\t\t\t\tpref_inv_payment_line1_value = :line1_value,\n\t\t\t\tpref_inv_payment_line2_name = :line2_name,\n\t\t\t\tpref_inv_payment_line2_value = :line2_value,\n\t\t\t\tpref_enabled = :enabled,\n\t\t\t\tstatus = :status,\n\t\t\t\tlocale = :locale,\n\t\t\t\tlanguage = :language,\n \t\t        index_group = :index_group,\n \t\t        include_online_payment = :include_online_payment\n\t\t\tWHERE\n\t\t\t\tpref_id = :id";
            if (dbQuery($sql, ':description', $_POST['pref_description'], ':currency_sign', $_POST['pref_currency_sign'], ':currency_code', $_POST['currency_code'], ':heading', $_POST['pref_inv_heading'], ':wording', $_POST['pref_inv_wording'], ':detail_heading', $_POST['pref_inv_detail_heading'], ':detail_line', $_POST['pref_inv_detail_line'], ':payment_method', $_POST['pref_inv_payment_method'], ':line1_name', $_POST['pref_inv_payment_line1_name'], ':line1_value', $_POST['pref_inv_payment_line1_value'], ':line2_name', $_POST['pref_inv_payment_line2_name'], ':line2_value', $_POST['pref_inv_payment_line2_value'], ':enabled', $_POST['pref_enabled'], ':status', $_POST['status'], ':locale', $_POST['locale'], ':language', $_POST['language'], ':index_group', $_POST['index_group'], ':include_online_payment', $include_online_payment, ':id', $_GET['id'])) {
                $saved = true;
                //	$display_block = $LANG['save_preference_success'];
            } else {
function convertInitCustomFields()
{
    // This function is exactly the same as convertCustomFields() in ./include/customFieldConversion.php but without the print_r and echo output while storing
    /* check if any value set -> keeps all data for sure */
    global $dbh;
    $db = new db();
    $sql = "SELECT * FROM " . TB_PREFIX . "custom_fields";
    $sth = $dbh->prepare($sql);
    $sth->execute();
    while ($custom = $sth->fetch()) {
        if (preg_match("/(.+)_cf([1-4])/", $custom['cf_custom_field'], $match)) {
            //print_r($match);
            switch ($match[1]) {
                case "biller":
                    $cat = 1;
                    break;
                case "customer":
                    $cat = 2;
                    break;
                case "product":
                    $cat = 3;
                    break;
                case "invoice":
                    $cat = 4;
                    break;
                default:
                    $case = 0;
            }
            $cf_field = "custom_field" . $match[2];
            if ($match[1] != "biller") {
                $sql = "SELECT id, :field FROM :table";
                $tablename = TB_PREFIX . $match[1] . "s";
            } else {
                $sql = "SELECT id, :field FROM :table";
                $tablename = TB_PREFIX . $match[1];
            }
            $store = false;
            /*
             * If custom field name is set
             */
            if ($custom['cf_custom_label'] != NULL) {
                $store = true;
            }
            //error_log($sql);
            $tth = $dbh->prepare($sql);
            $tth->bindValue(':table', $tablename);
            $tth->bindValue(':field', $cf_field);
            $tth->execute();
            /*
             * If any field is set, create custom field
             */
            while ($res = $tth->fetch()) {
                if ($res[1] != NULL) {
                    $store = true;
                    break;
                }
                //echo($res[0]."<br />");
            }
            if ($store) {
                //				print_r($res);
                //				echo "<br />".$sql."   ".$res['id'];
                //create new text custom field
                saveInitCustomField(3, $cat, $custom['cf_custom_field'], $custom['cf_custom_label']);
                $id = lastInsertId();
                error_log($id);
                $plugin = getPluginById(3);
                $plugin->setFieldId($id);
                //insert all data
                $uth = $dbh->prepare($sql);
                $uth->bindValue(':table', $tablename);
                $uth->bindValue(':field', $cf_field);
                $uth->execute();
                while ($res2 = $uth->fetch()) {
                    $plugin->saveInput($res2[$cf_field], $res2['id']);
                }
            }
        }
    }
}
Esempio n. 6
0
        'default_tax_id'    => $_POST['default_tax_id'],
        'default_tax_id_2'  => NULL,
        'cost'              => $_POST['cost'],
        'reorder_level'     => $_POST['reoder_level'],
        'custom_field1'     => $_POST['custom_field1'],
        'custom_field2'     => $_POST['custom_field2'],
        'custom_field3'     => $_POST['custom_field3'],
        'custom_field4'     => $_POST['custom_field4'],
        'notes'             => $_POST['notes'],
        'enabled'           => 1,
        'visible'           => 1
    );
	if($id = $SI_PRODUCTS->insert($data)) {
		$product_id = $SI_PRODUCTS->getLastInsertId();
 		$saved = true;
 		saveCustomFieldValues($_POST['categorie'], lastInsertId());
 	}
 	

 	$i = 1;
 	while ($i <= 3 )
 	{
 		if(!empty($_POST['attribute_'.$i]))
 		{
	 		$sql = "INSERT into
				".TB_PREFIX."products_matrix
			VALUES
				(
					NULL,
					:product_id,
					:product_attribute_number,
Esempio n. 7
0
 function onNewEntry($workflow, $args)
 {
     $categoriesArray = explode(',', $workflow->category);
     $entry = $args[0];
     if (!in_array($entry->cat_id, $categoriesArray)) {
         return false;
     }
     //Check to see if this a new Article or an old one being modified
     $id = JRequest::getInt('id', 0, 'post');
     //Create History Entry
     require_once JWF_BACKEND_PATH . DS . 'models' . DS . 'history.php';
     require_once JWF_BACKEND_PATH . DS . 'models' . DS . 'item.php';
     $historyModel = new JWFModelHistory();
     $itemModel = new JWFModelItem();
     if ($id == 0) {
         $historyTitle = JText::_('New Item Created');
         $historyMsg = new stdClass();
         $historyMsg->type = 'create';
         $historyMsg->title = $_POST['title'];
         $historyMsg->version = 0;
         $historyItemId = lastInsertId();
         $currentStation = reset($workflow->stations);
         //First station
     } else {
         $historyTitle = JText::_('Item modified');
         $historyMsg = new stdClass();
         $historyMsg->type = 'modify';
         $historyMsg->title = $_POST['title'];
         $historyMsg->version = $this->getLatestRevisionId($id);
         $historyItemId = $id;
         $stationId = $itemModel->getCurrentStationId($workflow->id, $id);
         $currentStation = $workflow->stations[$stationId];
     }
     if ($currentStation != null) {
         $historyModel->add($workflow->id, $currentStation, $historyItemId, 'component.content', $historyTitle, $historyMsg);
     }
     //Done creating history entry
     //Exit if this is an old one
     if ($id != 0) {
         return false;
     }
     $firstStation = reset($workflow->stations);
     $db =& JFactory::getDBO();
     $sql = "UPDATE #__aards_ads a SET a.published=0 WHERE a.id  = {$id}";
     $db->setQuery($sql);
     $db->query();
     return $itemModel->enter($workflow->id, $firstStation->id, $entry->id, $entry->ad_name, 0);
 }
Esempio n. 8
0
	public function insert_item()
	{

        global $LANG;

        $tax_total = getTaxesPerLineItem($this->line_item_tax_id,$this->quantity, $this->unit_price);

        //line item gross total
        $gross_total = $this->unit_price * $this->quantity;

        //line item total
        $total = $gross_total + $tax_total;

        //Remove jquery auto-fill description - refer jquery.conf.js.tpl autofill section
        if ($this->description == $LANG['description'])
        {
            $this->description ="";
        }

        if ($db_server == 'mysql' && !_invoice_items_check_fk(
            $invoice_id, $product_id, $tax['tax_id'])) {
            return null;
        }

		$sql = "INSERT INTO ".TB_PREFIX."invoice_items
				(
					invoice_id,
					quantity,
					product_id,
					unit_price,
					tax_amount,
					gross_total,
					description,
					total
				)
				VALUES
				(
					:invoice_id,
					:quantity,
					:product_id,
					:unit_price,
					:tax_amount,
					:gross_total,
					:description,
					:total
				)";

		//echo $sql;
		dbQuery($sql,
			':invoice_id', $this->invoice_id,
			':quantity', $this->quantity,
			':product_id', $this->product_id,
			':unit_price', $this->unit_price,
		//	':tax_id', $tax[tax_id],
		//	':tax_percentage', $tax[tax_percentage],
            ':tax_amount', $tax_total,
            ':gross_total', $gross_total,
            ':description', $this->description,
            ':total', $total

			);

		invoice_item_tax(lastInsertId(),$this->tax,$this->unit_price,$this->quantity,"insert");

        return true;
	}
Esempio n. 9
0
function updateInvoiceItem($id, $quantity, $product_id, $line_number, $line_item_tax_id, $description, $unit_price)
{
    global $logger;
    global $LANG;
    //$product = getProduct($product_id);
    //$tax = getTaxRate($tax_id);
    $tax_total = getTaxesPerLineItem($line_item_tax_id, $quantity, $unit_price);
    $logger->log('Invoice: ' . $invoice_id . ' Tax ' . $line_item_tax_id . ' for line item ' . $line_number . ': ' . $tax_total, Zend_Log::INFO);
    $logger->log('Description: ' . $description, Zend_Log::INFO);
    $logger->log(' ', Zend_Log::INFO);
    //line item gross total
    $gross_total = $unit_price * $quantity;
    //line item total
    $total = $gross_total + $tax_total;
    //Remove jquery auto-fill description - refer jquery.conf.js.tpl autofill section
    if ($description == $LANG['description']) {
        $description = "";
    }
    if ($db_server == 'mysql' && !_invoice_items_check_fk(null, $product_id, $tax_id, 'update')) {
        return null;
    }
    $sql = "UPDATE " . TB_PREFIX . "invoice_items \n\tSET quantity =  :quantity,\n\tproduct_id = :product_id,\n\tunit_price = :unit_price,\n\ttax_amount = :tax_amount,\n\tgross_total = :gross_total,\n\tdescription = :description,\n\ttotal = :total\t\t\t\n\tWHERE id = :id";
    //echo $sql;
    dbQuery($sql, ':quantity', $quantity, ':product_id', $product_id, ':unit_price', $unit_price, ':tax_amount', $tax_total, ':gross_total', $gross_total, ':description', $description, ':total', $total, ':id', $id);
    //if from a new invoice item in the edit page user lastInsertId()
    $id == null ? $id = lastInsertId() : ($id = $id);
    invoice_item_tax($id, $line_item_tax_id, $unit_price, $quantity, "update");
    return true;
}
Esempio n. 10
0
}
$saved = false;
$type = $_POST['type'];
if ($_POST['action'] == "insert") {
    if (insertInvoice($type)) {
        $id = lastInsertId();
        //saveCustomFieldValues($_POST['categorie'],$invoice_id);
        $saved = true;
    }
    /*
     * 1 = Total Invoices
     */
    if ($type == total_invoice && $saved) {
        $logger->log('Total style invoice created, ID: ' . $id, Zend_Log::INFO);
        insertProduct(0, 0);
        $product_id = lastInsertId();
        if (insertInvoiceItem($id, 1, $product_id, 1, $_POST['tax_id'][0], $_POST['description'], $_POST['unit_price'])) {
            //$saved = true;
        } else {
            die(end($dbh->errorInfo()));
        }
    } elseif ($saved) {
        $logger->log('Max items:' . $_POST['max_items'], Zend_Log::INFO);
        $i = 0;
        while ($i <= $_POST['max_items']) {
            $logger->log('i=' . $i, Zend_Log::INFO);
            $logger->log('qty=' . $_POST["quantity{$i}"], Zend_Log::INFO);
            if ($_POST["quantity{$i}"] != null) {
                if (insertInvoiceItem($id, $_POST["quantity{$i}"], $_POST["products{$i}"], $i, $_POST["tax_id"][$i], $_POST["description{$i}"], $_POST["unit_price{$i}"])) {
                    //			insert_invoice_item_tax(lastInsertId(), )
                    //$saved = true;
Esempio n. 11
0
    /*
     * 1 = Total Invoices
     */
    if ($type == 1 && $saved) {
        insertProduct(0, 0);
        $product_id = lastInsertId();
        if (matrix_invoice::insertInvoiceItem($invoice_id, 1, $product_id, $_POST['tax_id'], $_POST['description'])) {
            //$saved = true;
        } else {
            die(end($dbh->errorInfo()));
        }
    } elseif ($saved) {
        for ($i = 0; !empty($_POST["quantity{$i}"]) && $i < $_POST['max_items']; $i++) {
            if ($type == 4) {
                insertProductComplete(0, 0, $_POST["description{$i}"], $_POST["price{$i}"], NULL, NULL, NULL, NULL, $_POST["notes{$i}"]);
                $product = lastInsertId();
            } else {
                $product = $_POST["products{$i}"];
            }
            if (matrix_invoice::insertInvoiceItem($invoice_id, $_POST["quantity{$i}"], $product, $_POST['tax_id'], $_POST["description{$i}"], $_POST["attr1-{$i}"], $_POST["attr2-{$i}"], $_POST["attr3-{$i}"], $_POST["unit_price{$i}"])) {
                //$saved = true;
            } else {
                die(end($dbh->errorInfo()));
            }
        }
    }
} elseif ($_POST['action'] == "edit") {
    //Get type id - so do add into redirector header
    $invoice_id = $_POST['invoice_id'];
    if (updateInvoice($_POST['invoice_id'])) {
        updateCustomFieldValues($_POST['categorie'], $_POST['invoice_id']);
Esempio n. 12
0
	  ':enabled', $_POST['pref_enabled']
	  )) {
		$saved = true;

        if (empty($_POST['index_group']))
        {
            $sql_update = "UPDATE
                    ".TB_PREFIX."preferences
                SET
                    index_group = :index_group
                WHERE
                    pref_id = :pref_id
            ";
            dbQuery($sql_update,
                ':index_group',lastInsertId(),
                ':pref_id',lastInsertId()
            );
		}
        //$display_block = $LANG['save_preference_success'];
	} ELSE {
		$saved = false;
		//$display_block =  $LANG['save_preference_failure'];
	}
	//header( 'refresh: 2; url=manage_preferences.php' );

}

#edit preference

else if (  $op === 'edit_preference' ) {
Esempio n. 13
0
/**
 * @post store
 */
function store_post_controller()
{
    __is_guest();
    if (!empty($_POST)) {
        if (checked_token($_POST['_token'])) {
            __session_start();
            $_SESSION['old'] = [];
            $_SESSION['errors'] = [];
            $rules = ['title' => FILTER_SANITIZE_STRING, 'content' => FILTER_SANITIZE_STRING, 'status' => ['filter' => FILTER_CALLBACK, 'options' => function ($s) {
                if (in_array($s, ['published', 'unpublished'])) {
                    return $s;
                } else {
                    return 'unpublished';
                }
            }], 'published_at' => ['filter' => FILTER_CALLBACK, 'options' => function ($checkbox) {
                if ($checkbox == 'yes') {
                    return new DateTime('now');
                }
            }]];
            $sanitize = filter_input_array(INPUT_POST, $rules);
            // test if errors
            if (empty($_POST['title'])) {
                $_SESSION['errors']['title'] = trans('title', 'required');
            }
            if (!empty($_SESSION['errors'])) {
                $_SESSION['old'] = $sanitize;
                redirect('post/create');
            }
            if (is_uploaded_file($_FILES['file']['tmp_name'])) {
                try {
                    $dateFile = upload($_FILES['file']);
                    beginTransaction();
                    create_post_model($sanitize);
                    $post_id = lastInsertId();
                    create_media_model(['filename' => $dateFile['filename'], 'post_id' => $post_id, 'size' => $dateFile['size']]);
                    commit();
                    setFlashMessage("success stored");
                    redirect('dashboard');
                } catch (Exception $e) {
                    if ($e instanceof RuntimeException) {
                        $_SESSION['old'] = $sanitize;
                        $_SESSION['errors']['upload'] = $e->getMessage();
                        redirect('post/create');
                    }
                    rollback();
                    $_SESSION['old'] = $sanitize;
                    $_SESSION['errors']['file'] = $e->getMessage();
                    redirect('post/create');
                }
            } else {
                create_post_model($sanitize);
                setFlashMessage(trans('success_post_updated', 'post'));
                redirect('dashboard');
            }
        }
    }
    throw new RuntimeException('418');
}
Esempio n. 14
0
    public static function save()
    {

        global $auth_session;
        global $logger;
        global $db;
        
        $sql = "INSERT into
            ".TB_PREFIX."expense
            (
                domain_id,
                amount,
                expense_account_id,
                biller_id,
                customer_id,
                invoice_id,
                product_id,
                date,
                status,
                note
            )
        VALUES
            (	
                :domain_id,
                :amount,
                :expense_account_id,
                :biller_id,
                :customer_id,
                :invoice_id,
                :product_id,
                :date,
                :status,
                :note
            )";

        dbQuery($sql,
            ':domain_id',$auth_session->domain_id,	
            ':amount', $_POST['amount'],
            ':expense_account_id', $_POST['expense_account_id'],
            ':biller_id', $_POST['biller_id'],
            ':invoice_id', $_POST['invoice_id'],
            ':product_id', $_POST['product_id'],
            ':customer_id', $_POST['customer_id'],
            ':date', $_POST['date'],
            ':status', $_POST['status'],
            ':note', $_POST['note']
            );
	

        $logger->log("Exp ITEM tax- last insert ID-".lastInsertId(), Zend_Log::INFO);
        expense::expense_item_tax(lastInsertId(),$_POST['tax_id'][0],$_POST['amount'],"1","insert");

        return true;
    }
Esempio n. 15
0
 /**
  * Stores a Workflow to database
  *
  * @access	public
  * @param object $data Workflow Data to be saved 
  * @return int	ID of the newly saved workflow on success , 0 on failure
  */
 function save($data)
 {
     $user =& JFactory::getUser();
     $db =& JFactory::getDBO();
     $row =& JTable::getInstance('Workflow', 'Table');
     $nullDate = $db->getNullDate();
     if (!$row->bind($data)) {
         JError::raiseError(500, $db->stderr());
         return 0;
     }
     $row->id = intval($row->id);
     JArrayHelper::toInteger($data['category']);
     $row->category = implode(',', $data['category']);
     $newEntry = $row->id ? false : true;
     //Copied directly from com_content saveContent()
     // Are we saving from an item edit?
     if (!$newEntry) {
         $datenow =& JFactory::getDate();
         $row->modified = $datenow->toMySQL();
         $row->modified_by = $user->get('id');
     }
     $row->created_by = $row->created_by ? $row->created_by : $user->get('id');
     if ($row->created && strlen(trim($row->created)) <= 10) {
         $row->created .= ' 00:00:00';
     }
     $config =& JFactory::getConfig();
     $tzoffset = $config->getValue('config.offset');
     $date =& JFactory::getDate($row->created, $tzoffset);
     $row->created = $date->toMySQL();
     if (strlen(trim($row->publish_up)) == 0) {
         $date =& JFactory::getDate(1, $tzoffset);
     } else {
         $row->publish_up .= ' 00:00:00';
         $date =& JFactory::getDate($row->publish_up, $tzoffset);
     }
     $row->publish_up = $date->toMySQL();
     // Handle never unpublish date
     if (trim($row->publish_down) == JText::_('Never') || trim($row->publish_down) == '') {
         $row->publish_down = $nullDate;
     } else {
         if (strlen(trim($row->publish_down)) <= 10) {
             $row->publish_down .= ' 00:00:00';
         }
         $date =& JFactory::getDate($row->publish_down, $tzoffset);
         $row->publish_down = $date->toMySQL();
     }
     // Make sure the data is valid
     if (!$row->check()) {
         JError::raiseError(500, $db->stderr());
     }
     // Store the content to the database
     if (!$row->store()) {
         JError::raiseError(500, $db->stderr());
     }
     // Check the form
     $row->checkin();
     //End of faithful copy
     if ($newEntry) {
         $row->id = lastInsertId();
     }
     if (!$newEntry) {
         //Delete stations of this workflow
         $db->setQuery('DELETE FROM #__jwf_stations WHERE wid=' . $row->id);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
         }
     }
     $queriesNewId = array();
     $queriesOldId = array();
     foreach ($data['stations'] as $station) {
         $wid = intval($row->id);
         $title = $db->getEscaped($station->title, true);
         $task = $db->getEscaped($station->task, true);
         $allocatedTime = intval($station->allocatedTime);
         $group = intval($station->acl->id);
         $fields = $db->getEscaped($station->fields, true);
         $hooks = $station->activeHooks;
         $validations = $db->getEscaped($station->activeValidations, true);
         $order = intval($station->order);
         if ($station->id == null) {
             $queriesNewId[] = "({$wid}, '{$title}', '{$task}', {$allocatedTime}, {$group}, '{$fields}' , '{$hooks}', '{$validations}', {$order})";
         } else {
             $queriesOldId[] = "({$station->id}, {$wid}, '{$title}', '{$task}', {$allocatedTime}, {$group}, '{$fields}', '{$hooks}', '{$validations}', {$order})";
         }
     }
     if (count($queriesNewId)) {
         $sqlNewIds = implode(',', $queriesNewId);
         $sqlNewIds = 'INSERT INTO `#__jwf_stations` (`wid`,`title`,`task`,`allocatedTime`,`group`,`fields`, `activeHooks`, `activeValidations`,  `order`) VALUES ' . $sqlNewIds;
         $db->setQuery($sqlNewIds);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
         }
     }
     if (count($queriesOldId)) {
         $sqlOldIds = implode(',', $queriesOldId);
         $sqlOldIds = 'INSERT INTO `#__jwf_stations` (`id`,`wid`,`title`,`task`,`allocatedTime`,`group`,`fields`,`activeHooks`, `activeValidations`, `order`) VALUES ' . $sqlOldIds;
         $db->setQuery($sqlOldIds);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
         }
     }
     //Update trigger cache
     $pManager =& getPluginManager();
     $pManager->loadPlugins('component');
     $plugins = $pManager->settings['component'];
     $trigger = $plugins[$row->component]->trigger;
     $category = $row->category;
     $component = $row->component;
     $triggerDataPath = JWF_FS_PATH . DS . 'triggerCache.ini';
     $triggerCacheData = new JRegistry();
     $triggerCacheData->loadINI(file_get_contents($triggerDataPath));
     $triggerCacheData->setValue($row->id, $trigger . '-' . $component . '-' . $category);
     file_put_contents($triggerDataPath, $triggerCacheData->toString('INI'));
     return $row->id;
 }
 private function ajouter()
 {
     global $cache;
     if (!isset($_SESSION['id'])) {
         exit;
     }
     if ($this->datas['id_principal'] == -1) {
         exit('Pas d\'ID');
     }
     if ($this->datas['lectureSeule'] == true) {
         make_redirection(redirect('L\'ajout de commentaires est verrouillé.', 100, URL, 2));
     }
     $id_module = intval($this->datas['id_principal']);
     $contenu = XTCode_encode($_POST['comm_contenu']);
     $this->bdd->query('INSERT INTO ' . $this->table . '(id_module, auteur, contenu, timestamp) VALUES(?, ?, ?, ?)', array($id_module, intval($_SESSION['id']), $contenu, time()));
     if ($this->module == 'taches') {
         $dests = $this->bdd->fetch($this->bdd->query('SELECT assignee FROM ' . TABLE_TACHES . ' WHERE id = ?', $id_module));
         //if( $dests['assignee'] > 1 && $dests['assignee'] != $_SESSION['id'] )
         //     addMp( $dests['assignee'], 'Nouveau commentaire sur le panel des tâches', '<paragraphe>Nouveau commentaire sur la <lien vers="'.RACINE.'developpeurs/taches-'.$id_module.'-commenter.html">tâche #'.$id_module.'</lien><paragraphe>', true );
     }
     $idCom = lastInsertId();
     $error = redirect('Le commentaire a bien été posté.', 5, URL, 1);
     // $cache->deleteIDCache( $id_module, 'contents', 'nbComs' . ucfirst( $this->module ) );
     make_redirection($error);
 }