Files
crm.e5.pl/modules/EcmStockDocIns/SaveCorrect.php

78 lines
4.0 KiB
PHP
Raw Normal View History

2024-04-27 09:23:34 +02:00
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*****************************************************************************
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
* Version 1.1 ("License"); You may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/rpl.php. Software distributed under the
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
* either express or implied.
*
* You may:
* a) Use and distribute this code exactly as you received without payment or
* a royalty or other fee.
* b) Create extensions for this code, provided that you make the extensions
* publicly available and document your modifications clearly.
* c) Charge for a fee for warranty or support or for accepting liability
* obligations for your customers.
*
* You may NOT:
* a) Charge for the use of the original code or extensions, including in
* electronic distribution models, such as ASP (Application Service
* Provider).
* b) Charge for the original source code or your extensions other than a
* nominal fee to cover distribution costs where such distribution
* involves PHYSICAL media.
* c) Modify or delete any pre-existing copyright notices, change notices,
* or License text in the Licensed Software
* d) Assert any patent claims against the Licensor or Contributors, or
* which would in any way restrict the ability of any third party to use the
* Licensed Software.
*
* You must:
* a) Document any modifications you make to this code including the nature of
* the change, the authors of the change, and the date of the change.
* b) Make the source code for any extensions you deploy available via an
* Electronic Distribution Mechanism such as FTP or HTTP download.
* c) Notify the licensor of the availability of source code to your extensions
* and include instructions on how to acquire the source code and updates.
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
* reproduce, perform, modify, sublicense, and distribute your extensions.
*
* The Original Code is: CommuniCore
* Olavo Farias
* 2006-04-7 olavo.farias@gmail.com
*
* The Initial Developer of the Original Code is CommuniCore.
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
* All Rights Reserved.
********************************************************************************/
require_once("modules/EcmStockDocIns/EcmStockDocIn.php");
require_once('include/formbase.php');
$focus = new EcmStockDocIn();
$focus->retrieve($_GET['correct_id']);
$n=new EcmStockDocIn();
$arr=array("name","desciption","parent_id","type","status","register_date","validtill_date","parent_contact_name","parent_contact_title","parent_address_street","parent_address_city","parent_address_postalcode","parent_address_country","subtotal","total","discount","to_vatid","ecmlanguage","to_is_vat_free","header_text","footer_text","ads_text","template_id","template_name","contact_id","accepted","email_id","order_origin","show_images_on_offers","stock_id","pdflanguages","assigned_user_id");
foreach($arr as $f){
$n->$f=$focus->$f;
}
$n->position_list=$focus->getPositionList(true);
$n->type="1";
$n->correct_id=$_GET['correct_id'];
$return_id=$n->saveCorrect();
$ww=$GLOBALS['db']->query("select id from ecmstockdocinitems where ecmstockdocin_id='".$_GET['correct_id']."' and deleted='0'");
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
$w=$GLOBALS['db']->query("select * from ecmstockoperations where parent_type='EcmStockDocIns' and parent_id='".$_GET['correct_id']."' and documentitem_id='".$rr['id']."'");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$focus->addProductToStockOut($r['id'],$r['product_id'],$r['quantity'],$r['price'],date("Y-m-d H:i:s"),$return_id,$n->stock_id,$rr['id']);
}
}
header("Location: index.php?module=EcmStockDocIns&action=DetailView&record=".$return_id);
?>