init
This commit is contained in:
214
modules/EcmStockStates/CreateXLS.php
Executable file
214
modules/EcmStockStates/CreateXLS.php
Executable file
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
if(!$_GET['date'])$date=date("Y-m-d");
|
||||
else $date=$GLOBALS['timedate']->to_db_date($_GET['date']);
|
||||
$exp=explode("-",$date);
|
||||
$date=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
|
||||
if(!$date)$date=date("Y-m-d");
|
||||
include_once("modules/EcmProductReports/vtigerConnector.php");
|
||||
include_once('modules/EcmCharts/chartHelper.php');
|
||||
$vc=new vtigerConnector();
|
||||
set_include_path('include/PHPExcel/');
|
||||
|
||||
include 'PHPExcel.php';
|
||||
//include 'PHPExcel/Writer/Excel2007.php';
|
||||
include 'PHPExcel/Writer/Excel5.php';
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
$objPHPExcel = new PHPExcel();
|
||||
$objPHPExcel->getProperties()->setCreator("E5 CRM");
|
||||
$objPHPExcel->getProperties()->setLastModifiedBy("E5 CRM");
|
||||
$objPHPExcel->getProperties()->setTitle("Office 2007 STATES");
|
||||
$objPHPExcel->getProperties()->setSubject("Office 2007 STATES");
|
||||
$objPHPExcel->getProperties()->setDescription("STATES");
|
||||
|
||||
$alf="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(10);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(20);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(20);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20);
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
if($date==date("Y-m-d",mktime()+24*3600))$dat=date("Y-m-d H:i:s");
|
||||
else $dat=$date." 23:59:59";
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("A1","Inventory states: ".$dat);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("A2","Index");
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("B2","Name");
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("C2","Category");
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("D2","Quantity");
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("E2","Price");
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("F2","Value");
|
||||
|
||||
$i=3;
|
||||
|
||||
//$wh[]="product_active='1'";
|
||||
foreach($_REQUEST['check'] as $ch){
|
||||
$whk[]="id='".$ch."'";
|
||||
}
|
||||
if(count($whk)>0)$wh[]="(".implode(" or ",$whk).")";
|
||||
|
||||
$wh[]="deleted='0'";
|
||||
if($_REQUEST['category_id'])$wh[]="product_category_id='".$_REQUEST['category_id']."'";
|
||||
if($_REQUEST['active']=="active")$wh[]="product_active='1'";
|
||||
if($_REQUEST['active']=="inactive")$wh[]="product_active='0'";
|
||||
|
||||
$who[]="deleted='0'";
|
||||
if($date)$who[]="date_entered<='".$date." 23:59:59'";
|
||||
if($_REQUEST['stock_id'])$who[]="stock_id='".$_REQUEST['stock_id']."'";
|
||||
|
||||
$where=implode(" and ",$wh);
|
||||
|
||||
$z="select id,name,code,product_category_name from ecmproducts where ".$where." order by code asc, name asc";
|
||||
//echo $z;
|
||||
$w=mysql_query($z);
|
||||
echo mysql_error();
|
||||
$sum_qty=0;
|
||||
$sum_price=0;
|
||||
while($r=mysql_fetch_array($w)){
|
||||
$value=0;
|
||||
$qty=0;
|
||||
$price=0;
|
||||
if($date!=date("Y-m-d",mktime()+24*3600)){
|
||||
$arr=array();
|
||||
$pp1=0;
|
||||
$q1=0;
|
||||
$ww=$GLOBALS['db']->query("select quantity as qty,id,price from ecmstockoperations where deleted='0' and type='0' and in_id IS NULL and product_id='".$r['id']."' and (".implode(" and ",$who).")");
|
||||
while($rrr=$GLOBALS['db']->fetchByAssoc($ww)){
|
||||
$www=$GLOBALS['db']->query("select quantity from ecmstockoperations where in_id='".$rrr['id']."' and type='1' and in_id IS NOT NULL and product_id='".$r['id']."' and (".implode(" and ",$who).") and deleted='0'");
|
||||
$rqty=0;
|
||||
while($rrp=$GLOBALS['db']->fetchByAssoc($www)){
|
||||
$rqty+=$rrp['quantity'];
|
||||
}
|
||||
$qty=$rrr['qty']-$rqty;
|
||||
if($qty>0){
|
||||
$arr[]=array("qty"=>$qty,"id"=>$rrr['id'],"price"=>$rrr['price']);
|
||||
}
|
||||
}
|
||||
|
||||
if(count($arr)>0){
|
||||
foreach($arr as $v){
|
||||
$q1+=$v['qty'];
|
||||
$pp1+=$v['qty']*$v['price'];
|
||||
}
|
||||
}
|
||||
$qty=$q1;
|
||||
$value=$pp1;
|
||||
|
||||
@$price=$value/$qty;
|
||||
}
|
||||
else{
|
||||
$whs=array();
|
||||
$whs[]="deleted='0'";
|
||||
$whs[]="product_id='".$r['id']."'";
|
||||
if($_GET['stock_id'])$whs[]="stock_id='".$_GET['stock_id']."'";
|
||||
$whes=implode(" and ",$whs);
|
||||
$wss=mysql_query("select quantity,price from ecmstockstates where ".$whes);
|
||||
while($rss=mysql_fetch_array($wss)){
|
||||
$qty+=$rss['quantity'];
|
||||
@$value+=$rss['quantity']*$rss['price'];
|
||||
|
||||
}
|
||||
@$price=$value/$qty;
|
||||
}
|
||||
$r['qty']=$qty;
|
||||
$r['price']=$price;
|
||||
$r['value']=$value;
|
||||
$arr[]=array(
|
||||
"id"=>$r['id'],
|
||||
"qty"=>$qty,
|
||||
"code"=>$r['code'],
|
||||
"name"=>$r['name'],
|
||||
"product_category_id"=>$r['product_category_id'],
|
||||
"product_category_name"=>$r['product_category_name'],
|
||||
"price"=>$price,
|
||||
"value"=>$value,
|
||||
);
|
||||
//}
|
||||
|
||||
//if(!$_REQUEST['order_by'])$_REQUEST['order_by']="code";
|
||||
//if(!$_REQUEST['sorder'])$_REQUEST['sorder']="asc";
|
||||
//$arr=multisort($arr,array(array('key'=>$_REQUEST['order_by'],'sort'=>$_REQUEST['sorder'])));
|
||||
|
||||
//if(count($arr)>0){
|
||||
//foreach($arr as $r){
|
||||
if($_REQUEST['empty']=="yes" && $qty==0)continue;
|
||||
if($_REQUEST['empty']=="no" && $qty!=0)continue;
|
||||
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("A".$i,$r['code']);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("B".$i,$r['name']);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("C".$i,$r['product_category_name']);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("D".$i,$r['qty']);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("E".$i,$r['price']);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("F".$i,$r['value']);
|
||||
|
||||
|
||||
$sum_qty+=$r['qty'];
|
||||
$sum_price+=$r['value'];
|
||||
|
||||
$i++;
|
||||
//}
|
||||
}
|
||||
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("D".$i,$sum_qty);
|
||||
@$objPHPExcel->getActiveSheet()->SetCellValue("E".$i,$sum_price/$sum_qty);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("F".$i,$sum_price);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
|
||||
array(
|
||||
'fill' => array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'color' => array('argb' => 'F0F0F0')
|
||||
),
|
||||
'borders' => array(
|
||||
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
|
||||
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
|
||||
)
|
||||
),
|
||||
"A1:F1"
|
||||
);
|
||||
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
|
||||
array(
|
||||
'fill' => array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'color' => array('argb' => 'F0F0F0')
|
||||
),
|
||||
'borders' => array(
|
||||
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
|
||||
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
|
||||
)
|
||||
),
|
||||
"A2:F2"
|
||||
);
|
||||
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
|
||||
array(
|
||||
'fill' => array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'color' => array('argb' => 'F0F0F0')
|
||||
),
|
||||
'borders' => array(
|
||||
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
|
||||
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
|
||||
)
|
||||
),
|
||||
"A".($i).":F".($i)
|
||||
);
|
||||
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
//$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
|
||||
chmod("cache/upload",0777);
|
||||
$microtime=str_replace(".","",str_replace(" ","",microtime()));
|
||||
$name="cache/upload/States".$microtime.".xls";
|
||||
$objWriter->save($name);
|
||||
chmod($name,0777);
|
||||
|
||||
header("Location: ".$name);
|
||||
?>
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
|
||||
|
||||
global $current_user;
|
||||
|
||||
$dashletData['MyEcmStockStatesDashlet']['searchFields'] = array('priority' => array('default' => ''),
|
||||
'status' => array('default' => array('Assigned', 'New', 'Pending')),
|
||||
'found_in_release' => array('default' => ''),
|
||||
'fixed_in_release' => array('default' => ''),
|
||||
'type' => array('default' => ''),
|
||||
'' => array('default' => ''),
|
||||
'date_entered' => array('default' => ''),
|
||||
'date_modified' => array('default' => ''),
|
||||
|
||||
|
||||
|
||||
'assigned_user_id' => array('type' => 'assigned_user_name',
|
||||
'default' => $current_user->name));
|
||||
$dashletData['MyEcmStockStatesDashlet']['columns'] = array('ecmstockstate_number' => array('width' => '5',
|
||||
'label' => 'LBL_NUMBER',
|
||||
'default' => true),
|
||||
'name' => array('width' => '40',
|
||||
'label' => 'LBL_LIST_SUBJECT',
|
||||
'link' => true,
|
||||
'default' => true),
|
||||
'priority' => array('width' => '10',
|
||||
'label' => 'LBL_PRIORITY',
|
||||
'default' => true),
|
||||
'status' => array('width' => '10',
|
||||
'label' => 'LBL_STATUS',
|
||||
'default' => true),
|
||||
'resolution' => array('width' => '15',
|
||||
'label' => 'LBL_RESOLUTION'),
|
||||
'release_name' => array('width' => '15',
|
||||
'label' => 'LBL_FOUND_IN_RELEASE',
|
||||
'related_fields' => array('found_in_release')),
|
||||
'type' => array('width' => '15',
|
||||
'label' => 'LBL_TYPE'),
|
||||
'fixed_in_release_name' => array('width' => '15',
|
||||
'label' => 'LBL_FIXED_IN_RELEASE'),
|
||||
'source' => array('width' => '15',
|
||||
'label' => 'LBL_SOURCE'),
|
||||
'date_entered' => array('width' => '15',
|
||||
'label' => 'LBL_DATE_ENTERED'),
|
||||
'date_modified' => array('width' => '15',
|
||||
'label' => 'LBL_DATE_MODIFIED'),
|
||||
'created_by' => array('width' => '8',
|
||||
'label' => 'LBL_CREATED'),
|
||||
'assigned_user_name' => array('width' => '8',
|
||||
'label' => 'LBL_LIST_ASSIGNED_USER'),
|
||||
|
||||
|
||||
|
||||
|
||||
);
|
||||
?>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
|
||||
|
||||
global $app_strings;
|
||||
|
||||
$dashletMeta['MyEcmStockStatesDashlet'] = array('module' => 'EcmStockStates',
|
||||
'title' => translate('LBL_LIST_MY_ECMSTOCKSTATES', 'EcmStockStates'),
|
||||
'description' => 'A customizable view into EcmStockStates',
|
||||
'icon' => 'themes/default/images/EcmStockStates.gif',
|
||||
'category' => 'Module Views',
|
||||
'hidden' => true);
|
||||
?>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
|
||||
|
||||
require_once('include/Dashlets/DashletGeneric.php');
|
||||
require_once('modules/EcmStockStates/EcmStockState.php');
|
||||
|
||||
class MyEcmStockStatesDashlet extends DashletGeneric {
|
||||
function MyEcmStockStatesDashlet($id, $def = null) {
|
||||
global $current_user, $app_strings;
|
||||
require('modules/EcmStockStates/Dashlets/MyEcmStockStatesDashlet/MyEcmStockStatesDashlet.data.php');
|
||||
|
||||
parent::DashletGeneric($id, $def);
|
||||
|
||||
$this->searchFields = $dashletData['MyEcmStockStatesDashlet']['searchFields'];
|
||||
$this->columns = $dashletData['MyEcmStockStatesDashlet']['columns'];
|
||||
|
||||
if(empty($def['title'])) $this->title = translate('LBL_LIST_MY_ECMSTOCKSTATES', 'EcmStockStates');
|
||||
$this->seedBean = new EcmStockState();
|
||||
}
|
||||
|
||||
function displayOptions() {
|
||||
require_once('modules/Releases/Release.php');
|
||||
$this->processDisplayOptions();
|
||||
|
||||
$seedRelease = new Release();
|
||||
|
||||
$this->currentSearchFields['fixed_in_release']['input'] = '<select multiple="true" size="3" name="fixed_in_release[]">'
|
||||
. get_select_options_with_id($seedRelease->get_releases(false, "Active"), (empty($this->filters['fixed_in_release']) ? '' : $this->filters['fixed_in_release']))
|
||||
. '</select>';
|
||||
$this->currentSearchFields['found_in_release']['input'] = '<select multiple="true" size="3" name="found_in_release[]">'
|
||||
. get_select_options_with_id($seedRelease->get_releases(false, "Active"), (empty($this->filters['found_in_release']) ? '' : $this->filters['found_in_release']))
|
||||
. '</select>';
|
||||
|
||||
$this->configureSS->assign('searchFields', $this->currentSearchFields);
|
||||
return $this->configureSS->fetch($this->configureTpl);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
36
modules/EcmStockStates/DetailView.php
Executable file
36
modules/EcmStockStates/DetailView.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings;
|
||||
|
||||
require_once('modules/EcmStockStates/EcmStockState.php');
|
||||
require_once('modules/EcmStockStates/Forms.php');
|
||||
require_once ('include/time.php');
|
||||
require_once('include/json_config.php');
|
||||
|
||||
$json_config = new json_config();
|
||||
|
||||
$focus = new EcmStockState();
|
||||
|
||||
if(isset($_REQUEST['record']))$focus->retrieve($_REQUEST['record']);
|
||||
|
||||
require_once('include/MVC/View/SugarView.php');
|
||||
|
||||
if(file_exists('modules/EcmStockStates/views/view.detail.php')) {
|
||||
require_once('modules/EcmStockStates/views/view.detail.php');
|
||||
$detail = new EcmStockState();
|
||||
}
|
||||
else{
|
||||
require_once('include/MVC/View/views/view.detail.php');
|
||||
$detail = new ViewDetail();
|
||||
$detail->ss = new Sugar_Smarty();
|
||||
$detail->module = 'EcmStockStates';
|
||||
}
|
||||
|
||||
global $app_list_strings;
|
||||
|
||||
$detail->bean = $focus;
|
||||
$detail->preDisplay();
|
||||
|
||||
echo $detail->display();
|
||||
?>
|
||||
280
modules/EcmStockStates/EcmStockState.php
Executable file
280
modules/EcmStockStates/EcmStockState.php
Executable file
@@ -0,0 +1,280 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: TODO: To be written.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
require_once('data/SugarBean.php');
|
||||
require_once('include/utils.php');
|
||||
|
||||
class EcmStockState extends SugarBean {
|
||||
var $field_name_map = array();
|
||||
|
||||
var $id;
|
||||
var $date_entered;
|
||||
var $date_modified;
|
||||
var $modified_user_id;
|
||||
var $assigned_user_id;
|
||||
var $name;
|
||||
var $stock_name;
|
||||
var $stock_id;
|
||||
var $product_code;
|
||||
var $product_name;
|
||||
var $product_id;
|
||||
var $quantity;
|
||||
|
||||
var $module_dir = 'EcmStockStates';
|
||||
var $table_name = "ecmstockstates";
|
||||
var $object_name = "EcmStockState";
|
||||
|
||||
var $new_schema = true;
|
||||
|
||||
var $additional_column_fields = array('assigned_user_name', 'assigned_user_id');
|
||||
|
||||
function EcmStockState() {
|
||||
parent::SugarBean();
|
||||
$this->setupCustomFields('EcmStockStates');
|
||||
foreach($this->field_defs as $field){
|
||||
$this->field_name_map[$field['name']] = $field;
|
||||
}
|
||||
}
|
||||
function get_summary_text(){
|
||||
return $this->name;
|
||||
}
|
||||
function create_list_query($order_by, $where, $show_deleted = 0){
|
||||
$custom_join = $this->custom_fields->getJOIN();
|
||||
$query ="SELECT ";
|
||||
$query.="ecmstockstates.*,users.user_name as assigned_user_name";
|
||||
if($custom_join)$query.=$custom_join['select'];
|
||||
$query.=" FROM ecmstockstates ";
|
||||
$query.="LEFT JOIN users ON ecmstockstates.assigned_user_id=users.id";
|
||||
$query.=" ";
|
||||
if($custom_join)$query.=$custom_join['join'];
|
||||
$where_auto='1=1';
|
||||
if($show_deleted==0)$where_auto=" $this->table_name.deleted=0 ";
|
||||
elseif($show_deleted==1)$where_auto=" $this->table_name.deleted=1 ";
|
||||
if($where!="")$query.="where $where AND ".$where_auto;
|
||||
else $query.="where ".$where_auto;
|
||||
if(substr_count($order_by,'.')>0)$query .= " ORDER BY $order_by";
|
||||
elseif($order_by != "")$query .= " ORDER BY $order_by";
|
||||
else $query .= " ORDER BY ecmstockstates.name";
|
||||
|
||||
|
||||
return $query;
|
||||
|
||||
}
|
||||
function create_export_query($order_by,$where){
|
||||
$custom_join = $this->custom_fields->getJOIN();
|
||||
$query ="SELECT ";
|
||||
$query.="ecmstockstates.*,users.user_name as assigned_user_name";
|
||||
if($custom_join)$query.=$custom_join['select'];
|
||||
$query.=" FROM ecmstockstates ";
|
||||
$query.="LEFT JOIN users ON ecmstockstates.assigned_user_id=users.id";
|
||||
$query.=" ";
|
||||
if($custom_join)$query.=$custom_join['join'];
|
||||
$where_auto='1=1';
|
||||
if($show_deleted==0)$where_auto=" $this->table_name.deleted=0 ";
|
||||
elseif($show_deleted==1)$where_auto=" $this->table_name.deleted=1 ";
|
||||
if($where!="")$query.="where $where AND ".$where_auto;
|
||||
else $query.="where ".$where_auto;
|
||||
if(substr_count($order_by,'.')>0)$query .= " ORDER BY $order_by";
|
||||
elseif($order_by != "")$query .= " ORDER BY $order_by";
|
||||
else $query .= " ORDER BY ecmstockstates.name";
|
||||
return $query;
|
||||
}
|
||||
function fill_in_additional_list_fields(){
|
||||
}
|
||||
|
||||
function fill_in_additional_detail_fields(){
|
||||
parent::fill_in_additional_detail_fields();
|
||||
}
|
||||
function UpdateStockState($stock_id,$product_id){
|
||||
|
||||
$q=0;
|
||||
$p=0;
|
||||
$i=0;
|
||||
$pp=0;
|
||||
$qq=0;
|
||||
|
||||
|
||||
$w=$GLOBALS['db']->query("select quantity as qty,id,price from ecmstockoperations where deleted='0' and type='0' and used=0 and in_id IS NULL and stock_id='".$stock_id."' and product_id='".$product_id."'");
|
||||
while($rrr=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select sum(quantity) as s from ecmstockoperations where in_id='".$rrr['id']."' and type='1' and in_id IS NOT NULL and stock_id='".$stock_id."' and product_id='".$product_id."' and deleted='0'"));
|
||||
$rqty=$rrp['s'];
|
||||
/*$ww=mysql_query("select quantity from ecmstockoperations where in_id='".$rrr['id']."' and type='1' and in_id IS NOT NULL and stock_id='".$stock_id."' and product_id='".$product_id."' and deleted='0'");
|
||||
$rqty=0;
|
||||
while($rrp=mysql_fetch_array($ww)){
|
||||
$rqty+=$rrp['quantity'];
|
||||
}*/
|
||||
$qty=$rrr['qty']-$rqty;
|
||||
if($qty>0){
|
||||
$arr[]=array("qty"=>$qty,"id"=>$rrr['id'],"price"=>$rrr['price']);
|
||||
}
|
||||
else if ($qty==0) {
|
||||
//set used = 1
|
||||
$GLOBALS['db']->query("UPDATE ecmstockoperations SET used='1' WHERE id='".$rrr['id']."'");
|
||||
}
|
||||
}
|
||||
|
||||
if(count($arr)>0){
|
||||
foreach($arr as $v){
|
||||
$q1+=$v['qty'];
|
||||
$pp1+=$v['qty']*$v['price'];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if($_REQUEST['type']=="test"){
|
||||
$w=$GLOBALS['db']->query("select quantity,price,type from ecmstockoperations where stock_id='".$stock_id."' and product_id='".$product_id."' and deleted='0'");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
if($r['type']==0){
|
||||
$q+=$r['quantity'];
|
||||
$pp+=$r['quantity']*$r['price'];
|
||||
$i++;
|
||||
}
|
||||
else{
|
||||
$q-=$r['quantity'];
|
||||
$pp-=$r['quantity']*$r['price'];
|
||||
}
|
||||
}
|
||||
if($q1!=$q){
|
||||
$rprod=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select code,name from ecmproducts where id='".$product_id."'"));
|
||||
echo $q1." == ".$q." ".$rprod['code']." ".$rprod['name']."<br>";
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if($_REQUEST['type']!="test"){
|
||||
$GLOBALS['db']->query("delete from ecmstockstates where stock_id='".$stock_id."' and product_id='".$product_id."' and deleted='0'");
|
||||
|
||||
require_once("modules/EcmStockOperations/EcmStockOperation.php");
|
||||
$o=new EcmStockState();
|
||||
$o->unformat_all_fields();
|
||||
|
||||
require_once("modules/EcmProducts/EcmProduct.php");
|
||||
$o->product_id=$product_id;
|
||||
$p=new EcmProduct();
|
||||
$p->retrieve($product_id);
|
||||
$o->product_name=$p->name;
|
||||
$o->product_code=$p->code;
|
||||
$o->product_id=$p->id;
|
||||
|
||||
require_once("modules/EcmStocks/EcmStock.php");
|
||||
$o->stock_id=$stock_id;
|
||||
$s=new EcmStock();
|
||||
$s->retrieve($stock_id);
|
||||
$o->stock_name=$s->name;
|
||||
$o->quantity=$q1;
|
||||
if($q1>0)$o->price=$pp1/$q1;
|
||||
if($p->id)$oid=$o->save();
|
||||
//if($q1>0)if($p->code=="RE00867")echo ($pp1/$q1)."<br>";
|
||||
if($q1>0)$GLOBALS['db']->query("update ecmstockstates set price='".($pp1/$q1)."' where id='".$oid."'");
|
||||
}
|
||||
|
||||
//add mz
|
||||
//update ems_price
|
||||
$GLOBALS['db']->query(
|
||||
"UPDATE ecmproducts as p
|
||||
INNER JOIN (
|
||||
SELECT round(sum(quantity*price)/sum(quantity),2) as avg_price, product_id FROM ecmstockstates GROUP BY product_id
|
||||
) s ON p.id=s.product_id
|
||||
SET p.ems_price = s.avg_price
|
||||
WHERE p.id='$product_id'"
|
||||
);
|
||||
}
|
||||
function get_list_view_data(){
|
||||
global $current_language,$current_user;
|
||||
$the_array=parent::get_list_view_data();
|
||||
$app_list_strings=return_app_list_strings_language($current_language);
|
||||
$mod_strings=return_module_language($current_language,'EcmStockStates');
|
||||
|
||||
$the_array['NAME']=(($this->name == "") ? "<em>blank</em>" : $this->name);
|
||||
$the_array['NEW_FIELD'] ='1';
|
||||
/*
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select ecmproducts.name from ecmstockstates inner join ecmproducts on ecmproducts.id=ecmstockstates.product_id"));
|
||||
$the_array['PRODUCT_NAME']=$r['name'];
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select ecmstocks.name from ecmstockstates inner join ecmstocks on ecmstocks.id=ecmstockstates.stock_id"));
|
||||
$the_array['STOCK_NAME']=$r['name'];
|
||||
|
||||
$this->retrieve($this->id);
|
||||
$dd=substr($this->parent_type,0,strlen($this->parent_type)-1);
|
||||
require_once("modules/".$this->parent_type."/".$dd.".php");
|
||||
$d=new $dd();
|
||||
$d->retrieve($this->parent_id);
|
||||
$the_array['PARENT_NAME']=$d->number;
|
||||
*/
|
||||
|
||||
|
||||
$the_array['ENCODED_NAME']=$this->name;
|
||||
return $the_array;
|
||||
}
|
||||
function build_generic_where_clause($the_query_string){
|
||||
$where_clauses=array();
|
||||
$the_query_string=PearDatabase::quote(from_html($the_query_string));
|
||||
array_push($where_clauses,"ecmstockstates.name like '$the_query_string%'");
|
||||
|
||||
$the_where="";
|
||||
foreach($where_clauses as $clause){
|
||||
if($the_where!="")$the_where.=" or ";
|
||||
$the_where.=$clause;
|
||||
}
|
||||
return $the_where;
|
||||
}
|
||||
function set_notification_body($xtpl,$ecmstockstate)
|
||||
{
|
||||
global $mod_strings,$app_list_strings;
|
||||
$xtpl->assign("ECMSTOCKSTATE_SUBJECT",$ecmstockstate->name);
|
||||
return $xtpl;
|
||||
}
|
||||
|
||||
function bean_implements($interface){
|
||||
switch($interface){
|
||||
case 'ACL':return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function save($check_notify=FALSE){
|
||||
return parent::save($check_notify);
|
||||
}
|
||||
}
|
||||
?>
|
||||
73
modules/EcmStockStates/EcmStockStatesQuickCreate.php
Executable file
73
modules/EcmStockStates/EcmStockStatesQuickCreate.php
Executable file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/EditView/QuickCreate.php');
|
||||
require_once('modules/EcmStockStates/EcmStockState.php');
|
||||
require_once('include/javascript/javascript.php');
|
||||
|
||||
class EcmStockStatesQuickCreate extends QuickCreate {
|
||||
|
||||
var $javascript;
|
||||
|
||||
function process() {
|
||||
global $current_user, $timedate, $app_list_strings, $current_language, $mod_strings;
|
||||
$mod_strings = return_module_language($current_language, 'EcmStockStates');
|
||||
|
||||
parent::process();
|
||||
|
||||
$this->ss->assign("PRIORITY_OPTIONS", get_select_options_with_id($app_list_strings['ecmstockstate_priority_dom'], $app_list_strings['ecmstockstate_priority_default_key']));
|
||||
$this->ss->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['ecmstockstate_status_dom'], $app_list_strings['ecmstockstate_status_default_key']));
|
||||
$this->ss->assign("TYPE_OPTIONS", get_select_options_with_id($app_list_strings['ecmstockstate_type_dom'],$app_list_strings['ecmstockstate_type_default_key']));
|
||||
|
||||
if($this->viaAJAX) { // override for ajax call
|
||||
$this->ss->assign('saveOnclick', "onclick='if(check_form(\"ecmstockstatesQuickCreate\")) return SUGAR.subpanelUtils.inlineSave(this.form.id, \"ecmstockstates\"); else return false;'");
|
||||
$this->ss->assign('cancelOnclick', "onclick='return SUGAR.subpanelUtils.cancelCreate(\"subpanel_ecmstockstates\")';");
|
||||
}
|
||||
|
||||
$this->ss->assign('viaAJAX', $this->viaAJAX);
|
||||
|
||||
$this->javascript = new javascript();
|
||||
$this->javascript->setFormName('ecmstockstatesQuickCreate');
|
||||
|
||||
$focus = new EcmStockState();
|
||||
$this->javascript->setSugarBean($focus);
|
||||
$this->javascript->addAllFields('');
|
||||
|
||||
$this->ss->assign('additionalScripts', $this->javascript->getScript(false));
|
||||
}
|
||||
}
|
||||
?>
|
||||
38
modules/EcmStockStates/Forms.php
Executable file
38
modules/EcmStockStates/Forms.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*********************************************************************************/
|
||||
//require_once('include/EditView/SideQuickCreate.php');
|
||||
?>
|
||||
382
modules/EcmStockStates/ListStates.php
Executable file
382
modules/EcmStockStates/ListStates.php
Executable file
@@ -0,0 +1,382 @@
|
||||
<?
|
||||
if(!$_REQUEST['date'])$date=date("Y-m-d");
|
||||
else $date=$GLOBALS['timedate']->to_db_date($_REQUEST['date']);
|
||||
$exp=explode("-",$date);
|
||||
$date=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
|
||||
|
||||
//$date = null;
|
||||
if(!$date)$date=date("Y-m-d");
|
||||
include_once("modules/EcmProductReports/vtigerConnector.php");
|
||||
include_once('modules/EcmCharts/chartHelper.php');
|
||||
$vc=new vtigerConnector();
|
||||
set_include_path('include/PHPExcel/');
|
||||
|
||||
include 'PHPExcel.php';
|
||||
//include 'PHPExcel/Writer/Excel2007.php';
|
||||
include 'PHPExcel/Writer/Excel5.php';
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
$objPHPExcel = new PHPExcel();
|
||||
$objPHPExcel->getProperties()->setCreator("E5 CRM");
|
||||
$objPHPExcel->getProperties()->setLastModifiedBy("E5 CRM");
|
||||
$objPHPExcel->getProperties()->setTitle("Office 2007 STATES");
|
||||
$objPHPExcel->getProperties()->setSubject("Office 2007 STATES");
|
||||
$objPHPExcel->getProperties()->setDescription("STATES");
|
||||
|
||||
$alf="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(10);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(20);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(20);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(20);
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("A1","Inventory states: ".$dat);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("A2","Index");
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("B2","Name");
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("C2","Category");
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("D2","Quantity");
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("E2","Unit");
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("F2","Price");
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("G2","Value");
|
||||
?>
|
||||
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2>Inventory States:</h2></td></tr></table><br />
|
||||
<ul class="tablist" style="width:100%;">
|
||||
<li>
|
||||
<a class="current" href="#">Basic Search</a>
|
||||
</li>
|
||||
</ul>
|
||||
<form action="index.php" method="get">
|
||||
<input type="hidden" name="module" value="EcmStockStates" />
|
||||
<input type="hidden" name="action" value="ListStates" />
|
||||
<input type="hidden" name="order_by" value="<?php echo $_REQUEST['order_by'];?>" />
|
||||
<input type="hidden" name="sorder" value="<?php echo $_REQUEST['sorder'];?>" />
|
||||
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="dataLabel" width="10%" nowrap="nowrap">
|
||||
Inventory</td>
|
||||
<td class="dataField" width="30%" nowrap="nowrap">
|
||||
<select name="stock_id">
|
||||
<option value="">select</option>
|
||||
<?php
|
||||
$w=$GLOBALS['db']->query("select id,name from ecmstocks where deleted='0' order by name asc");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
echo '<option value="'.$r['id'].'"';
|
||||
if($r['id']==$_GET['stock_id'])echo ' selected';
|
||||
echo '>'.$r['name'].'</option>';
|
||||
}
|
||||
?>
|
||||
</select> </td>
|
||||
<td class="dataLabel" width="10%" nowrap="nowrap">
|
||||
Category</td>
|
||||
<td class="dataField" width="30%" nowrap="nowrap">
|
||||
<select name="category_id">
|
||||
<option value="">select</option>
|
||||
<?php
|
||||
$w=$GLOBALS['db']->query("select id,name from ecmproductcategories where deleted='0' order by name asc");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
echo '<option value="'.$r['id'].'"';
|
||||
if($r['id']==$_GET['category_id'])echo ' selected';
|
||||
echo '>'.$r['name'].'</option>';
|
||||
}
|
||||
?>
|
||||
</select> </td>
|
||||
<td class="dataLabel" width="10%" nowrap="nowrap">
|
||||
Date</td>
|
||||
<td class="dataField" width="30%" nowrap="nowrap">
|
||||
<input autocomplete="off" name="date" id="date" value="<? echo $GLOBALS['timedate']->to_display_date($date);?>" title="" tabindex="" size="11" maxlength="10" type="text">
|
||||
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_trigger" align="absmiddle" border="0">
|
||||
<script type="text/javascript">
|
||||
Calendar.setup ({
|
||||
inputField : "date",
|
||||
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
|
||||
button : "date_trigger",
|
||||
singleClick : true,
|
||||
dateStr : "",
|
||||
step : 1
|
||||
}
|
||||
);
|
||||
</script> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="dataLabel" width="10%" nowrap="nowrap">
|
||||
Active</td>
|
||||
<td class="dataField" width="30%" nowrap="nowrap">
|
||||
<select name="active">
|
||||
<option value="">All</option>
|
||||
<option value="active" <?php if($_REQUEST['active']=="active")echo "selected";?>>Yes</option>
|
||||
<option value="inactive" <?php if($_REQUEST['active']=="inactive")echo "selected";?>>No</option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="dataLabel" width="10%" nowrap="nowrap">
|
||||
Not empty states only</td>
|
||||
<td class="dataField" width="30%" nowrap="nowrap">
|
||||
<select name="empty">
|
||||
<option value="">All</option>
|
||||
<option value="yes" <?php if($_REQUEST['empty']=="yes")echo "selected";?>>Yes</option>
|
||||
<option value="no" <?php if($_REQUEST['empty']=="no")echo "selected";?>>No</option>
|
||||
</select> </td>
|
||||
<td class="dataLabel" width="10%" nowrap="nowrap"> </td>
|
||||
<td class="dataField" width="30%" nowrap="nowrap"> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<input class="button" name="submit" value="Search" type="submit" onclick="this.form.action.value='ListStates';">
|
||||
<input class="button" name="clear" value="Clear" type="button" onclick="location.href='index.php?module=EcmStockStates&action=ListStates';">
|
||||
<input type="submit" class="button" name="CreateXLS" value="Create XLS">
|
||||
<br />
|
||||
<?php
|
||||
|
||||
$tds1='<td class="listViewThS1">';
|
||||
|
||||
$trs='<tr>';
|
||||
$tre='</tr>';
|
||||
|
||||
$tds='<td class="oddListRowS1">';
|
||||
$tde='</td>';
|
||||
|
||||
$tbs='<table cellpadding="0" cellspacing="0" border="0" class="ListView" style="width:100%;">';
|
||||
$tbe='</table>';
|
||||
|
||||
$t.=$tbs;
|
||||
$t.=$trs;
|
||||
$t.=$tds1;
|
||||
$t.=" ";
|
||||
$t.=$tde;
|
||||
$t.=$vc->sortableColumn("Index","code",$_GET['sorder'],15,"index");
|
||||
$t.=$vc->sortableColumn("Name","name",$_GET['sorder'],30,"index");
|
||||
$t.=$vc->sortableColumn("Category","product_category_name",$_GET['sorder'],20,"index");
|
||||
$t.=$vc->sortableColumn("Quantity","qty",$_GET['sorder'],10,"index");
|
||||
$t.=$vc->sortableColumn("Unit","unit",$_GET['sorder'],10,"index");
|
||||
$t.=$vc->sortableColumn("Price","price",$_GET['sorder'],15,"index");
|
||||
$t.=$vc->sortableColumn("Value","value",$_GET['sorder'],15,"index");
|
||||
$t.=$tre;
|
||||
$i=1;
|
||||
$ac=3;
|
||||
|
||||
$wh[]="deleted='0'";
|
||||
if($_GET['category_id'])$wh[]="product_category_id='".$_GET['category_id']."'";
|
||||
if($_GET['active']=="active")$wh[]="product_active='1'";
|
||||
if($_GET['active']=="inactive")$wh[]="product_active='0'";
|
||||
|
||||
$who[]="deleted='0'";
|
||||
if($date)$who[]="date_entered<='".$date." 23:59:59'";
|
||||
if($_GET['stock_id'])$who[]="stock_id='".$_GET['stock_id']."'";
|
||||
|
||||
$where=implode(" and ",$wh);
|
||||
$z="select id,name,code,product_category_name,product_category_id, unit_id from ecmproducts where ".$where." order by code asc, name asc";
|
||||
$w=$GLOBALS['db']->query($z);
|
||||
echo mysql_error();
|
||||
$sum_qty=0;
|
||||
$sum_price=0;
|
||||
|
||||
global $app_list_strings;
|
||||
|
||||
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$value=0;
|
||||
$qty=0;
|
||||
$price=0;
|
||||
|
||||
if($date!=date("Y-m-d",mktime()+24*3600)){
|
||||
$arr=array();
|
||||
$pp1=0;
|
||||
$q1=0;
|
||||
$ww=$GLOBALS['db']->query("select quantity as qty,id,price from ecmstockoperations where deleted='0' and type='0' and (in_id IS NULL or in_id='') and product_id='".$r['id']."' and (".implode(" and ",$who).") order by product_code");
|
||||
//echo "select quantity as qty,id,price from ecmstockoperations where deleted='0' and type='0' and (in_id IS NULL or in_id='') and product_id='".$r['id']."' and (".implode(" and ",$who).") order by code<br><br>";
|
||||
while($rrr=$GLOBALS['db']->fetchByAssoc($ww)){
|
||||
$www=$GLOBALS['db']->query("select quantity from ecmstockoperations where in_id='".$rrr['id']."' and type='1' and in_id IS NOT NULL and in_id!='' and product_id='".$r['id']."' and (".implode(" and ",$who).") and deleted='0'");
|
||||
$rqty=0;
|
||||
while($rrp=$GLOBALS['db']->fetchByAssoc($www)){
|
||||
$rqty+=$rrp['quantity'];
|
||||
}
|
||||
$qty=$rrr['qty']-$rqty;
|
||||
if($qty>0){
|
||||
$arr[]=array("qty"=>$qty,"id"=>$rrr['id'],"price"=>$rrr['price']);
|
||||
}
|
||||
}
|
||||
|
||||
if(count($arr)>0){
|
||||
foreach($arr as $v){
|
||||
$q1+=$v['qty'];
|
||||
$pp1+=$v['qty']*$v['price'];
|
||||
}
|
||||
}
|
||||
$qty=$q1;
|
||||
$value=$pp1;
|
||||
|
||||
@$price=$value/$qty;
|
||||
}
|
||||
else{
|
||||
$whs=array();
|
||||
$whs[]="deleted='0'";
|
||||
$whs[]="product_id='".$r['id']."'";
|
||||
if($_GET['stock_id'])$whs[]="stock_id='".$_GET['stock_id']."'";
|
||||
$whes=implode(" and ",$whs);
|
||||
$wss=$GLOBALS['db']->query("select quantity,price from ecmstockstates where ".$whes);
|
||||
while($rss=$GLOBALS['db']->fetchByAssoc($wss)){
|
||||
$qty+=$rss['quantity'];
|
||||
@$value+=$rss['quantity']*$rss['price'];
|
||||
}
|
||||
@$price=$value/$qty;
|
||||
}
|
||||
$arr1[]=array(
|
||||
"id"=>$r['id'],
|
||||
"qty"=>round($qty,2),
|
||||
"code"=>$r['code'],
|
||||
"name"=>$r['name'],
|
||||
"product_category_id"=>$r['product_category_id'],
|
||||
"product_category_name"=>$r['product_category_name'],
|
||||
"price"=>$price,
|
||||
"value"=>$value,
|
||||
"unit_id" => $r['unit_id'],
|
||||
);
|
||||
}
|
||||
if(!$_GET['order_by'])$_GET['order_by']="code";
|
||||
if(!$_GET['sorder'])$_GET['sorder']="asc";
|
||||
//$arr1=multisort($arr1,array(array('key'=>$_GET['order_by'],'sort'=>$_GET['sorder'])));
|
||||
|
||||
if(count($arr1)>0){
|
||||
foreach($arr1 as $r){
|
||||
if($_REQUEST['empty']=="yes" && ($r['qty']==0 || $r['qty']==""))continue;
|
||||
if($_REQUEST['empty']=="no" && $r['qty']!=0 && $r['qty']!="")continue;
|
||||
$t.=$trs;
|
||||
$t.=$tds;
|
||||
$t.='<input type="checkbox" value="'.$r['id'].'" name="check[]">';
|
||||
$t.=$tde;
|
||||
$t.=$tds;
|
||||
$t.=$r['code'];
|
||||
$t.=$tde;
|
||||
$t.=$tds;
|
||||
$t.='<a href="index.php?module=EcmProducts&action=DetailView&record='.$r['id'].'">'.$r['name'].'</a>';
|
||||
$t.=$tde;
|
||||
$t.=$tds;
|
||||
$t.='<a href="index.php?module=EcmProductCategories&action=DetailView&record='.$r['product_category_id'].'">'.$r['product_category_name'].'</a>';
|
||||
$t.=$tde;
|
||||
|
||||
$t.=$tds;
|
||||
$t.=number_format($r['qty'],4,",",".");
|
||||
$t.=$tde;
|
||||
$t.=$tds;
|
||||
$t.=$app_list_strings['ecmproducts_unit_dom'][$r['unit_id']];
|
||||
$t.=$tde;
|
||||
$t.=$tds;
|
||||
$t.=number_format($r['price'],2,",",".");
|
||||
$t.=$tde;
|
||||
$t.=$tds;
|
||||
$t.=number_format($r['value'],2,",",".");
|
||||
$t.=$tde;
|
||||
$t.=$tre;
|
||||
|
||||
$sum_qty+=$r['qty'];
|
||||
$sum_price+=$r['value'];
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("A".$ac,$r['code']);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("B".$ac,$r['name']);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("C".$ac,$r['product_category_name']);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("D".$ac,$r['qty']);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("E".$ac,$app_list_strings['ecmproducts_unit_dom'][$r['unit_id']]);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("F".$ac,$r['price']);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("G".$ac,$r['value']);
|
||||
$i++;
|
||||
$ac++;
|
||||
}
|
||||
}
|
||||
$t.=$trs;
|
||||
$t.=$tds1;
|
||||
$t.=" ";
|
||||
$t.=$tde;
|
||||
$t.=$tds1;
|
||||
$t.=" ";
|
||||
$t.=$tde;
|
||||
$t.=$tds1;
|
||||
$t.=" ";
|
||||
$t.=$tde;
|
||||
$t.=$tds1;
|
||||
$t.=" ";
|
||||
$t.=$tde;
|
||||
$t.=$tds1;
|
||||
$t.=number_format($sum_qty,0,"","");
|
||||
$t.=$tde;
|
||||
$t.=$tds1;
|
||||
$t.=" ";
|
||||
$t.=$tde;
|
||||
$t.=$tds1;
|
||||
$t.=@number_format($sum_price/$sum_qty,2,",",".");
|
||||
$t.=$tde;
|
||||
$t.=$tds1;
|
||||
$t.=number_format($sum_price,2,",",".");
|
||||
$t.=$tde;
|
||||
$t.=$tre;
|
||||
|
||||
$t.=$tbe;
|
||||
echo $t;
|
||||
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("D".$ac,$sum_qty);
|
||||
@$objPHPExcel->getActiveSheet()->SetCellValue("F".$ac,$sum_price/$sum_qty);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue("G".$ac,$sum_price);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
|
||||
array(
|
||||
'fill' => array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'color' => array('argb' => 'F0F0F0')
|
||||
),
|
||||
'borders' => array(
|
||||
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
|
||||
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
|
||||
)
|
||||
),
|
||||
"A1:G1"
|
||||
);
|
||||
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
|
||||
array(
|
||||
'fill' => array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'color' => array('argb' => 'F0F0F0')
|
||||
),
|
||||
'borders' => array(
|
||||
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
|
||||
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
|
||||
)
|
||||
),
|
||||
"A2:G2"
|
||||
);
|
||||
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
|
||||
array(
|
||||
'fill' => array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'color' => array('argb' => 'F0F0F0')
|
||||
),
|
||||
'borders' => array(
|
||||
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
|
||||
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
|
||||
)
|
||||
),
|
||||
"A".($ac).":G".($ac)
|
||||
);
|
||||
if($_REQUEST['CreateXLS']){
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
//$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
|
||||
chmod("cache/upload",0777);
|
||||
$microtime=str_replace(".","",str_replace(" ","",microtime()));
|
||||
$name="cache/upload/States".$microtime.".xls";
|
||||
$objWriter->save($name);
|
||||
chmod($name,0777);
|
||||
|
||||
header("Location: ".$name);
|
||||
}
|
||||
?>
|
||||
</form>
|
||||
38
modules/EcmStockStates/ListView.php
Executable file
38
modules/EcmStockStates/ListView.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings;
|
||||
|
||||
require_once('modules/EcmStockStates/EcmStockState.php');
|
||||
require_once('modules/EcmStockStates/Forms.php');
|
||||
require_once ('include/time.php');
|
||||
require_once('include/json_config.php');
|
||||
|
||||
$json_config = new json_config();
|
||||
|
||||
$focus = new EcmStockState();
|
||||
|
||||
if(isset($_REQUEST['record'])) {
|
||||
$focus->retrieve($_REQUEST['record']);
|
||||
}
|
||||
else {}
|
||||
|
||||
require_once('include/MVC/View/SugarView.php');
|
||||
|
||||
if(file_exists('modules/EcmStockStates/views/view.list.php')) {
|
||||
require_once('modules/EcmStockStates/views/view.list.php');
|
||||
$list = new EcmStockStatesViewList();
|
||||
}
|
||||
else {
|
||||
require_once('include/MVC/View/views/view.list.php');
|
||||
$list = new ViewList();
|
||||
}
|
||||
|
||||
$list->bean = $focus;
|
||||
// if(!isset($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] != "true") require_once('modules/EcmGroupSales/HeaderMenu.php');
|
||||
|
||||
$list->preDisplay();
|
||||
$list->display();
|
||||
|
||||
?>
|
||||
57
modules/EcmStockStates/Menu.php
Executable file
57
modules/EcmStockStates/Menu.php
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: TODO To be written.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
global $mod_strings;
|
||||
/*
|
||||
if(ACLController::checkAccess('EcmStockStates', 'edit', true))
|
||||
$module_menu[] =array("index.php?module=EcmStockStates&action=EditView&return_module=EcmStockStates&return_action=DetailView", $mod_strings['LNK_NEW_ECMSTOCKSTATE'],"CreateEcmStockStates", 'EcmStockStates');*/
|
||||
if(ACLController::checkAccess('EcmStockStates', 'list', true))
|
||||
$module_menu[]=array("index.php?module=EcmStockStates&action=index&return_module=EcmStockStates&return_action=DetailView", $mod_strings['LNK_ECMSTOCKSTATE_LIST'],"EcmStockStates", 'EcmStockStates');
|
||||
if(ACLController::checkAccess('EcmStockStates', 'list', true))
|
||||
$module_menu[]=array("index.php?module=EcmStockStates&action=ListStates&return_module=EcmStockStates&return_action=DetailView", "Summary","EcmStockStates", 'EcmStockStates');
|
||||
$module_menu[]=array("index.php?module=EcmStockStates&action=documentsReport", "Raport dokumentów","EcmStockStates", 'EcmStockStates');
|
||||
if(ACLController::checkAccess('EcmStockStates','list', true)) $module_menu[]=array('#', '<span style="display: none">wp_shortcut_fill_0</span>', '');
|
||||
|
||||
|
||||
?>
|
||||
55
modules/EcmStockStates/add_invoices_payments.php
Executable file
55
modules/EcmStockStates/add_invoices_payments.php
Executable file
@@ -0,0 +1,55 @@
|
||||
<?
|
||||
/*$w=mysql_query("select id,total,register_date,document_no,parent_id from ecminvoiceouts where register_date>'2009-12-31' and deleted='0'");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
echo "insert into ecmpayments_ecminvoiceouts(id,ecminvoiceout_id,date_entered,date_modified,modified_user_id,deleted,paid,total,document_no,account_id,register_date,payment_date) values('".create_guid()."','".$r['id']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','1','0','0','".$r['total']."','".$r['document_no']."','".$r['parent_id']."','".$r['register_date']."','');<br>";
|
||||
}*/
|
||||
/*$w=mysql_query("select register_date,id,ecminvoiceout_id,document_no from ecmpayments_ecminvoiceouts where document_no like '%/10' order by document_no asc");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
$rr=mysql_fetch_array(mysql_query("select ecmpaymentcondition_id from ecminvoiceouts where id='".$r['ecminvoiceout_id']."'"));
|
||||
$rr=mysql_fetch_array(mysql_query("select days from ecmpaymentconditions where id='".$rr['ecmpaymentcondition_id']."'"));
|
||||
$exp=explode("-",$r['register_date']);
|
||||
$date=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+3600*24*$rr['days']);
|
||||
echo "update ecmpayments_ecminvoiceouts set document_no='".$r['document_no']."',register_date='".$date."' where id='".$r['id']."';";
|
||||
}*/
|
||||
include_once("modules/EcmStockStates/class.dbf.php");
|
||||
//include_once("modules/EcmStockStates/helper.php");
|
||||
?>
|
||||
<textarea style="width:900px;height:600px;">
|
||||
<?
|
||||
/*
|
||||
$w=mysql_query("select id,name,dir from ecmstocks where dir is null and deleted='0'");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
$dbf = new dbf_class('modules/EcmStockStates/klk/'.$r['dir'].'/_wn.dbf');
|
||||
$num_rec=$dbf->dbf_num_rec;
|
||||
for($i=0;$i<$num_rec;$i++){
|
||||
$row=$dbf->getRowAssoc($i);
|
||||
if($row['DATA_DOK']>'20091231')continue;
|
||||
if($row['ROZL']=="T")$paid=1;
|
||||
else $paid=0;
|
||||
echo "update ecmpayments_ecminvoiceouts set paid='".$paid."' where document_no='".$row['SYM_DOK']." ".$row['NR_DOK']."';";
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
$w=mysql_query("select * from contacts where created_by='1633fa7a-fd76-08dc-ef31-4b544bbb5932' and date_entered like '2010-01-25%'");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
echo "insert into accounts set id='".create_guid()."',date_entered='".date("Y-m-d H:i:s")."',date_modified='".date("Y-m-d H:i:s")."',assigned_user_id='1633fa7a-fd76-08dc-ef31-4b544bbb5932',modified_user_id='1633fa7a-fd76-08dc-ef31-4b544bbb5932',created_by='1633fa7a-fd76-08dc-ef31-4b544bbb5932',name='".$r['last_name']."',phone_office='".$r['phone_work']."',billing_address_street='".$r['primary_address_street']."',billing_address_city='".$r['primary_address_city']."',billing_address_postalcode='".$r['primary_address_postalcode']."';
|
||||
";
|
||||
$ids[$r['id']]=$r['id'];
|
||||
}
|
||||
foreach($ids as $id){
|
||||
echo "update contacts set deleted='1' where id='".$id."';
|
||||
";
|
||||
}*/
|
||||
$ww=mysql_query("select id from ecminvoiceouts where register_date='2010-01-26'");
|
||||
while($rr=mysql_fetch_array($ww)){
|
||||
$total=0;
|
||||
$w=mysql_query("select p.price,p.quantity,p.ecmvat_value from ecminvoiceoutitems as p where p.ecminvoiceout_id='".$rr['id']."'");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
$total+=$r['quantity']*$r['price']*(1+$r['ecmvat_value']/100);
|
||||
}
|
||||
echo "update ecmpayments_ecminvoiceouts set total='".$total."' where ecminvoiceout_id='".$rr['id']."';
|
||||
";
|
||||
}
|
||||
?>
|
||||
</textarea>
|
||||
46
modules/EcmStockStates/checkOperations.php
Normal file
46
modules/EcmStockStates/checkOperations.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
$code = $_REQUEST['code'];
|
||||
|
||||
if (!$code || $code=='') die('Brak kodu');
|
||||
|
||||
$db = $GLOBALS['db'];
|
||||
|
||||
//get id
|
||||
$prod = $db->fetchByAssoc($db->query("SELECT id FROM ecmproducts WHERE code='$code' AND deleted='0'"));
|
||||
|
||||
$product_id = $prod['id'];
|
||||
|
||||
|
||||
if (!$product_id || $product_id=='') die ('Nie znaleziono produktu');
|
||||
|
||||
//get operations
|
||||
|
||||
$operations = $db->query("SELECT sum(quantity) as op_sum, parent_name, parent_type, type, parent_id FROM ecmstockoperations WHERE product_id='$product_id' GROUP BY parent_id");
|
||||
|
||||
$types = array();
|
||||
while ($o = $db->fetchByAssoc($operations)) {
|
||||
//get document info
|
||||
$doc = $db->fetchByAssoc($db->query("SELECT sum(quantity) doc_sum FROM ".substr(strtolower($o['parent_type']),0,-1)."items WHERE ".substr(strtolower($o['parent_type']),0,-1)."_id='".$o['parent_id']."' AND ecmproduct_id='$product_id'"));
|
||||
|
||||
if (!$types[$o['parent_type']]) {
|
||||
$types[$o['parent_type']]['op'] = $o['op_sum'];
|
||||
$types[$o['parent_type']]['doc'] = $doc['doc_sum'];
|
||||
} else {
|
||||
$types[$o['parent_type']]['op'] += $o['op_sum'];
|
||||
$types[$o['parent_type']]['doc'] += $doc['doc_sum'];
|
||||
}
|
||||
if (floatval($doc['doc_sum']) != floatval($o['op_sum']))
|
||||
echo $o['parent_name'].' '.format_number($o['op_sum']).' '.format_number($doc['doc_sum']).'<br><br>';
|
||||
}
|
||||
|
||||
echo '<br>Sumy:<br>';
|
||||
foreach ($types as $k=>$v) {
|
||||
echo '----<br>';
|
||||
echo $k.'<br>';
|
||||
echo 'Operacje: '.format_number($v['op']).'<br>';
|
||||
echo 'Dokumenty: '.format_number($v['doc']);
|
||||
echo '<br><br>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
43
modules/EcmStockStates/checkProduct.php
Normal file
43
modules/EcmStockStates/checkProduct.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?
|
||||
ini_set('display_errors',1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$q = "SELECT id FROM ecmstockoperations WHERE parent_id='c7880a7a-e5aa-5907-2b68-4efdcc7fa21d' AND product_id='c95743ea-a965-425c-2850-4acdefdbb52e'";
|
||||
|
||||
$db = $GLOBALS['db'];
|
||||
|
||||
$res = $db->query($q);
|
||||
|
||||
$docs = array();
|
||||
|
||||
while ($row = $db->fetchByAssoc($res)) {
|
||||
echo $row['id'].'<br><br>';
|
||||
|
||||
$q = "SELECT parent_id, quantity, parent_type FROM ecmstockoperations WHERE in_id='".$row['id']."'";
|
||||
$ress = $db->query($q);
|
||||
while ($roww=$db->fetchByAssoc($ress)) {
|
||||
$q = "SELECT quantity, document_no, d.id as id FROM ".strtolower(substr($roww['parent_type'],0,strlen($roww['parent_type'])-1))."items as i INNER JOIN ".strtolower($roww['parent_type'])." as d ON i.".strtolower(substr($roww['parent_type'],0,strlen($roww['parent_type'])-1))."_id=d.id WHERE ".strtolower(substr($roww['parent_type'],0,strlen($roww['parent_type'])-1))."_id='".$roww['parent_id']."' AND ecmproduct_id='c95743ea-a965-425c-2850-4acdefdbb52e'";
|
||||
|
||||
$doc_res = $db->query($q);
|
||||
$doc_row = $db->fetchByAssoc($doc_res);
|
||||
|
||||
$tmp = array();
|
||||
$tmp['quantity'] = $doc_row['quantity'];
|
||||
$tmp['document_no'] = $doc_row['document_no'];
|
||||
|
||||
$docs[$doc_row['id']] = $tmp;
|
||||
}
|
||||
}
|
||||
$sum = 0;
|
||||
foreach ($docs as $id=>$v) {
|
||||
echo $v['document_no'].': '.$v['quantity'].'<br>';
|
||||
$sum+=$v['quantity'];
|
||||
|
||||
$q = "SELECT sum(quantity) as s FROM ecmstockoperations WHERE parent_id='$id' AND product_id='c95743ea-a965-425c-2850-4acdefdbb52e' AND in_id!='212419f3-aab6-7809-91dc-4fe9b3bcc980'";
|
||||
echo $q.'<br>';
|
||||
$res = $db->query($q);
|
||||
$row = $db->fetchByAssoc($res);
|
||||
echo 'Stock Operation: '.$row['s'].'<br>--------------------------------<br>';
|
||||
}
|
||||
echo '<br><br>Suma: '.$sum.'<br>';
|
||||
?>
|
||||
30
modules/EcmStockStates/check_products.php
Executable file
30
modules/EcmStockStates/check_products.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
set_time_limit(9999999999);
|
||||
|
||||
include_once("class.dbf.php");
|
||||
include_once("helper.php");
|
||||
|
||||
$sql=mysql_connect("localhost","root","");
|
||||
mysql_select_db("saascrm");
|
||||
mysql_query("set names utf8");
|
||||
|
||||
//$w=mysql_query("select id,name,dir from ecmstocks where deleted='0'");
|
||||
//while($r=mysql_fetch_array($w)){
|
||||
$dbf = new dbf_class("klk/".$r['dir']."/_stany.dbf");
|
||||
$num_rec=$dbf->dbf_num_rec;
|
||||
$n=0;
|
||||
for($i=0;$i<$num_rec;$i++){
|
||||
$row = $dbf->getRowAssoc($i);
|
||||
$index=iconv("CP852","UTF-8",$row['INDEKS']);
|
||||
$nazwa=$row['NAZWA'];
|
||||
|
||||
if(mysql_num_rows(mysql_query("select name from ecmproducts where code like '".$index."' and deleted='0'"))==0){
|
||||
echo $index." ".$nazwa."\n";
|
||||
addProduct($index,$nazwa);
|
||||
$n++;
|
||||
}
|
||||
}
|
||||
echo $n;
|
||||
//}
|
||||
mysql_close($sql);
|
||||
?>
|
||||
120
modules/EcmStockStates/class.dbf.php
Executable file
120
modules/EcmStockStates/class.dbf.php
Executable file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
class dbf_class {
|
||||
|
||||
var $dbf_num_rec; //Number of records in the file
|
||||
var $dbf_num_field; //Number of columns in each row
|
||||
var $dbf_names = array(); //Information on each column ['name'],['len'],['type']
|
||||
//These are private....
|
||||
var $_raw; //The raw input file
|
||||
var $_rowsize; //Length of each row
|
||||
var $_hdrsize; //Length of the header information (offset to 1st record)
|
||||
var $_memos; //The raw memo file (if there is one).
|
||||
|
||||
function dbf_class($filename) {
|
||||
if ( !file_exists($filename)) {
|
||||
echo 'Not a valid DBF file !!!'; exit;
|
||||
}
|
||||
$tail=substr($filename,-4);
|
||||
if (strcasecmp($tail, '.dbf')!=0) {
|
||||
echo 'Not a valid DBF file !!!'; exit;
|
||||
}
|
||||
|
||||
//Read the File
|
||||
$handle = fopen($filename, "r");
|
||||
if (!$handle) { echo "Cannot read DBF file"; exit; }
|
||||
$filesize = filesize($filename);
|
||||
$this->_raw = fread ($handle, $filesize);
|
||||
fclose ($handle);
|
||||
//Make sure that we indeed have a dbf file...
|
||||
if(!(ord($this->_raw[0]) == 3 || ord($this->_raw[0]) == 131) && ord($this->_raw[$filesize]) != 26) {
|
||||
echo 'Not a valid DBF file !!!'; exit;
|
||||
}
|
||||
// 3= file without DBT memo file; 131 ($83)= file with a DBT.
|
||||
$arrHeaderHex = array();
|
||||
for($i=0; $i<32; $i++){
|
||||
$arrHeaderHex[$i] = str_pad(dechex(ord($this->_raw[$i]) ), 2, "0", STR_PAD_LEFT);
|
||||
}
|
||||
//Initial information
|
||||
$line = 32;//Header Size
|
||||
//Number of records
|
||||
$this->dbf_num_rec= hexdec($arrHeaderHex[7].$arrHeaderHex[6].$arrHeaderHex[5].$arrHeaderHex[4]);
|
||||
$this->_hdrsize= hexdec($arrHeaderHex[9].$arrHeaderHex[8]);//Header Size+Field Descriptor
|
||||
//Number of fields
|
||||
$this->_rowsize = hexdec($arrHeaderHex[11].$arrHeaderHex[10]);
|
||||
$this->dbf_num_field = floor(($this->_hdrsize - $line ) / $line ) ;//Number of Fields
|
||||
|
||||
//Field properties retrieval looping
|
||||
for($j=0; $j<$this->dbf_num_field; $j++){
|
||||
$name = '';
|
||||
$beg = $j*$line+$line;
|
||||
for($k=$beg; $k<$beg+11; $k++){
|
||||
if(ord($this->_raw[$k])!=0){
|
||||
$name .= $this->_raw[$k];
|
||||
}
|
||||
}
|
||||
$this->dbf_names[$j]['name']= $name;//Name of the Field
|
||||
$this->dbf_names[$j]['len']= ord($this->_raw[$beg+16]);//Length of the field
|
||||
$this->dbf_names[$j]['type']= $this->_raw[$beg+11];
|
||||
}
|
||||
if (ord($this->_raw[0])==131) { //See if this has a memo file with it...
|
||||
//Read the File
|
||||
$tail=substr($tail,-1,1); //Get the last character...
|
||||
if ($tail=='F'){ //See if upper or lower case
|
||||
$tail='T'; //Keep the case the same
|
||||
} else {
|
||||
$tail='t';
|
||||
}
|
||||
$memoname = substr($filename,0,strlen($filename)-1).$tail;
|
||||
$handle = fopen($memoname, "r");
|
||||
if (!$handle) { echo "Cannot read DBT file"; exit; }
|
||||
$filesize = filesize($memoname);
|
||||
$this->_memos = fread ($handle, $filesize);
|
||||
fclose ($handle);
|
||||
}
|
||||
}
|
||||
|
||||
function getRow($recnum) {
|
||||
$memoeot = chr(26).chr(26);
|
||||
$rawrow = substr($this->_raw,$recnum*$this->_rowsize+$this->_hdrsize,$this->_rowsize);
|
||||
$rowrecs = array();
|
||||
$beg=1;
|
||||
if (ord($rawrow[0])==42) {
|
||||
return false; //Record is deleted...
|
||||
}
|
||||
for ($i=0; $i<$this->dbf_num_field; $i++) {
|
||||
$col=trim(substr($rawrow,$beg,$this->dbf_names[$i]['len']));
|
||||
if ($this->dbf_names[$i]['type']!='M') {
|
||||
|
||||
$rowrecs[]=$col;
|
||||
} else {
|
||||
$memobeg=$col*512; //Find start of the memo block (0=header so it works)
|
||||
$memoend=strpos($this->_memos,$memoeot,$memobeg); //Find the end of the memo
|
||||
$rowrecs[]=substr($this->_memos,$memobeg,$memoend-$memobeg);
|
||||
}
|
||||
$beg+=$this->dbf_names[$i]['len'];
|
||||
}
|
||||
return $rowrecs;
|
||||
}
|
||||
|
||||
function getRowAssoc($recnum) {
|
||||
$rawrow = substr($this->_raw,$recnum*$this->_rowsize+$this->_hdrsize,$this->_rowsize);
|
||||
$rowrecs = array();
|
||||
$beg=1;
|
||||
if (ord($rawrow[0])==42) {
|
||||
return false; //Record is deleted...
|
||||
}
|
||||
for ($i=0; $i<$this->dbf_num_field; $i++) {
|
||||
$col=trim(substr($rawrow,$beg,$this->dbf_names[$i]['len']));
|
||||
if ($this->dbf_names[$i]['type']!='M') {
|
||||
$rowrecs[$this->dbf_names[$i]['name']]=$col;
|
||||
} else {
|
||||
$memobeg=$col*512; //Find start of the memo block (0=header so it works)
|
||||
$memoend=strpos($this->_memos,$memoeot,$memobeg); //Find the end of the memo
|
||||
$rowrecs[$this->dbf_names[$i]['name']]=substr($this->_memos,$memobeg,$memoend-$memobeg);
|
||||
}
|
||||
$beg+=$this->dbf_names[$i]['len'];
|
||||
}
|
||||
return $rowrecs;
|
||||
}
|
||||
}
|
||||
?>
|
||||
12
modules/EcmStockStates/clearInvoices.php
Executable file
12
modules/EcmStockStates/clearInvoices.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?
|
||||
set_time_limit(999999);
|
||||
$w=mysql_query("select distinct ecminvoiceout_id from ecminvoiceoutitems");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
echo $r['ecminvoiceout_id'];
|
||||
if(mysql_num_rows(mysql_query("select id from ecminvoiceouts where id='".$r['ecminvoiceout_id']."'"))==0){
|
||||
mysql_query("delete from ecminvoiceoutitems where ecminvoiceout_id='".$r['ecminvoiceout_id']."'");
|
||||
echo ' ok';
|
||||
}
|
||||
echo '<br>';
|
||||
}
|
||||
?>
|
||||
60
modules/EcmStockStates/documentsReport.php
Normal file
60
modules/EcmStockStates/documentsReport.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<form
|
||||
action="index.php"
|
||||
type="GET">
|
||||
<input type="hidden" name="module" value="EcmStockStates"/>
|
||||
<input type="hidden" name="action" value="documentsReport"/>
|
||||
<input type="hidden" name="process" value="1"/>
|
||||
Kod produktu: <input name="product_code" value="<?php echo $_REQUEST['product_code']?>" /><br> Typ
|
||||
dokumentu: <select name="doc_type">
|
||||
<option value="EcmStockDocIns" <?php if ($_REQUEST['doc_type']=='EcmStockDocIns') echo "selected ";?>>PZ</option>
|
||||
<option value="EcmStockDocOuts"<?php if ($_REQUEST['doc_type']=='EcmStockDocOuts') echo "selected ";?>>WZ</option>
|
||||
<option value="EcmStockDocInsideIns"<?php if ($_REQUEST['doc_type']=='EcmStockDocInsideIns') echo "selected ";?>>PW</option>
|
||||
<option value="EcmStockDocInsideOuts"<?php if ($_REQUEST['doc_type']=='EcmStockDocInsideOuts') echo "selected ";?>>RW</option>
|
||||
<option value="EcmStockDocCorrects"<?php if ($_REQUEST['doc_type']=='EcmStockDocCorrects') echo "selected ";?>>KS</option>
|
||||
<option value="EcmStockDocMoves"<?php if ($_REQUEST['doc_type']=='EcmStockDocMoves') echo "selected ";?>>MM</option>
|
||||
<option value="EcmInsideOrders"<?php if ($_REQUEST['doc_type']=='EcmInsideOrders') echo "selected ";?>>IO</option>
|
||||
</select><br>
|
||||
<input type="submit"></input>
|
||||
</form>
|
||||
<br>
|
||||
<?php
|
||||
if ($_REQUEST ['process'] == '1') {
|
||||
$db = $GLOBALS ['db'];
|
||||
|
||||
// get id
|
||||
$prod = $db->fetchByAssoc ( $db->query ( "SELECT id FROM ecmproducts WHERE code='".$_REQUEST['product_code']."' AND deleted='0'" ) );
|
||||
$product_id = $prod ['id'];
|
||||
if (! $product_id || $product_id == '')
|
||||
die ( 'Nie znaleziono produktu' );
|
||||
|
||||
$sum_doc = 0;
|
||||
$sum_op = 0;
|
||||
$operations = $db->query ( "SELECT sum(quantity) as op_sum, parent_name,parent_type, type, parent_id FROM ecmstockoperations WHERE product_id='$product_id' AND parent_type='" . $_REQUEST ['doc_type'] . "' GROUP BY parent_id ORDER BY date_entered DESC" );
|
||||
echo '<table style="border: 0.5px solid black; border-collapse:collapse;"><thead>
|
||||
<tr style="border: 0.5px solid black;">
|
||||
<th style="border: 0.5px solid black;">Nazwa dokumentu</th>
|
||||
<th style="border: 0.5px solid black;">Ilośc na dokumentcie</th>
|
||||
<th style="border: 0.5px solid black;">Wykonana operacja</th>
|
||||
<th style="border: 0.5px solid black;">Data dokumentu</th>
|
||||
</tr></thead>';
|
||||
while ( $o = $db->fetchByAssoc ( $operations ) ) {
|
||||
// get document info
|
||||
$doc = $db->fetchByAssoc ( $db->query ( "SELECT date_entered, sum(quantity) doc_sum FROM " . substr ( strtolower ( $o ['parent_type'] ), 0, - 1 ) . "items WHERE " . substr ( strtolower ( $o ['parent_type'] ), 0, - 1 ) . "_id='" . $o ['parent_id'] . "' AND ecmproduct_id='$product_id'" ) );
|
||||
echo '<tr style="border: 0.5px solid black;">
|
||||
<td style="border: 0.5px solid black;">'.$o['parent_name'].'</td>
|
||||
<td style="border: 0.5px solid black;">'.format_number($doc['doc_sum'],4).'</td>
|
||||
<td style="border: 0.5px solid black;">'.format_number($o['op_sum'],4).'</td>
|
||||
<td style="border: 0.5px solid black;">'.$doc['date_entered'].'</td>
|
||||
</tr>';
|
||||
$sum_doc += floatval($doc['doc_sum']);
|
||||
$sum_op += floatval($o['op_sum']);
|
||||
}
|
||||
echo '<tr style="border: 0.5px solid black;">
|
||||
<td style="border: 0.5px solid black;">Podsumowanie: </td>
|
||||
<td style="border: 0.5px solid black;">'.format_number($sum_doc,4).'</td>
|
||||
<td style="border: 0.5px solid black;">'.format_number($sum_op,4).'</td>
|
||||
<td style="border: 0.5px solid black;"></td>
|
||||
</tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
76
modules/EcmStockStates/field_arrays.php
Executable file
76
modules/EcmStockStates/field_arrays.php
Executable file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: Contains field arrays that are used for caching
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
$fields_array['EcmStockState']=array(
|
||||
'column_fields'=>array(
|
||||
"id",
|
||||
"name",
|
||||
"date_entered",
|
||||
"date_modified",
|
||||
"modified_user_id",
|
||||
"assigned_user_id",
|
||||
"stock_name",
|
||||
"stock_id",
|
||||
"product_code",
|
||||
"product_name",
|
||||
"product_id",
|
||||
"quantity",
|
||||
"price",
|
||||
),
|
||||
'list_fields'=>array(
|
||||
"id",
|
||||
"name",
|
||||
"date_entered",
|
||||
"date_modified",
|
||||
"modified_user_id",
|
||||
"assigned_user_id",
|
||||
"stock_name",
|
||||
"stock_id",
|
||||
"product_code",
|
||||
"product_name",
|
||||
"product_id",
|
||||
"quantity",
|
||||
),
|
||||
'required_fields' => array('name'=>1),
|
||||
);
|
||||
?>
|
||||
19
modules/EcmStockStates/fk.php
Executable file
19
modules/EcmStockStates/fk.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$db = $GLOBALS['db'];
|
||||
|
||||
ini_set('display_errors',1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$query ="select id from ecminvoiceouts where id in ('4aa23315-566e-0da7-ae15-59f6d8be6571','4443253d-b902-05f6-ffbf-59f826980eb7','6713436f-b520-3583-7245-59f8327967a5','577dcd9b-2e96-1444-cc68-59f83bf70ec5','51d7ea7e-86df-74f7-3e3b-59fc67e2d0b4','b0b5f65d-c144-5a8c-97f7-59fc6a4c028d','b98f2bd2-ef9d-a707-ed2c-59fc6e80f411','7b0dfd86-a59f-7e19-cf13-5a0423ebaecc','b19abe07-99b1-02c5-3a1a-5a042445df93','844f8fe4-001a-5c9f-32ad-5a0426cea733','45e91486-ddf8-6e43-82a8-5a04574e2cc5','dc506bfb-6a44-a9c0-0e39-5a045774ead6','953b59fa-40ef-daff-4840-5a045c5ddf72','2f51fc14-c925-5c3d-daa2-5a04758dc54f','122367a5-970d-9473-6b1e-5a04762e23b4','4427c7ad-55e4-2360-6fc0-5a09585937f8','c3580ea7-c598-7f55-e9d0-5a095a96df5e','f2a6cd93-3e0d-d09f-6aa9-5a095c23fcbc','886b0f73-5d78-c49b-9c37-5a095d124d04','12f23d4f-efb9-4a9f-c5a2-5a095d0eab33','84323c5d-eb4f-cfc8-37a4-5a098550174f','cb220f64-9079-175c-492a-5a0985e86c44','280f2ade-3ca9-b01d-db53-5a098ca8ca50','9c681708-429a-e669-a96b-5a098d076b80','180e6820-dc07-cb94-eada-5a09972a2f31','b4815fa1-9fa0-8c07-e5b6-5a09ace4bb59','1789a938-ef14-f677-451a-5a09aca87c3c','d25d1616-a617-6fd7-9b69-5a09aecf6c4d','72086af7-8b7c-8399-83ef-5a0aaff3780a','a0f498ae-c289-768a-21b6-5a0c2e2cc72b','d87d3ae4-65cb-0ae9-8f75-5a0c31f0b038','23bb4e40-c36e-0613-0c20-5a0c3559954a','adf07e63-2c99-056f-7611-5a0c4a6c9318','319ccaf2-6635-db49-22c2-5a0c4b6ab6de','2852055f-72dc-eed6-cb21-5a0c4c488365','14a247ef-865e-c40c-1834-5a0c4c0ca78c','af573f8d-68b7-d0c6-4e2e-5a0c4d324134','aa28f95f-67c7-9da7-935e-5a0c4e8b0cec','639aa27f-f56a-81f2-78e9-5a0c524df658','5b9e4d7d-b560-6146-cd10-5a0c53b51926','f0c95709-fe5b-fafa-ace4-5a0c544728ad','82ec694d-fb1f-6fb5-46b2-5a0c55a45050','1ecef11b-97c8-6839-2341-5a0c56fc8f75','4bdef90b-eaa5-68b6-1364-5a0c58b0f3f2','baad307d-a308-1508-c362-5a0c59574f34','74f8b5d0-bbd9-0903-ad8d-5a0e88f3f459','8d0a4f0a-d43c-9afd-4b7c-5a0e8af6f7ff','7d100c39-2dc8-f527-1e06-5a0e8a25123c','1a834b9e-3bfe-7c9b-1c06-5a0e8bf4e9df','e8204212-5b9e-14bd-611f-5a0e8b1688e2','5c8e8091-1f26-e72d-acf5-5a0ed9775260','2e4bf6b4-0936-dde5-1281-5a12b8bf2b5c','2b271908-bba6-6c91-4e61-5a12ba1bb0a4','1b30090f-36e4-dd5e-9a82-5a12bb0b4ac1','94804f59-166c-8070-1968-5a12c0779adb','a2435bcc-213e-9ec0-b261-5a12c2929132','9736be93-d188-0fe7-7e20-5a1427402bcb','6602db7e-22df-3afb-7623-5a1428ea0f39','996a9e7e-8b51-c780-50f3-5a142a796dab','cad01477-7009-a6c6-e9f0-5a142a501654','69d58a8f-355e-7bac-8abb-5a142bf26099','a807de08-b06a-8bab-b575-5a142c4b9b8e','858bbbd8-293e-06c1-b7dd-5a142d4995be','68d2baa8-f75e-c57c-1657-5a142ea7a7e7','a44b5ced-d9d8-e892-26e8-5a142f968066','2dba450a-e5e0-13db-320f-5a143036be8a','4ece8611-5934-3e75-3b4b-5a1430391629','6b78229c-0769-15fd-eda4-5a1431fb626c','880ada2a-6603-de07-b047-5a143256b20a','1ed332f8-e404-d17d-ce16-5a16aefa3535','d4470050-90f3-cbad-71f3-5a16c31c93ee','389d6ee4-6305-fe83-fbf6-5a1c144254b9','24daf2b5-df16-2e70-5e31-5a1c1512cc4f','eb03e0e4-68b9-141f-f129-5a1c16e93b8c','7fb844a9-7cb0-632d-4d1d-5a1c17726b9d','447fbf24-7a71-469f-1f15-5a1c186829f5','fe930628-33a7-ccec-bbaf-5a1c18552a28','98725fbf-55cd-a1e8-681a-5a1c19c459fa','890da27c-e5a9-ca95-5267-5a1c1a738945','7633418e-0249-00de-7b31-5a1c1b16c95d','9e7dbe98-0da8-d32d-c825-5a1c1c4b8144','b34b8575-001e-93ac-def7-5a1c1d87eb27','30d1018f-c06f-3366-947e-5a1c1eb9d526','7a81d99c-df91-2add-e331-5a1d2cddc63b','ad2c050c-ce43-4322-1b2c-5a1d32bcfc40','a51ab7f7-52a8-48c5-740d-5a1d33fff010','77f194ef-7cf7-2a37-3ac3-5a1d35139359','83a04479-7aab-8f44-c724-5a1d35937102','3de64a12-e109-c55a-baa7-5a1e4d7c6434','939e2404-45a5-339a-8df2-5a1e6891e135','6de886c4-79ec-f7d5-e6bd-5a1fdea99fa6','57be22ce-83a0-a3f7-bfdc-5a269bb1a501','4b5a7278-73fb-b0cb-6555-5a269ced52c5','56240fdb-bc0d-f8ed-b8e7-5a269d2999bc','733f491e-90ce-8a93-2df9-5a269e20d319','b8e1ee6f-48f1-fb28-86d5-5a269f81ed36','a96a14fa-6a98-1b49-7f3f-5a26a0527e3f','554d17f3-680e-f319-0fd4-5a26a1ea90ec','eca4e7af-c864-48e2-1196-5a26a1c5dbb2','df51083c-48ad-8359-41fb-5a26a211aca2','80b2944e-a3cd-b618-2141-5a26a36ffc48','30a88683-5747-6d3e-8a6a-5a26a4423e55','19cea127-5cc4-9374-87d4-5a26a65db6e9','62207ab5-9e56-1617-967e-5a26a7d14806') limit 1
|
||||
";
|
||||
|
||||
$res=$db->query($query);
|
||||
while($dane=$db->fetchByAssoc($res)){
|
||||
$i = new EcmInvoiceOut();
|
||||
|
||||
$i->retrieve($dane['id']);
|
||||
$i->sendSoap();
|
||||
}
|
||||
|
||||
?>
|
||||
5
modules/EcmStockStates/getProductQuantity.php
Normal file
5
modules/EcmStockStates/getProductQuantity.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
include_once("modules/EcmStockOperations/EcmStockOperation.php");
|
||||
$op=new EcmStockOperation();
|
||||
print $op->getStock($_GET['product_id'], $_GET['stock_id']);
|
||||
?>
|
||||
199
modules/EcmStockStates/helper.php
Executable file
199
modules/EcmStockStates/helper.php
Executable file
@@ -0,0 +1,199 @@
|
||||
<?
|
||||
function create_guid()
|
||||
{
|
||||
$microTime = microtime();
|
||||
list($a_dec, $a_sec) = explode(" ", $microTime);
|
||||
|
||||
$dec_hex = sprintf("%x", $a_dec* 1000000);
|
||||
$sec_hex = sprintf("%x", $a_sec);
|
||||
|
||||
ensure_length($dec_hex, 5);
|
||||
ensure_length($sec_hex, 6);
|
||||
|
||||
$guid = "";
|
||||
$guid .= $dec_hex;
|
||||
$guid .= create_guid_section(3);
|
||||
$guid .= '-';
|
||||
$guid .= create_guid_section(4);
|
||||
$guid .= '-';
|
||||
$guid .= create_guid_section(4);
|
||||
$guid .= '-';
|
||||
$guid .= create_guid_section(4);
|
||||
$guid .= '-';
|
||||
$guid .= $sec_hex;
|
||||
$guid .= create_guid_section(6);
|
||||
|
||||
return $guid;
|
||||
|
||||
}
|
||||
|
||||
function create_guid_section($characters)
|
||||
{
|
||||
$return = "";
|
||||
for($i=0; $i<$characters; $i++)
|
||||
{
|
||||
$return .= sprintf("%x", mt_rand(0,15));
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function ensure_length(&$string, $length)
|
||||
{
|
||||
$strlen = strlen($string);
|
||||
if($strlen < $length)
|
||||
{
|
||||
$string = str_pad($string,$length,"0");
|
||||
}
|
||||
else if($strlen > $length)
|
||||
{
|
||||
$string = substr($string, 0, $length);
|
||||
}
|
||||
}
|
||||
function ch($str){
|
||||
return iconv("CP852","UTF-8",$str);
|
||||
}
|
||||
function addPzBilans($name,$stock_id){
|
||||
|
||||
$id="bilans_otwarcia".$stock_id;
|
||||
$arr=array(
|
||||
"id"=>$id,
|
||||
"name"=>"Bilans otwarcia",
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"document_no"=>$name,
|
||||
"number"=>1,
|
||||
"modified_user_id"=>1,
|
||||
"assigned_user_id"=>1,
|
||||
"created_by"=>1,
|
||||
//"parent_name"=>"E5 Polska Sp. z o. o.",
|
||||
"parent_id"=>36,
|
||||
"status"=>"accepted",
|
||||
"register_date"=>"2009-10-06",
|
||||
"parent_address_street"=>"Wąwozowa 11",
|
||||
"parent_address_city"=>"Warszawa",
|
||||
"parent_address_postalcode"=>"02-796",
|
||||
"subtotal"=>0,
|
||||
"total"=>0,
|
||||
"discount"=>0,
|
||||
"ecmlanguage"=>"pl_pl",
|
||||
"template_id"=>"1d178dc6-0904-3fa3-f51b-4a4b4698a173",
|
||||
"template_name"=>"E5 Polska Sp. z o. o.",
|
||||
"stock_id"=>$stock_id,
|
||||
"currency_id"=>"PLN",
|
||||
"correct_id"=>"",
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
mysql_query("insert into ecmstockdocins set ".implode(",",$in));
|
||||
//echo $i." [".$row['NR_PZ']."]\n";
|
||||
if(mysql_error())echo mysql_error();
|
||||
return $id;
|
||||
}
|
||||
function addProductLinePZ($id,$i,$r,$index,$name){
|
||||
$vats=array(
|
||||
0=>"9b783d21-5548-6653-e1d6-49610eb3f9dd",
|
||||
22=>"9c592a4a-2de0-1fa3-e082-494aeceb122c",
|
||||
7=>"bf3a5fec-435f-af22-024a-4958b51863c8",
|
||||
);
|
||||
$rr=mysql_fetch_array(mysql_query("select id from ecmproducts where code like '".$index."' and deleted='0'"));
|
||||
$pid=$rr['id'];
|
||||
if($pid==""){
|
||||
$pid=addProduct($index,$name);
|
||||
}
|
||||
$iid=create_guid();
|
||||
$arr=array(
|
||||
"id"=>$iid,
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"deleted"=>0,
|
||||
"modified_user_id"=>1,
|
||||
"assigned_user_id"=>1,
|
||||
"created_by"=>1,
|
||||
"ecmstockdocin_id"=>$id,
|
||||
"ecmproduct_id"=>$pid,
|
||||
"position"=>$i,
|
||||
"code"=>str_replace("'",""",$index),
|
||||
"name"=>str_replace("'",""",$name),
|
||||
"quantity"=>round($r['ILOSC'],2),
|
||||
"price"=>$r['CENA_ZAK'],
|
||||
"discount"=>$r['RABAT'],
|
||||
"total"=>$r['CENA_ZAK']*$r['ILOSC'],
|
||||
"dd_unit_name"=>$r['NAZWA_J_M'],
|
||||
"dd_unit_id"=>1,
|
||||
"ecmvat_id"=>$vats[$r['VAT']],
|
||||
"ecmvat_value"=>$r['VAT'],
|
||||
"ecmvat_name"=>$r['VAT']."%",
|
||||
"currency_id"=>"PLN",
|
||||
"currency_name"=>"PLN",
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
mysql_query("insert into ecmstockdocinitems set ".implode(",",$in));
|
||||
if(mysql_error())echo mysql_error()."\n";
|
||||
return $iid;
|
||||
}
|
||||
function checkCharset($testString, $targetString){
|
||||
$out=false;
|
||||
$encoding=array("ASCII","ISO-8859-1","ISO-8859-2","ISO-8859-3","ISO-8859-4","ISO-8859-5","ISO-8859-7","ISO-8859-9","ISO-8859-10","ISO-8859-13","ISO-8859-14","ISO-8859-15","ISO-8859-16","KOI8-R","KOI8-U","KOI8-RU","CP1250","CP1251","CP1252","CP1253","CP1254","CP1257","CP850","CP866","Mac Roman","Mac CentralEurope","Mac Iceland","Mac Croatian","Mac Romania","Mac Cyrillic","Mac Ukraine","Mac Greek","Mac Turkish", "Macintosh","ISO-8859-6","ISO-8859-8", "CP1255","CP1256", "CP862","Mac Hebrew","Mac Arabic","EUC-JP", "SHIFT_JIS", "CP932", "ISO-2022-JP", "ISO-2022-JP-2", "ISO-2022-JP-1","EUC-CN","HZ","GBK","GB18030","EUC-TW","BIG5","CP950","BIG5-HKSCS","ISO-2022-CN","ISO-2022-CN-EXT","EUC-KR","CP949","ISO-2022-KR","JOHAB","ARMSCII-8","Georgian-Academy","Georgian-PS","KOI8-T","TIS-620","CP874","MacThai","MuleLao-1","CP1133","VISCII","TCVN","CP1258","HP-ROMAN8","NEXTSTEP","UTF-8","UCS-2","UCS-2BE","UCS-2LE","UCS-4","UCS-4BE","UCS-4LE","UTF-16","UTF-16BE","UTF-16LE","UTF-32","UTF-32BE","UTF-32LE","UTF-7","C99","JAVA","UCS-2-INTERNAL","UCS-4-INTERNAL","CP437","CP737","CP775","CP852","CP853","CP855","CP857","CP858","CP860","CP861","CP863","CP865","CP869","CP1125","CP864","EUC-JISX0213","Shift_JISX0213","ISO-2022-JP-3","TDS565","RISCOS-LATIN1");
|
||||
foreach($encoding as $v){
|
||||
if(iconv($v, "utf-8", $testString) === $targetString){$out=$v;}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
function addProduct($code,$name){
|
||||
$id=create_guid();
|
||||
if(!$name)$name=$code;
|
||||
$arr=array(
|
||||
"id"=>$id,
|
||||
"name"=>str_replace("'",""",$name),
|
||||
"code"=>str_replace("'",""",$code),
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"assigned_user_id"=>1,
|
||||
"modified_user_id"=>1,
|
||||
"created_by"=>1,
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
mysql_query("insert into ecmproducts set ".implode(",",$in));
|
||||
return $id;
|
||||
}
|
||||
function addOperation($doc_id,$doc_name,$doc_type,$item_id,$index,$name,$qty,$price,$type,$stock_id,$stock_name){
|
||||
$rr=mysql_fetch_array(mysql_query("select id from ecmproducts where code like '".$index."' and deleted='0'"));
|
||||
$pid=$rr['id'];
|
||||
if($pid==""){
|
||||
$pid=addProduct($index,$name);
|
||||
}
|
||||
$oid=create_guid();
|
||||
|
||||
$arr=array(
|
||||
"id"=>$oid,
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"deleted"=>0,
|
||||
"modified_user_id"=>1,
|
||||
"assigned_user_id"=>1,
|
||||
"created_by"=>1,
|
||||
"stock_id"=>$stock_id,
|
||||
"stock_name"=>$stock_name,
|
||||
"product_id"=>$pid,
|
||||
"product_name"=>str_replace("'",""",$name),
|
||||
"product_code"=>str_replace("'",""",$index),
|
||||
"quantity"=>abs($qty),
|
||||
"price"=>$price,
|
||||
"parent_type"=>$doc_type,
|
||||
"parent_name"=>str_replace("'",""",$doc_name),
|
||||
"parent_id"=>$doc_id,
|
||||
"documentitem_id"=>$item_id,
|
||||
"type"=>$type,
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
mysql_query("insert into ecmstockoperations set ".implode(",",$in));
|
||||
return $oid;
|
||||
}
|
||||
?>
|
||||
6
modules/EcmStockStates/index.php
Executable file
6
modules/EcmStockStates/index.php
Executable file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
require_once('modules/EcmStockStates/ListView.php');
|
||||
|
||||
?>
|
||||
101
modules/EcmStockStates/inventory_value_report.php
Normal file
101
modules/EcmStockStates/inventory_value_report.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
$db = $GLOBALS['db'];
|
||||
|
||||
//get out
|
||||
$out_query = "
|
||||
select
|
||||
sum(so.quantity) as qty,
|
||||
sum(so.quantity*price) as total,
|
||||
so.stock_id,
|
||||
p.group_ks
|
||||
from
|
||||
ecmstockoperations as so
|
||||
inner join
|
||||
ecmproducts as p on p.id=so.product_id
|
||||
where
|
||||
so.type = 1
|
||||
group by
|
||||
so.stock_id, p.group_ks;
|
||||
";
|
||||
|
||||
$res_out = $db->query($out_query);
|
||||
|
||||
|
||||
$in_query = "
|
||||
select
|
||||
sum(so.quantity) as qty,
|
||||
sum(so.quantity*price) as total,
|
||||
so.stock_id,
|
||||
p.group_ks
|
||||
from
|
||||
ecmstockoperations as so
|
||||
inner join
|
||||
ecmproducts as p on p.id=so.product_id
|
||||
where
|
||||
so.type = 0
|
||||
group by
|
||||
so.stock_id, p.group_ks;
|
||||
";
|
||||
|
||||
$res = $db->query($in_query);
|
||||
|
||||
|
||||
$rd = array(); //report data
|
||||
|
||||
$total = 0;
|
||||
$total_qty = 0;
|
||||
while ($row = $db->fetchByAssoc($res)) {
|
||||
if (!$rd[$row['stock_id']])
|
||||
$rd[$row['stock_id']] = array();
|
||||
if (!$rd[$row['stock_id']][$row['group_ks']])
|
||||
$rd[$row['stock_id']][$row['group_ks']] = array();
|
||||
$rd[$row['stock_id']][$row['group_ks']]['qty'] = $row['qty'];
|
||||
$rd[$row['stock_id']][$row['group_ks']]['total'] = $row['total'];
|
||||
$total+=$row['total'];
|
||||
$total_qty+=$row['qty'];
|
||||
}
|
||||
|
||||
while ($row = $db->fetchByAssoc($res_out)) {
|
||||
$rd[$row['stock_id']][$row['group_ks']]['qty'] -= $row['qty'];
|
||||
$rd[$row['stock_id']][$row['group_ks']]['total'] -= $row['total'];
|
||||
$total-=$row['total'];
|
||||
$total_qty-=$row['qty'];
|
||||
}
|
||||
|
||||
echo '<table cellpadding="0" cellspacing="0" border="0" style=""><tr><td class="listViewThS1" style=text-align:center; "width:250px; height:48px;">Ilość całkowita</td><td class="listViewThS1" style=text-align:center; "width:250px; height:48px;">Wartość całkowita</td></tr>';
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td class="oddListRowS1" style="text-align:center; width:250px; border-bottom: 1px solid #cccccc;">'.$total_qty.'</td>';
|
||||
echo '<td class="oddListRowS1" style="text-align:center; width:250px; border-bottom: 1px solid #cccccc;">'.format_number($total).'</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
|
||||
foreach ($rd as $stock_id=>$stock_data) {
|
||||
$s = $db->fetchByAssoc($db->query("SELECT name FROM ecmstocks WHERE id='$stock_id'"));
|
||||
echo '<br><br><h2>'.$s['name'].'</h2><br><br>';
|
||||
echo '<table cellpadding="0" cellspacing="0" border="0" style=""><tr><td class="listViewThS1" style=text-align:center; "width:250px; height:48px;">Grupa KS</td><td class="listViewThS1" style=text-align:center; "width:250px; height:48px;">Ilość</td><td class="listViewThS1" style=text-align:center; "width:250px; height:48px;">Wartość</td></tr>';
|
||||
|
||||
$stock_total = 0;
|
||||
$stock_qty = 0;
|
||||
foreach ($stock_data as $group_ks=>$value) {
|
||||
echo '<tr>';
|
||||
echo '<td class="oddListRowS1" style="text-align:center; width:250px; border-bottom: 1px solid #cccccc;">'.$group_ks.'</td>';
|
||||
echo '<td class="oddListRowS1" style="text-align:center; width:250px; border-bottom: 1px solid #cccccc;">'.format_number($value['qty']).'</td>';
|
||||
echo '<td class="oddListRowS1" style="text-align:center; width:250px; border-bottom: 1px solid #cccccc;">'.format_number($value['total']).'</td>';
|
||||
echo '</tr>';
|
||||
|
||||
$stock_total+=$value['total'];
|
||||
$stock_qty+=$value['qty'];
|
||||
}
|
||||
|
||||
//total row
|
||||
echo '<tr>';
|
||||
echo '<td class="oddListRowS1" style="text-align:center; width:250px; border-bottom: 1px solid #cccccc;">Suma</td>';
|
||||
echo '<td class="oddListRowS1" style="text-align:center; width:250px; border-bottom: 1px solid #cccccc;">'.format_number($stock_qty).'</td>';
|
||||
echo '<td class="oddListRowS1" style="text-align:center; width:250px; border-bottom: 1px solid #cccccc;">'.format_number($stock_total).'</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
?>
|
||||
95
modules/EcmStockStates/language/en_us.lang.php
Executable file
95
modules/EcmStockStates/language/en_us.lang.php
Executable file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: Defines the English language pack for the base application.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
$mod_strings = array (
|
||||
'LBL_QUANTITY' => 'Quantity',
|
||||
'LBL_LIST_PRODUCT_CODE'=>'Index',
|
||||
'LBL_PRODUCT_CODE'=>'Index',
|
||||
'LBL_PRODUCT_NAME' => 'Product',
|
||||
'LBL_STOCK_NAME' => 'Inventory',
|
||||
'LBL_DATE' => 'Date',
|
||||
'LBL_PRICE' => 'Price',
|
||||
'LBL_TYPE' => 'Type',
|
||||
'LBL_LIST_PRODUCT_NAME' => 'Product',
|
||||
'LBL_LIST_STOCK_NAME' => 'Inventory',
|
||||
'LBL_LIST_DATE' => 'Date',
|
||||
'LBL_LIST_PRICE' => 'Price',
|
||||
'LBL_LIST_TYPE' => 'Type',
|
||||
'LBL_LIST_QUANTITY' => 'Quantity',
|
||||
'LBL_LIST_DOCUMENT_NAME' => 'Document',
|
||||
|
||||
'LBL_ASSIGNED_TO_ID' => 'Assigned To',
|
||||
'LBL_MODULE_NAME' => 'Inventory States',
|
||||
'LBL_MODULE_TITLE' => 'Inventory States: Home',
|
||||
'LBL_MODULE_ID' => 'Inventory States',
|
||||
'LBL_SEARCH_FORM_TITLE' => 'Inventory States Search',
|
||||
'LBL_LIST_FORM_TITLE' => 'Inventory States List',
|
||||
'LBL_NEW_FORM_TITLE' => 'New Inventory State',
|
||||
'LBL_SUBJECT' => 'Subject:',
|
||||
'LBL_ECMSTOCKSTATE' => 'Inventory State:',
|
||||
'LBL_ECMSTOCKSTATE_SUBJECT' => 'Inventory State Subject:',
|
||||
'LBL_LIST_SUBJECT' => 'Name',
|
||||
'LBL_LIST_LAST_MODIFIED' => 'Last Modified',
|
||||
'LNK_NEW_ECMSTOCKSTATE' => 'Create Inventory State',
|
||||
'LNK_ECMSTOCKSTATE_LIST' => 'Inventory States',
|
||||
'ERR_DELETE_RECORD' => 'You must specify a record number in order to delete the vat.',
|
||||
'LBL_LIST_MY_ECMSTOCKSTATES' => 'My Assigned Inventory States',
|
||||
|
||||
'LBL_CREATED_BY' => 'Created by:',
|
||||
'LBL_DATE_CREATED' => 'Create Date:',
|
||||
'LBL_MODIFIED_BY' => 'Last Modified by:',
|
||||
'LBL_DATE_LAST_MODIFIED' => 'Modify Date:',
|
||||
|
||||
'LBL_DEFAULT_SUBPANEL_TITLE' => 'Inventory States',
|
||||
'LBL_SYSTEM_ID' => 'System ID',
|
||||
'LBL_LIST_ASSIGNED_TO_NAME' => 'Assigned User',
|
||||
'LBL_LIST_VALUE' => 'Value',
|
||||
'LBL_ASSIGNED_TO_NAME' => 'Assigned to',
|
||||
'LBL_NEW_FIELD' => 'Test',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
);
|
||||
?>
|
||||
79
modules/EcmStockStates/language/ge_ge.lang.php
Executable file
79
modules/EcmStockStates/language/ge_ge.lang.php
Executable file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: Defines the English language pack for the base application.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
$mod_strings = array (
|
||||
'LBL_ASSIGNED_TO_ID' => 'Assigned To',
|
||||
'LBL_VALUE' => 'Value',
|
||||
'LBL_MODULE_NAME' => 'Vat',
|
||||
'LBL_MODULE_TITLE' => 'Vat: Home',
|
||||
'LBL_MODULE_ID' => 'Vat',
|
||||
'LBL_SEARCH_FORM_TITLE' => 'Vat Search',
|
||||
'LBL_LIST_FORM_TITLE' => 'Vat List',
|
||||
'LBL_NEW_FORM_TITLE' => 'New Vat',
|
||||
'LBL_SUBJECT' => 'Subject:',
|
||||
'LBL_ECMSTOCKSTATE' => 'Vat:',
|
||||
'LBL_ECMSTOCKSTATE_SUBJECT' => 'Vat Subject:',
|
||||
'LBL_LIST_SUBJECT' => 'Name',
|
||||
'LBL_LIST_LAST_MODIFIED' => 'Last Modified',
|
||||
'LNK_NEW_ECMSTOCKSTATE' => 'Create Vat',
|
||||
'LNK_ECMSTOCKSTATE_LIST' => 'Vat',
|
||||
'ERR_DELETE_RECORD' => 'You must specify a record number in order to delete the vat.',
|
||||
'LBL_LIST_MY_ECMSTOCKSTATES' => 'My Assigned Vat',
|
||||
|
||||
'LBL_CREATED_BY' => 'Created by:',
|
||||
'LBL_DATE_CREATED' => 'Create Date:',
|
||||
'LBL_MODIFIED_BY' => 'Last Modified by:',
|
||||
'LBL_DATE_LAST_MODIFIED' => 'Modify Date:',
|
||||
|
||||
'LBL_DEFAULT_SUBPANEL_TITLE' => 'Vat',
|
||||
'LBL_SYSTEM_ID' => 'System ID',
|
||||
'LBL_LIST_ASSIGNED_TO_NAME' => 'Assigned User',
|
||||
'LBL_LIST_VALUE' => 'Value',
|
||||
'LBL_ASSIGNED_TO_NAME' => 'Assigned to',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
);
|
||||
?>
|
||||
94
modules/EcmStockStates/language/pl_pl.lang.php
Executable file
94
modules/EcmStockStates/language/pl_pl.lang.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: Defines the English language pack for the base application.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
$mod_strings = array (
|
||||
'LBL_QUANTITY'=>'Ilosc',
|
||||
'LBL_PRODUCT_CODE' => 'Indeks',
|
||||
'LBL_LIST_PRODUCT_CODE' => 'Indeks',
|
||||
'LBL_PRODUCT_NAME' => 'Produkt',
|
||||
'LBL_STOCK_NAME' => 'Magazyn',
|
||||
'LBL_DATE' => 'Data',
|
||||
'LBL_PRICE' => 'Cena',
|
||||
'LBL_TYPE' => 'Typ',
|
||||
'LBL_LIST_PRODUCT_NAME' => 'Produkt',
|
||||
'LBL_LIST_STOCK_NAME' => 'Magazyn',
|
||||
'LBL_LIST_DATE' => 'Data',
|
||||
'LBL_LIST_PRICE' => 'Cena',
|
||||
'LBL_LIST_TYPE' => 'Typ',
|
||||
'LBL_LIST_QUANTITY' => 'Ilosc',
|
||||
'LBL_LIST_DOCUMENT_NAME' => 'Dokument',
|
||||
'LBL_LIST_PARENT_TYPE' => 'Typ Dokumentu',
|
||||
|
||||
'LBL_ASSIGNED_TO_ID' => 'Przypisany Do',
|
||||
'LBL_MODULE_NAME' => 'Stany Magazynowe',
|
||||
'LBL_MODULE_TITLE' => 'Stany Magazynowe: Strona Glówna',
|
||||
'LBL_MODULE_ID' => 'Stany Magazynowe',
|
||||
'LBL_SEARCH_FORM_TITLE' => 'Wyszukiwanie',
|
||||
'LBL_LIST_FORM_TITLE' => 'Lista Stanów Magazynowych',
|
||||
'LBL_NEW_FORM_TITLE' => 'Nowa Operacja Magazynowa',
|
||||
'LBL_SUBJECT' => 'Tytul:',
|
||||
'LBL_ECMSTOCKSTATE' => 'Operacja Magazynowa:',
|
||||
'LBL_ECMSTOCKSTATE_SUBJECT' => 'Tytul Stanu Magazynowego:',
|
||||
'LBL_LIST_SUBJECT' => 'Nazwa',
|
||||
'LBL_LIST_LAST_MODIFIED' => 'Ostatnio Modyfikowane',
|
||||
'LNK_NEW_ECMSTOCKSTATE' => 'Utwórz Stan Magazynowy',
|
||||
'LNK_ECMSTOCKSTATE_LIST' => 'Stany Magazynowe',
|
||||
'LBL_LIST_MY_ECMSTOCKSTATES' => 'Moje Przypisane Stany Magazynowe',
|
||||
|
||||
'LBL_CREATED_BY' => 'Utworzeone Przez:',
|
||||
'LBL_DATE_CREATED' => 'Data Utworzenia:',
|
||||
'LBL_MODIFIED_BY' => 'Ostatnio Modyfikowane Przez:',
|
||||
'LBL_DATE_LAST_MODIFIED' => 'Data Modyfikacji:',
|
||||
|
||||
'LBL_DEFAULT_SUBPANEL_TITLE' => 'Stany Magazynowe',
|
||||
'LBL_SYSTEM_ID' => 'System ID',
|
||||
'LBL_LIST_ASSIGNED_TO_NAME' => 'Przypisany Uzytkownik',
|
||||
'LBL_ASSIGNED_TO_NAME' => 'Przypisane Do',
|
||||
'LBL_NEW_FIELD' => 'Test',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
);
|
||||
?>
|
||||
42
modules/EcmStockStates/metadata/SearchFields.php
Executable file
42
modules/EcmStockStates/metadata/SearchFields.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
$searchFields['EcmStockStates'] =
|
||||
array (
|
||||
'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true),
|
||||
'assigned_user_id'=> array('query_type'=>'default'),
|
||||
);
|
||||
?>
|
||||
64
modules/EcmStockStates/metadata/additionalDetails.php
Executable file
64
modules/EcmStockStates/metadata/additionalDetails.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*********************************************************************************/
|
||||
|
||||
require_once('include/utils.php');
|
||||
|
||||
function additionalDetailsEcmStockState($fields) {
|
||||
static $mod_strings;
|
||||
global $app_strings;
|
||||
if(empty($mod_strings)) {
|
||||
global $current_language;
|
||||
$mod_strings = return_module_language($current_language, 'EcmStockStates');
|
||||
}
|
||||
|
||||
$overlib_string = '';
|
||||
|
||||
if(!empty($fields['DATE_ENTERED']))
|
||||
$overlib_string .= '<b>'. $app_strings['LBL_DATE_ENTERED'] . '</b> ' . $fields['DATE_ENTERED'] . '<br>';
|
||||
if(!empty($fields['NAME']))
|
||||
$overlib_string .= '<b>'. $mod_strings['LBL_NAME'] . '</b> ' . $fields['NAME'] . '<br>';
|
||||
|
||||
return array('fieldToAddTo' => 'NAME',
|
||||
'string' => $overlib_string,
|
||||
'editLink' => "index.php?action=EditView&module=EcmStockStates&return_module=EcmStockStates&record={$fields['ID']}",
|
||||
'viewLink' => "index.php?action=DetailView&module=EcmStockStates&return_module=EcmStockStates&record={$fields['ID']}");
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
67
modules/EcmStockStates/metadata/detailviewdefs.php
Executable file
67
modules/EcmStockStates/metadata/detailviewdefs.php
Executable file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
$viewdefs['EcmStockStates']['DetailView'] = array(
|
||||
'templateMeta'=>array(
|
||||
'form'=>array(
|
||||
'buttons'=>array(
|
||||
'EDIT',
|
||||
'DUPLICATE',
|
||||
'DELETE',
|
||||
)
|
||||
),
|
||||
'maxColumns'=>'2',
|
||||
'widths'=>array(
|
||||
array(
|
||||
'label'=>'10',
|
||||
'field' =>'30'
|
||||
),
|
||||
array(
|
||||
'label'=>'10',
|
||||
'field'=>'30'
|
||||
)
|
||||
),
|
||||
),
|
||||
'panels'=>array(
|
||||
array(
|
||||
'name',
|
||||
'assigned_user_name',
|
||||
),
|
||||
array(
|
||||
'value',
|
||||
),
|
||||
)
|
||||
);
|
||||
?>
|
||||
52
modules/EcmStockStates/metadata/editviewdefs.php
Executable file
52
modules/EcmStockStates/metadata/editviewdefs.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
$viewdefs['EcmStockStates']['EditView'] = array(
|
||||
'templateMeta'=>array(
|
||||
'form' => array('buttons'=>array('SAVE', 'CANCEL')),
|
||||
'maxColumns'=>'2',
|
||||
'widths'=>array(
|
||||
array('label'=>'10','field'=>'30'),
|
||||
array('label'=>'10','field'=>'30'),
|
||||
),
|
||||
),
|
||||
'panels'=>array(
|
||||
'default'=>array(
|
||||
array('name','assigned_user_name'),
|
||||
array('value'),
|
||||
),
|
||||
),
|
||||
);
|
||||
?>
|
||||
94
modules/EcmStockStates/metadata/listviewdefs.php
Executable file
94
modules/EcmStockStates/metadata/listviewdefs.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
$listViewDefs['EcmStockStates'] = array(
|
||||
'PRODUCT_ID' => array(
|
||||
'width'=>'1',
|
||||
'sortable'=>false,
|
||||
'label'=>' ',
|
||||
'customCode'=>' ',
|
||||
'default'=>true,
|
||||
),
|
||||
'PRODUCT_CODE' => array(
|
||||
'width'=>'10',
|
||||
'label'=>'LBL_LIST_PRODUCT_CODE',
|
||||
'default'=>true,
|
||||
),
|
||||
'PRODUCT_NAME' => array(
|
||||
'width' => '30',
|
||||
'label' => 'LBL_LIST_PRODUCT_NAME',
|
||||
'module'=>'EcmProducts',
|
||||
'id'=>'PRODUCT_ID',
|
||||
//'customCode'=>'<a href="index.php?module=EcmStockOperations&action=&query=true&searchFormTab=basic_search&product_id_basic={$PRODUCT_ID}&product_name_basic={$PRODUCT_NAME}&stock_id_basic={$STOCK_ID}&stock_name_basic={$STOCK_NAME}">{$PRODUCT_NAME}</a>',
|
||||
'default' => true,
|
||||
'link' => true),
|
||||
'STOCK_ID' => array(
|
||||
'width'=>'1',
|
||||
'sortable'=>false,
|
||||
'label'=>' ',
|
||||
'customCode'=>' ',
|
||||
'default'=>true,
|
||||
),
|
||||
'STOCK_NAME' => array(
|
||||
'width' => '15',
|
||||
'label' => 'LBL_LIST_STOCK_NAME',
|
||||
'module'=>'EcmStocks',
|
||||
'id'=>'STOCK_ID',
|
||||
'customCode'=>'<a href="index.php?module=EcmStockStates&action=&query=true&searchFormTab=basic_search&stock_id1_basic={$STOCK_ID}&stock_name_basic={$STOCK_NAME}">{$STOCK_NAME}</a>',
|
||||
'default' => true,
|
||||
'link' => true),
|
||||
'DATE_ENTERED' => array(
|
||||
'width' => '15',
|
||||
'label' => 'LBL_LIST_DATE',
|
||||
'default' => true),
|
||||
'PRICE' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_LIST_PRICE',
|
||||
'default' => true),
|
||||
'QUANTITY' => array(
|
||||
'width' => '5',
|
||||
'label' => 'LBL_LIST_QUANTITY',
|
||||
'default' => true),
|
||||
'NEW_FIELD' => array(
|
||||
'width' => '5',
|
||||
'label' => 'LBL_NEW_FIELD',
|
||||
'default' => true),
|
||||
);
|
||||
?>
|
||||
51
modules/EcmStockStates/metadata/metafiles.php
Executable file
51
modules/EcmStockStates/metadata/metafiles.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*
|
||||
* Created on Jun 1, 2007
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - PHPeclipse - PHP - Code Templates
|
||||
*/
|
||||
$metafiles['EcmStockStates'] = array(
|
||||
'detailviewdefs' => 'modules/EcmStockStates/metadata/detailviewdefs.php',
|
||||
'editviewdefs' => 'modules/EcmStockStates/metadata/editviewdefs.php',
|
||||
'listviewdefs' => 'modules/EcmStockStates/metadata/listviewdefs.php',
|
||||
'searchdefs' => 'modules/EcmStockStates/metadata/searchdefs.php',
|
||||
'popupdefs' => 'modules/EcmStockStates/metadata/popupdefs.php',
|
||||
'searchfields' => 'modules/EcmStockStates/metadata/SearchFields.php',
|
||||
|
||||
);
|
||||
?>
|
||||
67
modules/EcmStockStates/metadata/popupdefs.php
Executable file
67
modules/EcmStockStates/metadata/popupdefs.php
Executable file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
$popupMeta = array('moduleMain' => 'EcmStockState',
|
||||
'varName' => 'ECMSTOCKSTATE',
|
||||
'orderBy' => 'ecmstockstates.name',
|
||||
'whereClauses' =>
|
||||
array('name' => 'ecmstockstates.name'),
|
||||
'listviewdefs' => array(
|
||||
'NAME' => array(
|
||||
'width' => '32',
|
||||
'label' => 'LBL_LIST_SUBJECT',
|
||||
'default' => true,
|
||||
'link' => true),
|
||||
'VALUE' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_LIST_VALUE',
|
||||
'default' => true),
|
||||
'ASSIGNED_USER_NAME' => array(
|
||||
'width' => '9',
|
||||
'label' => 'LBL_LIST_ASSIGNED_USER',
|
||||
'default' => true)
|
||||
|
||||
),
|
||||
'searchdefs' => array(
|
||||
'name',
|
||||
'value',
|
||||
array('name' => 'assigned_user_id', 'type' => 'enum', 'label' => 'LBL_ASSIGNED_TO', 'function' => array('name' => 'get_user_array', 'params' => array(false))),
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
||||
|
||||
63
modules/EcmStockStates/metadata/searchdefs.php
Executable file
63
modules/EcmStockStates/metadata/searchdefs.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*
|
||||
* Created on May 29, 2007
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - PHPeclipse - PHP - Code Templates
|
||||
*/
|
||||
$searchdefs['EcmStockStates'] = array(
|
||||
'templateMeta' => array(
|
||||
'maxColumns' => '3',
|
||||
'widths' => array('label' => '10', 'field' => '30'),
|
||||
),
|
||||
'layout' => array(
|
||||
'basic_search' => array(
|
||||
'product_code',
|
||||
'product_name',
|
||||
'stock_id',
|
||||
),
|
||||
'advanced_search' => array(
|
||||
'product_code',
|
||||
'product_name',
|
||||
'stock_id',
|
||||
'price',
|
||||
'date_entered',
|
||||
'quantity',
|
||||
),
|
||||
),
|
||||
);
|
||||
?>
|
||||
71
modules/EcmStockStates/metadata/sidecreateviewdefs.php
Executable file
71
modules/EcmStockStates/metadata/sidecreateviewdefs.php
Executable file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*********************************************************************************/
|
||||
$viewdefs['EcmStockStates']['SideQuickCreate'] = array(
|
||||
'templateMeta' => array('form'=>array('buttons'=>array('SAVE'),
|
||||
'button_location'=>'bottom',
|
||||
'headerTpl'=>'include/EditView/header.tpl',
|
||||
'footerTpl'=>'include/EditView/footer.tpl',
|
||||
),
|
||||
'maxColumns' => '1',
|
||||
'panelClass'=>'none',
|
||||
|
||||
'labelsOnTop'=>true,
|
||||
'widths' => array(
|
||||
array('label' => '10', 'field' => '30'),
|
||||
),
|
||||
),
|
||||
'panels' =>array (
|
||||
'DEFAULT' =>
|
||||
array (
|
||||
array (
|
||||
array('name'=>'name', 'displayParams'=>array('size'=>20, 'required'=>true)),
|
||||
),
|
||||
array(
|
||||
array('name'=>'value', 'displayParams'=>array('size'=>20)),
|
||||
),
|
||||
array (
|
||||
array('name'=>'assigned_user_name', 'displayParams'=>array('required'=>true, 'size'=>11, 'selectOnly'=>true)),
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
)
|
||||
|
||||
|
||||
);
|
||||
|
||||
?>
|
||||
65
modules/EcmStockStates/metadata/studio.php
Executable file
65
modules/EcmStockStates/metadata/studio.php
Executable file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
|
||||
|
||||
$GLOBALS['studioDefs']['EcmStockStates'] = array(
|
||||
'LBL_DETAILVIEW'=>array(
|
||||
'template'=>'xtpl',
|
||||
'template_file'=>'modules/EcmStockStates/DetailView.html',
|
||||
'php_file'=>'modules/EcmStockStates/DetailView.php',
|
||||
'type'=>'DetailView',
|
||||
),
|
||||
'LBL_EDITVIEW'=>array(
|
||||
'template'=>'xtpl',
|
||||
'template_file'=>'modules/EcmStockStates/EditView.html',
|
||||
'php_file'=>'modules/EcmStockStates/EditView.php',
|
||||
'type'=>'EditView',
|
||||
),
|
||||
'LBL_LISTVIEW'=>array(
|
||||
'template'=>'listview',
|
||||
'meta_file'=>'modules/EcmStockStates/listviewdefs.php',
|
||||
'type'=>'ListView',
|
||||
),
|
||||
'LBL_SEARCHFORM'=>array(
|
||||
'template'=>'xtpl',
|
||||
'template_file'=>'modules/EcmStockStates/SearchForm.html',
|
||||
'php_file'=>'modules/EcmStockStates/ListView.php',
|
||||
'type'=>'SearchForm',
|
||||
),
|
||||
|
||||
);
|
||||
42
modules/EcmStockStates/metadata/subpaneldefs.php
Executable file
42
modules/EcmStockStates/metadata/subpaneldefs.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* Layout definition for EcmStockStates
|
||||
*
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
$layout_defs['EcmStockStates']['subpanel_setup'] = array(
|
||||
);
|
||||
?>
|
||||
91
modules/EcmStockStates/metadata/subpanels/default.php
Executable file
91
modules/EcmStockStates/metadata/subpanels/default.php
Executable file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* Subpanel Layout definition for EcmStockStates
|
||||
*
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
|
||||
$subpanel_layout = array(
|
||||
'top_buttons' => array(
|
||||
array('widget_class' => 'SubPanelTopCreateButton'),
|
||||
array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'EcmStockStates'),
|
||||
),
|
||||
|
||||
'where' => '',
|
||||
|
||||
|
||||
|
||||
'list_fields' => array(
|
||||
'ecmstockstate_number'=>array(
|
||||
'vname' => 'LBL_LIST_NUMBER',
|
||||
'width' => '5%',
|
||||
),
|
||||
|
||||
'name'=>array(
|
||||
'vname' => 'LBL_LIST_SUBJECT',
|
||||
'widget_class' => 'SubPanelDetailViewLink',
|
||||
'width' => '50%',
|
||||
),
|
||||
'status'=>array(
|
||||
'vname' => 'LBL_LIST_STATUS',
|
||||
'width' => '15%',
|
||||
),
|
||||
'type'=>array(
|
||||
'vname' => 'LBL_LIST_TYPE',
|
||||
'width' => '15%',
|
||||
),
|
||||
'priority'=>array(
|
||||
'vname' => 'LBL_LIST_PRIORITY',
|
||||
'width' => '11%',
|
||||
),
|
||||
'assigned_user_name' => array (
|
||||
'name' => 'assigned_user_name',
|
||||
'vname' => 'LBL_LIST_ASSIGNED_TO_NAME',
|
||||
),
|
||||
'edit_button'=>array(
|
||||
'widget_class' => 'SubPanelEditButton',
|
||||
'module' => 'EcmStockStates',
|
||||
'width' => '4%',
|
||||
),
|
||||
'remove_button'=>array(
|
||||
'widget_class' => 'SubPanelRemoveButton',
|
||||
'module' => 'EcmStockStates',
|
||||
'width' => '5%',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
?>
|
||||
60
modules/EcmStockStates/op.php
Executable file
60
modules/EcmStockStates/op.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
set_time_limit(9999999999);
|
||||
|
||||
include_once("class.dbf.php");
|
||||
include_once("helper.php");
|
||||
|
||||
$sql=mysql_connect("localhost","root","");
|
||||
mysql_select_db("saascrm");
|
||||
mysql_query("set names utf8");
|
||||
mysql_query("truncate table ecmstockoperations");
|
||||
mysql_query("truncate table ecmstockdocins");
|
||||
mysql_query("truncate table ecmstockdocinitems");
|
||||
|
||||
$re="RE00018";
|
||||
|
||||
$w=mysql_query("select id,name,dir from ecmstocks where deleted='0'");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
addPzBilans("PZ 20091006001",$r['id']);
|
||||
|
||||
$dbf = new dbf_class("klk/".$r['dir']."/_stany.dbf");
|
||||
$num_rec=$dbf->dbf_num_rec;
|
||||
|
||||
$dbfp = new dbf_class("klk/".$r['dir']."/_struk.dbf");
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
$products=array();
|
||||
for($j=0;$j<$num_recp;$j++){
|
||||
$rowp = $dbfp->getRowAssoc($j);
|
||||
$products[$rowp['NR_SYSTEM']][]=$rowp;
|
||||
}
|
||||
|
||||
$n=1;
|
||||
for($i=0;$i<$num_rec;$i++){
|
||||
$row = $dbf->getRowAssoc($i);
|
||||
//if($re!=$row['INDEKS'])continue;
|
||||
$scena=$row['CENA'];
|
||||
$silosc=$row['STAN'];
|
||||
$index=$row['INDEKS'];
|
||||
$rr=mysql_fetch_array(mysql_query("select name from ecmproducts where code like '".ch($index)."' and deleted='0'"));
|
||||
$name=$rr['name'];
|
||||
$cena=0;
|
||||
$ilosc=0;
|
||||
if(count($products[$row['NR_SYSTEM']])>0){
|
||||
foreach($products[$row['NR_SYSTEM']] as $prod){
|
||||
if($prod['ILOSC']>0){
|
||||
addOperation("bilans_otwarcia".$r['id'],"PZ 20091006001","EcmStockDocIn",1,ch($index),ch($name),$prod['ILOSC'],$prod['CENA_ZAK'],0,$r['id'],$r['name']);
|
||||
addProductLinePZ("bilans_otwarcia".$r['id'],$n,$prod,ch($index),ch($name));
|
||||
$n++;
|
||||
$cena+=(int)$prod['ILOSC']*$prod['CENA_ZAK'];
|
||||
$ilosc+=(int)$prod['ILOSC'];
|
||||
$sum+=$ilosc*$cena;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo $i."/".$num_rec." ".$r['dir']." ".$ilosc." = ".round($silosc,0)."\n";
|
||||
}
|
||||
mysql_query("update ecmstockdocins set total='".$sum."',subtotal='".$sum."'");
|
||||
}
|
||||
//echo round(($cena/$ilosc),2)." = ".$scena."\n".$ilosc." = ".$silosc;
|
||||
mysql_close($sql);
|
||||
?>
|
||||
133
modules/EcmStockStates/pz.php
Executable file
133
modules/EcmStockStates/pz.php
Executable file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
set_time_limit(9999999999);
|
||||
$sql=mysql_connect("localhost","root","");
|
||||
mysql_select_db("saascrm");
|
||||
mysql_query("set names utf8");
|
||||
mysql_query("truncate table ecmstockdocins");
|
||||
mysql_query("truncate table ecmstockdocinitems");
|
||||
|
||||
function addPz($row,$i,$stock_id){
|
||||
$r=mysql_fetch_array(mysql_query("select id from accounts where name like '%".$row['PLATNIK']."%' and deleted='0'"));
|
||||
$parent_id=$r['id'];
|
||||
$rd=$row['DATA'];
|
||||
$a1=explode(" ",$row['ADRES1']);
|
||||
$r=mysql_fetch_array(mysql_query("select id from ecmstockdocins where name like 'PZ ".$row['KOR_DO_WZ']."' and deleted='0'"));
|
||||
$correct_id=$r['id'];
|
||||
if($correct_id)$pre="PZKOR";
|
||||
else $pre="PZ";
|
||||
$id=create_guid();
|
||||
$arr=array(
|
||||
"id"=>$id,
|
||||
"name"=>$pre." ".$row['NR_PZ'],
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"document_no"=>"PZ ".$row['NR_PZ'],
|
||||
"number"=>($i+1),
|
||||
"modified_user_id"=>1,
|
||||
"assigned_user_id"=>1,
|
||||
"created_by"=>1,
|
||||
"parent_name"=>$row['DOSTAWCA'],
|
||||
"parent_id"=>$parent_id,
|
||||
"status"=>"accepted",
|
||||
"register_date"=>$rd[0].$rd[1].$rd[2].$rd[3]."-".$rd[4].$rd[5]."-".$rd[6].$rd[7],
|
||||
"parent_address_street"=>$row['ADRES2'],
|
||||
"parent_address_city"=>$a1[1],
|
||||
"parent_address_postalcode"=>$a1[0],
|
||||
"subtotal"=>($row['WARTOSC_ZAK']),
|
||||
"total"=>$row['WARTOSC_ZAK'],
|
||||
"discount"=>0,
|
||||
"ecmlanguage"=>"pl_pl",
|
||||
"template_id"=>"1d178dc6-0904-3fa3-f51b-4a4b4698a173",
|
||||
"template_name"=>"E5 Polska Sp. z o. o.",
|
||||
"stock_id"=>$stock_id,
|
||||
"currency_id"=>"PLN",
|
||||
"correct_id"=>$correct_id,
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
mysql_query("insert into ecmstockdocins set ".implode(",",$in));
|
||||
return $id;
|
||||
}
|
||||
|
||||
function addProductLine($id,$i,$r){
|
||||
$vats=array(
|
||||
0=>"9b783d21-5548-6653-e1d6-49610eb3f9dd",
|
||||
22=>"9c592a4a-2de0-1fa3-e082-494aeceb122c",
|
||||
7=>"bf3a5fec-435f-af22-024a-4958b51863c8",
|
||||
);
|
||||
$rr=mysql_fetch_array(mysql_query("select id from ecmproducts where code like '".$r['INDEKS']."' and deleted='0'"));
|
||||
$pid=$rr['id'];
|
||||
if($pid==""){
|
||||
$pid=addProduct($r['INDEKS'],$r['NAZWA']);
|
||||
}
|
||||
$iid=create_guid();
|
||||
if(!$r['RABAT'])$rabat=0;
|
||||
else $rabat=$r['RABAT'];
|
||||
$arr=array(
|
||||
"id"=>$iid,
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"deleted"=>0,
|
||||
"modified_user_id"=>1,
|
||||
"assigned_user_id"=>1,
|
||||
"created_by"=>1,
|
||||
"ecmstockdocin_id"=>$id,
|
||||
"ecmproduct_id"=>$pid,
|
||||
"position"=>$i,
|
||||
"code"=>$r['INDEKS'],
|
||||
"name"=>str_replace("'","",$r['NAZWA']),
|
||||
"quantity"=>$r['ILOSC'],
|
||||
"price"=>$r['CENA_ZAK'],
|
||||
"discount"=>$rabat,
|
||||
"total"=>$r['WART_ZAK'],
|
||||
"dd_unit_name"=>$r['NAZWA_J_M'],
|
||||
"dd_unit_id"=>1,
|
||||
"ecmvat_id"=>$vats[$r['VAT']],
|
||||
"ecmvat_value"=>$r['VAT'],
|
||||
"ecmvat_name"=>$r['VAT']."%",
|
||||
"currency_id"=>"PLN",
|
||||
"currency_name"=>"PLN",
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
mysql_query("insert into ecmstockdocinitems set ".implode(",",$in));
|
||||
if(mysql_error()){
|
||||
echo mysql_error()."\n".implode(",",$in);
|
||||
}
|
||||
return $iid;
|
||||
}
|
||||
|
||||
|
||||
include_once("class.dbf.php");
|
||||
include_once("helper.php");
|
||||
|
||||
$w=mysql_query("select id,name,dir from ecmstocks where deleted='0'");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
|
||||
$dbf = new dbf_class('klk/'.$r['dir'].'/_pz.dbf');
|
||||
$num_rec=$dbf->dbf_num_rec;
|
||||
|
||||
$dbfp = new dbf_class('klk/'.$r['dir'].'/_pz_list.dbf');
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
$n=0;
|
||||
for($i=0; $i<$num_rec; $i++){
|
||||
$row = $dbf->getRowAssoc($i);
|
||||
$id=addPz($row,$i,$r['id']);
|
||||
|
||||
echo $i."/".$num_rec." ".$r['dir']." [".$row['NR_PZ']."]\n";
|
||||
|
||||
for($j=$n; $j<$num_recp; $j++){
|
||||
$rowp = $dbfp->getRowAssoc($j);
|
||||
if($row['NR_SYSTEM']==$rowp['NR_SYSTEM']){
|
||||
$lid=addProductLine($id,$j,$rowp);
|
||||
$n++;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
}
|
||||
}
|
||||
mysql_close($sql);
|
||||
?>
|
||||
35
modules/EcmStockStates/rebuildState.php
Executable file
35
modules/EcmStockStates/rebuildState.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once("modules/EcmStockStates/EcmStockState.php");
|
||||
$ss=new EcmStockState();
|
||||
set_time_limit(1000000);
|
||||
|
||||
$codes=explode("|",$_GET['code']);
|
||||
|
||||
|
||||
$db = $GLOBALS['db'];
|
||||
foreach($codes as $code){
|
||||
if($code=="")continue;
|
||||
$z2=$db->query("update ecmstockoperations set used=0 where product_id in (
|
||||
|
||||
'554','322','360','586')");
|
||||
$z2=$db->query("select id from ecmproducts where id in (
|
||||
|
||||
'554','322','360','586'
|
||||
) and deleted=0");
|
||||
|
||||
while($p=$db->fetchByAssoc($z2)){
|
||||
|
||||
$w=$db->query("select id from ecmstocks where deleted='0'");
|
||||
while($r=$db->fetchByAssoc($w)){
|
||||
$ss->UpdateStockState($r['id'],$p['id']);
|
||||
echo "updated";
|
||||
}
|
||||
$w=$db->query("select quantity,stock_name,price,product_code from ecmstockstates where product_id='".$p['id']."' and deleted='0'");
|
||||
while($s=$db->fetchByAssoc($w)){
|
||||
echo $s['product_code']." ".$s['stock_name']." ".$s['quantity']." ".$s['price']."<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
52
modules/EcmStockStates/rebuildStates.php
Executable file
52
modules/EcmStockStates/rebuildStates.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?
|
||||
//return;
|
||||
|
||||
require_once("modules/EcmStockStates/EcmStockState.php");
|
||||
$ss=new EcmStockState();
|
||||
set_time_limit(1000000);
|
||||
//error_reporting(E_ALL);
|
||||
|
||||
$sarr=array();
|
||||
$parr=array();
|
||||
|
||||
// https://crm.e5.pl/index.php?module=EcmStockStates&action=rebuildStates&ids=2096adf3-d888-a84f-c7ec-59f810381701,75d70d0d-8f48-bf2c-3cd7-63a426511e9e,8f0d5583-468a-9c14-83b2-50a25be72052,cbead744-99e9-7d1c-0d7e-58622d8e6d8b,e95ac585-b616-b83f-e5e4-4ae5952dae8f
|
||||
|
||||
if (isset($_GET['ids'])) {
|
||||
$ids = explode(',', $_GET['ids']);
|
||||
$w=$GLOBALS['db']->query("SELECT so.stock_id, so.product_id FROM ecmstockoperations AS so
|
||||
INNER JOIN ecmproducts AS p ON p.id = so.product_id
|
||||
WHERE p.id IN ('".implode("','", $ids)."')
|
||||
ORDER BY so.date_entered");
|
||||
} else if (isset($_GET['codes'])) {
|
||||
$codes = explode(',', $_GET['codes']);
|
||||
$w=$GLOBALS['db']->query("SELECT so.stock_id, so.product_id FROM ecmstockoperations AS so
|
||||
INNER JOIN ecmproducts AS p ON p.id = so.product_id
|
||||
WHERE p.code IN ('".implode("','", $codes)."')
|
||||
ORDER BY so.date_entered");
|
||||
} else {
|
||||
$w=$GLOBALS['db']->query("
|
||||
select stock_id, product_id from ecmstockoperations
|
||||
order by date_entered");
|
||||
}
|
||||
|
||||
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
if(!in_array($r['stock_id'],$sarr))$sarr[]=$r['stock_id'];
|
||||
if(!in_array($r['product_id'],$parr))$parr[]=$r['product_id'];
|
||||
}
|
||||
|
||||
for($i=0;$i<count($parr);$i++){
|
||||
for($j=0;$j<count($sarr);$j++){
|
||||
if($parr[$j] && $sarr[$j])$ss->UpdateStockState($sarr[$j],$parr[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
function brecho() {
|
||||
echo '<pre>';
|
||||
foreach(func_get_args() as $obj) {
|
||||
print_r($obj);
|
||||
echo "<br>";
|
||||
}
|
||||
echo '</pre>';
|
||||
}
|
||||
?>
|
||||
13
modules/EcmStockStates/st.php
Executable file
13
modules/EcmStockStates/st.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?
|
||||
include_once("class.dbf.php");
|
||||
|
||||
$dbf=new dbf_class("klk/_stany.dbf");
|
||||
$num_rec=$dbf->dbf_num_rec;
|
||||
for($i=0;$i<$num_rec;$i++){
|
||||
$row=$dbf->getRowAssoc($i);
|
||||
$w[$row['INDEKS']]++;
|
||||
}
|
||||
foreach($w as $k=>$v){
|
||||
if($v>0)echo $v." = ".$k."\n";
|
||||
}
|
||||
?>
|
||||
191
modules/EcmStockStates/stany.php
Executable file
191
modules/EcmStockStates/stany.php
Executable file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
require_once("config.php");
|
||||
$sql1=mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
|
||||
mysql_select_db($sugar_config['dbconfig']['db_name']);
|
||||
|
||||
class dbf_class {
|
||||
|
||||
var $dbf_num_rec; //Number of records in the file
|
||||
var $dbf_num_field; //Number of columns in each row
|
||||
var $dbf_names = array(); //Information on each column ['name'],['len'],['type']
|
||||
//These are private....
|
||||
var $_raw; //The raw input file
|
||||
var $_rowsize; //Length of each row
|
||||
var $_hdrsize; //Length of the header information (offset to 1st record)
|
||||
var $_memos; //The raw memo file (if there is one).
|
||||
|
||||
function dbf_class($filename) {
|
||||
if ( !file_exists($filename)) {
|
||||
echo 'Not a valid DBF file !!!'; exit;
|
||||
}
|
||||
$tail=substr($filename,-4);
|
||||
if (strcasecmp($tail, '.dbf')!=0) {
|
||||
echo 'Not a valid DBF file !!!'; exit;
|
||||
}
|
||||
|
||||
//Read the File
|
||||
$handle = fopen($filename, "r");
|
||||
if (!$handle) { echo "Cannot read DBF file"; exit; }
|
||||
$filesize = filesize($filename);
|
||||
$this->_raw = fread ($handle, $filesize);
|
||||
fclose ($handle);
|
||||
//Make sure that we indeed have a dbf file...
|
||||
if(!(ord($this->_raw[0]) == 3 || ord($this->_raw[0]) == 131) && ord($this->_raw[$filesize]) != 26) {
|
||||
echo 'Not a valid DBF file !!!'; exit;
|
||||
}
|
||||
// 3= file without DBT memo file; 131 ($83)= file with a DBT.
|
||||
$arrHeaderHex = array();
|
||||
for($i=0; $i<32; $i++){
|
||||
$arrHeaderHex[$i] = str_pad(dechex(ord($this->_raw[$i]) ), 2, "0", STR_PAD_LEFT);
|
||||
}
|
||||
//Initial information
|
||||
$line = 32;//Header Size
|
||||
//Number of records
|
||||
$this->dbf_num_rec= hexdec($arrHeaderHex[7].$arrHeaderHex[6].$arrHeaderHex[5].$arrHeaderHex[4]);
|
||||
$this->_hdrsize= hexdec($arrHeaderHex[9].$arrHeaderHex[8]);//Header Size+Field Descriptor
|
||||
//Number of fields
|
||||
$this->_rowsize = hexdec($arrHeaderHex[11].$arrHeaderHex[10]);
|
||||
$this->dbf_num_field = floor(($this->_hdrsize - $line ) / $line ) ;//Number of Fields
|
||||
|
||||
//Field properties retrieval looping
|
||||
for($j=0; $j<$this->dbf_num_field; $j++){
|
||||
$name = '';
|
||||
$beg = $j*$line+$line;
|
||||
for($k=$beg; $k<$beg+11; $k++){
|
||||
if(ord($this->_raw[$k])!=0){
|
||||
$name .= $this->_raw[$k];
|
||||
}
|
||||
}
|
||||
$this->dbf_names[$j]['name']= $name;//Name of the Field
|
||||
$this->dbf_names[$j]['len']= ord($this->_raw[$beg+16]);//Length of the field
|
||||
$this->dbf_names[$j]['type']= $this->_raw[$beg+11];
|
||||
}
|
||||
if (ord($this->_raw[0])==131) { //See if this has a memo file with it...
|
||||
//Read the File
|
||||
$tail=substr($tail,-1,1); //Get the last character...
|
||||
if ($tail=='F'){ //See if upper or lower case
|
||||
$tail='T'; //Keep the case the same
|
||||
} else {
|
||||
$tail='t';
|
||||
}
|
||||
$memoname = substr($filename,0,strlen($filename)-1).$tail;
|
||||
$handle = fopen($memoname, "r");
|
||||
if (!$handle) { echo "Cannot read DBT file"; exit; }
|
||||
$filesize = filesize($memoname);
|
||||
$this->_memos = fread ($handle, $filesize);
|
||||
fclose ($handle);
|
||||
}
|
||||
}
|
||||
|
||||
function getRow($recnum) {
|
||||
$memoeot = chr(26).chr(26);
|
||||
$rawrow = substr($this->_raw,$recnum*$this->_rowsize+$this->_hdrsize,$this->_rowsize);
|
||||
$rowrecs = array();
|
||||
$beg=1;
|
||||
if (ord($rawrow[0])==42) {
|
||||
return false; //Record is deleted...
|
||||
}
|
||||
for ($i=0; $i<$this->dbf_num_field; $i++) {
|
||||
$col=trim(substr($rawrow,$beg,$this->dbf_names[$i]['len']));
|
||||
if ($this->dbf_names[$i]['type']!='M') {
|
||||
|
||||
$rowrecs[]=$col;
|
||||
} else {
|
||||
$memobeg=$col*512; //Find start of the memo block (0=header so it works)
|
||||
$memoend=strpos($this->_memos,$memoeot,$memobeg); //Find the end of the memo
|
||||
$rowrecs[]=substr($this->_memos,$memobeg,$memoend-$memobeg);
|
||||
}
|
||||
$beg+=$this->dbf_names[$i]['len'];
|
||||
}
|
||||
return $rowrecs;
|
||||
}
|
||||
|
||||
function getRowAssoc($recnum) {
|
||||
$rawrow = substr($this->_raw,$recnum*$this->_rowsize+$this->_hdrsize,$this->_rowsize);
|
||||
$rowrecs = array();
|
||||
$beg=1;
|
||||
if (ord($rawrow[0])==42) {
|
||||
return false; //Record is deleted...
|
||||
}
|
||||
for ($i=0; $i<$this->dbf_num_field; $i++) {
|
||||
$col=trim(substr($rawrow,$beg,$this->dbf_names[$i]['len']));
|
||||
if ($this->dbf_names[$i]['type']!='M') {
|
||||
$rowrecs[$this->dbf_names[$i]['name']]=$col;
|
||||
} else {
|
||||
$memobeg=$col*512; //Find start of the memo block (0=header so it works)
|
||||
$memoend=strpos($this->_memos,$memoeot,$memobeg); //Find the end of the memo
|
||||
$rowrecs[$this->dbf_names[$i]['name']]=substr($this->_memos,$memobeg,$memoend-$memobeg);
|
||||
}
|
||||
$beg+=$this->dbf_names[$i]['len'];
|
||||
}
|
||||
return $rowrecs;
|
||||
}
|
||||
}//End of Class
|
||||
|
||||
$dbf = new dbf_class('_stany.dbf');
|
||||
$num_rec=$dbf->dbf_num_rec;
|
||||
$num_field=$dbf->dbf_num_field;
|
||||
mysql_query("truncate table ecmstockstates");
|
||||
mysql_query("truncate table ecmstockoperations");
|
||||
mysql_query("truncate table ecmstockdocins");
|
||||
mysql_query("truncate table ecmstockdocinitems");
|
||||
include_once("modules/EcmProducts/EcmProduct.php");
|
||||
include_once("modules/EcmStockDocIns/EcmStockDocIn.php");
|
||||
$esdi=new EcmStockDocIn();
|
||||
$esdi->format_all_fields();
|
||||
$esdi->name="Bilans otwarcia";
|
||||
$esdi->status="accepted";
|
||||
$esdi->parent_id=36;
|
||||
$esdi->register_date="17.09.2009";
|
||||
$esdi->ecmlanguage="pl_pl";
|
||||
$esdi->currency_id="PLN";
|
||||
$esdi->assigned_user_id=1;
|
||||
$esdi->modified_user_id=1;
|
||||
$esdi->stock_id="9758747e-5a0e-8b62-04a7-48a923cb3b9a";
|
||||
$esdi->stock_name="Stock 1";
|
||||
$tw=mysql_query("select id from ecmdocumenttemplates where account_id='36'");
|
||||
while($tr=mysql_fetch_array($tw))$tid=$tr['id'];
|
||||
$esdi->template_id=$tid;
|
||||
$esdi->template_name="E5 Polska Sp. z o. o.";
|
||||
$esdi->number=$esdi->generateNumber();
|
||||
$esdi->document_no=$esdi->formatNumber();
|
||||
|
||||
$esdiid=$esdi->save();
|
||||
for($i=0; $i<$num_rec; $i++){
|
||||
$row = $dbf->getRow($i);
|
||||
|
||||
$stan=$row[8];
|
||||
$cena=$row[13];
|
||||
$zamowione=$row[17];
|
||||
$pw=mysql_query("select name,id,code,vat_id,vat_name,vat_value from ecmproducts where code like '".$row[0]."' and deleted='0'");
|
||||
$r=mysql_fetch_array($pw);
|
||||
$name=$r['name'];
|
||||
$code=$r['code'];
|
||||
$pid=$r['id'];
|
||||
echo "[".$name." ".$code." ".mysql_num_rows($pw)."]<br>";
|
||||
if(mysql_num_rows($pw)<=0){
|
||||
$prod=new EcmProduct();
|
||||
$prod->code=$row[0];
|
||||
$code=$row[0];
|
||||
$prod->name=$row[1];
|
||||
$name=$row[1];
|
||||
$pid=$prod->save();
|
||||
echo "[dodano produkt: ".$name." ".$code."]<br>";
|
||||
}
|
||||
|
||||
if($stan>0){
|
||||
if(mysql_query("insert into ecmstockdocinitems values('".create_guid()."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','1','1','1','0','".$esdiid."','".$pid."','".$k."','".$code."','".$name."','".$stan."','".$cena."','0','".($cena*$stan)."','1','szt.','".$r['vat_id']."','".$r['vat_name']."','".$r['vat_value']."','1','1','PLN')"))echo "items ok<br>";
|
||||
else echo "items no<br>";
|
||||
|
||||
if(mysql_query("insert into ecmstockstates values('".create_guid()."','name','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','1','1','opis','0','1','Stock 1','9758747e-5a0e-8b62-04a7-48a923cb3b9a','".$name."','".$pid."','".$stan."','".$cena."','".$row[0]."');"))echo "states ok<br>";
|
||||
else echo "states no<br>";
|
||||
|
||||
if(mysql_query("insert into ecmstockoperations values('".create_guid()."','name','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','1','1','opis','0','1','9758747e-5a0e-8b62-04a7-48a923cb3b9a','".$pid."','".$stan."','".date("Y-m-d H:i:s")."','".$cena."','EcmStockDocIns','".$esdiid."',NULL,'".$esdiid."','0','Stock 1','".$name."','".$esdi->document_no."','".$code."');"))echo "ops ok<br>";
|
||||
else echo "ops no<br>";
|
||||
}
|
||||
|
||||
echo mysql_error();
|
||||
$k++;
|
||||
}
|
||||
mysql_close($sql1);
|
||||
?>
|
||||
45
modules/EcmStockStates/summary.php
Executable file
45
modules/EcmStockStates/summary.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
function getState($id,$date){
|
||||
$who[]="deleted='0'";
|
||||
$who[]="date_entered<='".$date." 23:59:59'";
|
||||
$arr=array();
|
||||
$pp1=0;
|
||||
$q1=0;
|
||||
$ww=mysql_query("select quantity as qty,id,price from ecmstockoperations where deleted='0' and type='0' and (in_id IS NULL or in_id='') and product_id='".$id."' and (".implode(" and ",$who).")");
|
||||
while($rrr=mysql_fetch_array(($ww)){
|
||||
$www=mysql_query("select quantity from ecmstockoperations where in_id='".$rrr['id']."' and type='1' and in_id IS NOT NULL and in_id!='' and product_id='".$id."' and (".implode(" and ",$who).") and deleted='0'");
|
||||
$rqty=0;
|
||||
while($rrp=mysql_fetch_array(($www)){
|
||||
$rqty+=$rrp['quantity'];
|
||||
}
|
||||
$qty=$rrr['qty']-$rqty;
|
||||
if($qty>0){
|
||||
$arr[]=array("qty"=>$qty,"id"=>$rrr['id'],"price"=>$rrr['price']);
|
||||
}
|
||||
}
|
||||
if(count($arr)>0){
|
||||
foreach($arr as $v){
|
||||
$q1+=$v['qty'];
|
||||
$pp1+=$v['qty']*$v['price'];
|
||||
}
|
||||
}
|
||||
$qty=$q1;
|
||||
$value=$pp1;
|
||||
@$price=$value/$qty;
|
||||
return array("qty"=>$qty,"price"=>$price);
|
||||
}
|
||||
|
||||
$z="select id,name,code from ecmproducts where deleted='0' order by code asc";
|
||||
$w=mysql_query($z);
|
||||
while($r=mysql_fetch_array(($w)){
|
||||
$s=getState($r['id'],$_REQUEST['date']);
|
||||
if($s['qty']>0){
|
||||
$t.=$r['code'].','.$r['name'].','.$s['qty'].','.$s['price'].',
|
||||
';
|
||||
}
|
||||
}
|
||||
$filename = "states.cvs";
|
||||
$handle = fopen($filename, "wb");
|
||||
$numbytes = fwrite($handle,$t);
|
||||
fclose($handle);
|
||||
?>
|
||||
36
modules/EcmStockStates/summarypz.php
Executable file
36
modules/EcmStockStates/summarypz.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
mysql_connect('127.0.0.1', 'e5crm', '5z#JaL');
|
||||
mysql_query('use e5crm');
|
||||
$date = '2013-01';
|
||||
function getTotal($id){
|
||||
$r=mysql_fetch_array(mysql_query("select sum(price*quantity) as s from ecmstockdoccorrectitems where ecmstockdoccorrect_id='".$id."' and deleted='0'"));
|
||||
return $r['s'];
|
||||
}
|
||||
$z="select id,document_no,total,register_date from ecmstockdoccorrects
|
||||
where deleted='0' and status='accepted' and register_date like '".$date."%' order by register_date asc";
|
||||
|
||||
$w=mysql_query($z);
|
||||
while($r=mysql_fetch_array($w)){
|
||||
$t.=$r['document_no'].','.$r['register_date'].','.getTotal($r['id']).',
|
||||
';
|
||||
}
|
||||
$filename = "ks.csv";
|
||||
$handle = fopen($filename, "wb");
|
||||
$numbytes = fwrite($handle,$t);
|
||||
$t="";
|
||||
fclose($handle);
|
||||
function getTotalPZ($id){
|
||||
$r=mysql_fetch_array(mysql_query("select sum(price*quantity) as s from ecmstockdocinitems where ecmstockdocin_id='".$id."' and deleted='0'"));
|
||||
return $r['s'];
|
||||
}
|
||||
$z="select id,document_no,total,register_date from ecmstockdocins where deleted='0' and status='accepted' and register_date like '".$date."%' order by register_date asc";
|
||||
$w=mysql_query($z);
|
||||
while($r=mysql_fetch_array($w)){
|
||||
$t.=$r['document_no'].','.$r['register_date'].','.getTotalPZ($r['id']).',
|
||||
';
|
||||
}
|
||||
$filename = "pz.csv";
|
||||
$handle = fopen($filename, "wb");
|
||||
$numbytes = fwrite($handle,$t);
|
||||
fclose($handle);
|
||||
?>
|
||||
91
modules/EcmStockStates/testState.php
Executable file
91
modules/EcmStockStates/testState.php
Executable file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
function state1($stock_id,$product_id){
|
||||
echo date("Y-m-d H:i:s")."<br>";
|
||||
$q=0;
|
||||
$p=0;
|
||||
$i=0;
|
||||
$pp=0;
|
||||
$qq=0;
|
||||
|
||||
|
||||
$w=mysql_query("select quantity as qty,id,price from ecmstockoperations where deleted='0' and type='0' and in_id IS NULL and stock_id='".$stock_id."' and product_id='".$product_id."'");
|
||||
while($rrr=mysql_fetch_array($w)){
|
||||
$ww=mysql_query("select quantity from ecmstockoperations where in_id='".$rrr['id']."' and type='1' and in_id IS NOT NULL and stock_id='".$stock_id."' and product_id='".$product_id."' and deleted='0'");
|
||||
$rqty=0;
|
||||
while($rrp=mysql_fetch_array($ww)){
|
||||
$rqty+=$rrp['quantity'];
|
||||
}
|
||||
$qty=$rrr['qty']-$rqty;
|
||||
if($qty>0){
|
||||
$arr[]=array("qty"=>$qty,"id"=>$rrr['id'],"price"=>$rrr['price']);
|
||||
}
|
||||
}
|
||||
|
||||
if(count($arr)>0){
|
||||
foreach($arr as $v){
|
||||
$q1+=$v['qty'];
|
||||
$pp1+=$v['qty']*$v['price'];
|
||||
}
|
||||
}
|
||||
echo $q1." ".$pp1."<br>".date("Y-m-d H:i:s")."<br><br>";
|
||||
}
|
||||
function state2($stock_id,$product_id){
|
||||
echo date("Y-m-d H:i:s")."<br>";
|
||||
$q=0;
|
||||
$p=0;
|
||||
$i=0;
|
||||
$pp=0;
|
||||
$qq=0;
|
||||
|
||||
/*$w=$GLOBALS['db']->query("
|
||||
select
|
||||
(o.quantity-oo.quantity) as qty,
|
||||
o.id,
|
||||
o.price
|
||||
from ecmstockoperations as o
|
||||
right outer join ecmstockoperations as oo on o.id=oo.in_id
|
||||
where
|
||||
oo.type='1' and
|
||||
oo.deleted='0' and
|
||||
o.deleted='0' and
|
||||
o.type='0' and
|
||||
o.in_id is null and
|
||||
o.stock_id='".$stock_id."' and
|
||||
o.product_id='".$product_id."'");*/
|
||||
$w=$GLOBALS['db']->query("select quantity as qty,id,price from ecmstockoperations where deleted='0' and type='0' and used=0 and in_id IS NULL and stock_id='".$stock_id."' and product_id='".$product_id."'");
|
||||
while($rrr=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select sum(quantity) as s from ecmstockoperations where in_id='".$rrr['id']."' and type='1' and in_id IS NOT NULL and stock_id='".$stock_id."' and product_id='".$product_id."' and deleted='0'"));
|
||||
$rqty=$rrp['s'];
|
||||
$qty=$rrr['qty']-$rqty;
|
||||
//$qty=$rrr['qty'];
|
||||
if($qty>0){
|
||||
$arr[]=array("qty"=>$qty,"id"=>$rrr['id'],"price"=>$rrr['price']);
|
||||
}
|
||||
}
|
||||
|
||||
if(count($arr)>0){
|
||||
foreach($arr as $v){
|
||||
$q1+=$v['qty'];
|
||||
$pp1+=$v['qty']*$v['price'];
|
||||
}
|
||||
}
|
||||
echo $q1." ".$pp1."<br>".date("Y-m-d H:i:s")."<br>";
|
||||
}
|
||||
function sales1(){
|
||||
// if(i.ecminvoiceoutitem_id is not null,sum(i.price*i.quantity-ii.price*ii.quantity),sum(i.price*i.quantity)) a
|
||||
$w=$GLOBALS['db']->query("select
|
||||
sum(i.price*i.quantity-ii.price*ii.quantity) as sum
|
||||
from ecminvoiceouts as e
|
||||
inner join (
|
||||
ecminvoiceoutitems as i on e.id=i.ecminvoiceout_id
|
||||
left join ecminvoiceoutitems as ii on ii.id=i.ecminvoiceoutitem_id
|
||||
)
|
||||
where
|
||||
e.register_date like '2010%'");
|
||||
$r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
echo $r['sum'];
|
||||
}
|
||||
//state1("c7afd71a-4c3a-bde4-138d-4acaee1644e4",450);
|
||||
//state2("c7afd71a-4c3a-bde4-138d-4acaee1644e4","3e84b9b5-1d1f-8ff4-e187-496bc6ac51e8");
|
||||
sales1();
|
||||
?>
|
||||
95
modules/EcmStockStates/tpls/QuickCreate.tpl
Executable file
95
modules/EcmStockStates/tpls/QuickCreate.tpl
Executable file
@@ -0,0 +1,95 @@
|
||||
{*
|
||||
|
||||
/**
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
|
||||
|
||||
*}
|
||||
|
||||
|
||||
<form name="ecmstockstatesQuickCreate" id="ecmstockstatesQuickCreate" method="POST" action="index.php">
|
||||
<input type="hidden" name="module" value="EcmStockStates">
|
||||
<input type="hidden" name="email_id" value="{$REQUEST.email_id}">
|
||||
<input type="hidden" name="account_id" value="{$REQUEST.account_id}">
|
||||
<input type="hidden" name="case_id" value="{$REQUEST.acase_id}">
|
||||
<input type="hidden" name="contact_id" value="{$REQUEST.contact_id}">
|
||||
<input type="hidden" name="return_action" value="{$REQUEST.return_action}">
|
||||
<input type="hidden" name="return_module" value="{$REQUEST.return_module}">
|
||||
<input type="hidden" name="return_id" value="{$REQUEST.return_id}">
|
||||
<input type="hidden" name="action" value='Save'>
|
||||
<input type="hidden" name="duplicate_parent_id" value="{$REQUEST.duplicate_parent_id}">
|
||||
<input type="hidden" name="to_pdf" value='1'>
|
||||
<input id='assigned_user_id' name='assigned_user_id' type="hidden" value="{$ASSIGNED_USER_ID}" />
|
||||
|
||||
|
||||
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td align="left" style="padding-bottom: 2px;">
|
||||
<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button" type="submit" name="button" {$saveOnclick|default:"onclick=\"return check_form('EcmStockStatesQuickCreate');\""} value=" {$APP.LBL_SAVE_BUTTON_LABEL} " >
|
||||
<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" type="submit" name="button" {$cancelOnclick|default:"onclick=\"this.form.action.value='$RETURN_ACTION'; this.form.module.value='$RETURN_MODULE'; this.form.record.value='$RETURN_ID'\""} value=" {$APP.LBL_CANCEL_BUTTON_LABEL} ">
|
||||
<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" type="submit" name="button" onclick="this.form.to_pdf.value='0';this.form.action.value='EditView'; this.form.module.value='EcmStockStates';" value=" {$APP.LBL_FULL_FORM_BUTTON_LABEL} "></td>
|
||||
<td align="right" nowrap><span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span> {$APP.NTC_REQUIRED}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm">
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<th align="left" class="dataLabel" colspan="4"><h4 class="dataLabel"><slot>{$MOD.LBL_ECMSTOCKSTATE_INFORMATION}</slot></h4></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" class="dataLabel" width="15%"><slot>{$MOD.LBL_SUBJECT} <span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span></slot></td>
|
||||
<td width="35%"><slot><textarea name='name' cols="40" tabindex='1' rows="1">{$NAME}</textarea></slot></td>
|
||||
<td class="dataLabel" width="15%"><slot>{$MOD.LBL_TYPE}</slot></td>
|
||||
<td width="35%"><slot><select tabindex='2' name='type'>{$TYPE_OPTIONS}</select></slot></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" class="dataLabel" rowspan="2" width="15%"><slot>{$MOD.LBL_DESCRIPTION}</slot></td>
|
||||
<td rowspan="2" width="35%"><slot><textarea name='description' tabindex='1' cols="40" rows="4">{$DESCRIPTION}</textarea></slot></td>
|
||||
<td class="dataLabel" width="15%"><slot>{$MOD.LBL_PRIORITY}</slot></td>
|
||||
<td class="dataField" nowrap width="35%"><slot><select tabindex='2' name='priority'>{$PRIORITY_OPTIONS}</select></slot></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="dataLabel" width="15%"><slot>{$MOD.LBL_STATUS}</slot></td>
|
||||
<td width="35%"><slot><select tabindex='2' name='status'>{$STATUS_OPTIONS}</select></slot></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<script>
|
||||
{$additionalScripts}
|
||||
</script>
|
||||
68
modules/EcmStockStates/us.php
Executable file
68
modules/EcmStockStates/us.php
Executable file
@@ -0,0 +1,68 @@
|
||||
<?
|
||||
set_time_limit(9999999999);
|
||||
|
||||
$re="RE01439";
|
||||
|
||||
$sql=mysql_connect("localhost","root","");
|
||||
mysql_select_db("saascrm");
|
||||
include_once("helper.php");
|
||||
mysql_query("truncate table ecmstockstates");
|
||||
mysql_query("set names utf8");
|
||||
|
||||
$w=mysql_query("select id,name,dir from ecmstocks where deleted='0'");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
$stock_id=$r['id'];
|
||||
$ww=mysql_query("select id,code,name from ecmproducts where deleted='0'");
|
||||
while($rr=mysql_fetch_array($ww)){
|
||||
$product_id=$rr['id'];
|
||||
$product_name=$rr['name'];
|
||||
$product_code=$rr['code'];
|
||||
//if($product_code!=$re)continue;
|
||||
$w=mysql_query("select quantity,price,type from ecmstockoperations where stock_id='".$stock_id."' and product_id='".$product_id."' and deleted='0'");
|
||||
$q=0;
|
||||
$p=0;
|
||||
$i=0;
|
||||
$pp=0;
|
||||
$qq=0;
|
||||
while($r=mysql_fetch_array($w)){
|
||||
if($r['type']==0){
|
||||
$q+=$r['quantity'];
|
||||
$pp+=$r['quantity']*$r['price'];
|
||||
$i++;
|
||||
}
|
||||
elseif($r['type']==1){
|
||||
$q-=$r['quantity'];
|
||||
$pp-=$r['quantity']*$r['price'];
|
||||
}
|
||||
}
|
||||
mysql_query("delete from ecmstockstates where stock_id='".$stock_id."' and product_id='".$product_id."' and deleted='0'");
|
||||
|
||||
$rrr=mysql_fetch_array(mysql_query("select name from ecmstocks where id='".$stock_id."'"));
|
||||
$stock_name=$rrr['name'];
|
||||
if($q>0)$avg_price=($pp/$q);
|
||||
else $avg_price=0;
|
||||
$arr=array(
|
||||
'id'=>create_guid(),
|
||||
'name'=>'',
|
||||
'date_entered'=>date("Y-m-d H:i:s"),
|
||||
'date_modified'=>date("Y-m-d H:i:s"),
|
||||
'created_by'=>1,
|
||||
'assigned_user_id'=>1,
|
||||
'product_id'=>$product_id,
|
||||
'product_name'=>$product_name,
|
||||
'product_code'=>$product_code,
|
||||
'stock_id'=>$stock_id,
|
||||
'stock_name'=>$stock_name,
|
||||
'quantity'=>$q,
|
||||
'price'=>$avg_price,
|
||||
);
|
||||
$se=array();
|
||||
foreach($arr as $k=>$v){
|
||||
$se[]=$k."='".$v."'";
|
||||
}
|
||||
echo $product_code." ".$q." ".$avg_price."\n";
|
||||
mysql_query("insert into ecmstockstates set ".implode(",",$se));
|
||||
}
|
||||
}
|
||||
mysql_close($sql);
|
||||
?>
|
||||
151
modules/EcmStockStates/vardefs.php
Executable file
151
modules/EcmStockStates/vardefs.php
Executable file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
$dictionary['EcmStockState']=array(
|
||||
'table'=>'ecmstockstates',
|
||||
'audited'=>true,
|
||||
'comment'=>'EcmStockStates',
|
||||
'duplicate_merge'=>true ,
|
||||
'unified_search'=>true,
|
||||
'fields'=>array(
|
||||
'stock_name' => array(
|
||||
'name'=> 'stock_name',
|
||||
'id_name'=>'stock_id',
|
||||
'vname'=>'LBL_STOCK_NAME',
|
||||
'type'=>'relate',
|
||||
'group'=>'stock_name',
|
||||
'dbtype' => 'varchar',
|
||||
'len' => '255',
|
||||
'module' => 'EcmStocks',
|
||||
'table'=>'ecmstocks',
|
||||
'massupdate'=>false,
|
||||
),
|
||||
'stock_id' => array (
|
||||
'name' => 'stock_id',
|
||||
'type' => 'enum',
|
||||
'module' => 'EcmStocks',
|
||||
'table'=>'ecmstocks',
|
||||
'vname' => 'LBL_STOCK_NAME',
|
||||
'group'=>'stock_name',
|
||||
'options'=>'ecmstocks_list_dom',
|
||||
'required' => true,
|
||||
'massupdate'=>false,
|
||||
),
|
||||
'product_code' => array(
|
||||
'name'=> 'product_code',
|
||||
'vname'=>'LBL_PRODUCT_CODE',
|
||||
'type'=>'varchar',
|
||||
'len' => '255',
|
||||
'massupdate'=>false,
|
||||
),
|
||||
'product_name' => array(
|
||||
'name'=> 'product_name',
|
||||
'id_name'=>'product_id',
|
||||
'vname'=>'LBL_PRODUCT_NAME',
|
||||
'type'=>'relate',
|
||||
'group'=>'product_name',
|
||||
'dbtype' => 'varchar',
|
||||
'len' => '255',
|
||||
'module' => 'EcmProducts',
|
||||
'table'=>'ecmproducts',
|
||||
'massupdate'=>false,
|
||||
),
|
||||
'product_id' => array (
|
||||
'name' => 'product_id',
|
||||
'type' => 'id',
|
||||
'module' => 'EcmProducts',
|
||||
'table'=>'ecmproducts',
|
||||
'vname' => 'LBL_PRODUCT_ID',
|
||||
'group'=>'product_name',
|
||||
'required' => true,
|
||||
'massupdate'=>false,
|
||||
),
|
||||
'quantity' => array (
|
||||
'name' => 'quantity',
|
||||
'vname' => 'LBL_QUANTITY',
|
||||
'type' => 'decimal',
|
||||
'precision'=>4,
|
||||
'len' => '15,4',
|
||||
'required' => true,
|
||||
'massupdate'=>false,
|
||||
),
|
||||
'price' => array (
|
||||
'name' => 'price',
|
||||
'vname' => 'LBL_PRICE',
|
||||
'type' => 'decimal',
|
||||
'len' => '15,2',
|
||||
'required' => true,
|
||||
'massupdate'=>false,
|
||||
),
|
||||
),
|
||||
'indices'=>array(
|
||||
array('name'=>'idx_ecmstockstate_id_del','type'=>'index','fields'=>array('id','deleted')),
|
||||
array('name'=>'idx_ecmstockstate_assigned_del','type'=>'index','fields'=>array( 'deleted', 'assigned_user_id')),
|
||||
),
|
||||
'relationships'=>array(
|
||||
'ecmstockstates_assigned_user'=>array(
|
||||
'lhs_module'=>'Users',
|
||||
'lhs_table'=>'users',
|
||||
'lhs_key'=>'id',
|
||||
'rhs_module'=>'EcmStockStates',
|
||||
'rhs_table'=>'ecmstockstates',
|
||||
'rhs_key'=>'assigned_user_id',
|
||||
'relationship_type'=>'one-to-many'
|
||||
),
|
||||
'ecmstockstates_modified_user'=>array(
|
||||
'lhs_module'=>'Users',
|
||||
'lhs_table'=>'users',
|
||||
'lhs_key'=>'id',
|
||||
'rhs_module'=>'EcmStockStates',
|
||||
'rhs_table'=>'ecmstockstates',
|
||||
'rhs_key'=>'modified_user_id',
|
||||
'relationship_type'=>'one-to-many'
|
||||
),
|
||||
'ecmstockstates_created_by'=>array(
|
||||
'lhs_module'=>'Users',
|
||||
'lhs_table'=>'users',
|
||||
'lhs_key'=>'id',
|
||||
'rhs_module'=>'EcmStockStates',
|
||||
'rhs_table'=>'ecmstockstates',
|
||||
'rhs_key'=>'created_by',
|
||||
'relationship_type'=>'one-to-many'
|
||||
)
|
||||
),
|
||||
'optimistic_locking'=>true,
|
||||
);
|
||||
require_once('include/SugarObjects/VardefManager.php');
|
||||
VardefManager::createVardef('EcmStockStates','EcmStockState', array('default','assignable'));
|
||||
?>
|
||||
251
modules/EcmStockStates/views/view.list.php
Executable file
251
modules/EcmStockStates/views/view.list.php
Executable file
@@ -0,0 +1,251 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: This file is used to override the default Meta-data EditView behavior
|
||||
* to provide customization specific to the Calls module.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/MVC/View/views/view.list.php');
|
||||
|
||||
class EcmStockStatesViewList extends ViewList{
|
||||
|
||||
function EcmStockStatesViewList(){
|
||||
parent::ViewList();
|
||||
}
|
||||
|
||||
function display(){
|
||||
if(!$this->bean->ACLAccess('list')){
|
||||
ACLController::displayNoAccess();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$this->module=$module = "EcmStockStates";
|
||||
$metadataFile = null;
|
||||
$foundViewDefs = false;
|
||||
if(file_exists('custom/modules/' . $module. '/metadata/listviewdefs.php')){
|
||||
$metadataFile = 'custom/modules/' . $module . '/metadata/listviewdefs.php';
|
||||
$foundViewDefs = true;
|
||||
}else{
|
||||
if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
|
||||
require_once('custom/modules/'.$module.'/metadata/metafiles.php');
|
||||
if(!empty($metafiles[$module]['listviewdefs'])){
|
||||
$metadataFile = $metafiles[$module]['listviewdefs'];
|
||||
$foundViewDefs = true;
|
||||
}
|
||||
}elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
|
||||
require_once('modules/'.$module.'/metadata/metafiles.php');
|
||||
if(!empty($metafiles[$module]['listviewdefs'])){
|
||||
$metadataFile = $metafiles[$module]['listviewdefs'];
|
||||
$foundViewDefs = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')){
|
||||
$metadataFile = 'modules/'.$module.'/metadata/listviewdefs.php';
|
||||
}
|
||||
require_once($metadataFile);
|
||||
|
||||
if(!empty($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select']!='_none') {
|
||||
if(empty($_REQUEST['button']) && (empty($_REQUEST['clear_query']) || $_REQUEST['clear_query']!='true')) {
|
||||
$this->saved_search = loadBean('SavedSearch');
|
||||
$this->saved_search->retrieveSavedSearch($_REQUEST['saved_search_select']);
|
||||
$this->saved_search->populateRequest();
|
||||
}
|
||||
elseif(!empty($_REQUEST['button'])) { // click the search button, after retrieving from saved_search
|
||||
$_SESSION['LastSavedView'][$_REQUEST['module']] = '';
|
||||
unset($_REQUEST['saved_search_select']);
|
||||
unset($_REQUEST['saved_search_select_name']);
|
||||
}
|
||||
}
|
||||
|
||||
$storeQuery = new StoreQuery();
|
||||
if(!isset($_REQUEST['query'])){
|
||||
$storeQuery->loadQuery($this->module);
|
||||
$storeQuery->populateRequest();
|
||||
}else{
|
||||
$storeQuery->saveFromRequest($this->module);
|
||||
}
|
||||
|
||||
$seed = $this->bean;
|
||||
$lv = new ListViewSmarty();
|
||||
$displayColumns = array();
|
||||
if(!empty($_REQUEST['displayColumns'])) {
|
||||
foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
|
||||
if(!empty($listViewDefs[$module][$col]))
|
||||
$displayColumns[$col] = $listViewDefs[$module][$col];
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach($listViewDefs[$module] as $col => $params) {
|
||||
if(!empty($params['default']) && $params['default'])
|
||||
$displayColumns[$col] = $params;
|
||||
}
|
||||
}
|
||||
$params = array('massupdate' => true, 'export'=>false);
|
||||
|
||||
$lv->quickViewLinks = false;
|
||||
$lv->export = false;
|
||||
$lv->mergeduplicates = false;
|
||||
|
||||
if(!empty($_REQUEST['orderBy'])) {
|
||||
$params['orderBy'] = $_REQUEST['orderBy'];
|
||||
$params['overrideOrder'] = true;
|
||||
if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
|
||||
}
|
||||
|
||||
$lv->displayColumns = $displayColumns;
|
||||
|
||||
$this->seed = $seed;
|
||||
$this->module = $module;
|
||||
|
||||
$searchForm = null;
|
||||
|
||||
//search
|
||||
$view = 'basic_search';
|
||||
if(!empty($_REQUEST['search_form_view']))
|
||||
$view = $_REQUEST['search_form_view'];
|
||||
$headers = true;
|
||||
if(!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only'])
|
||||
$headers = false;
|
||||
elseif(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
|
||||
if(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
|
||||
$view = 'advanced_search';
|
||||
}else {
|
||||
$view = 'basic_search';
|
||||
}
|
||||
}
|
||||
|
||||
$use_old_search = true;
|
||||
if(file_exists('modules/'.$this->module.'/SearchForm.html')){
|
||||
require_once('include/SearchForm/SearchForm.php');
|
||||
$searchForm = new SearchForm($this->module, $this->seed);
|
||||
}else{
|
||||
$use_old_search = false;
|
||||
require_once('include/SearchForm/SearchForm2.php');
|
||||
|
||||
if(!empty($metafiles[$this->module]['searchdefs']))
|
||||
require_once($metafiles[$this->module]['searchdefs']);
|
||||
elseif(file_exists('modules/'.$this->module.'/metadata/searchdefs.php'))
|
||||
require_once('modules/'.$this->module.'/metadata/searchdefs.php');
|
||||
|
||||
if (file_exists('custom/modules/'.$this->module.'/metadata/searchdefs.php'))
|
||||
{
|
||||
require_once('custom/modules/'.$this->module.'/metadata/searchdefs.php');
|
||||
}
|
||||
elseif (!empty($metafiles[$this->module]['searchdefs']))
|
||||
{
|
||||
require_once($metafiles[$this->module]['searchdefs']);
|
||||
}
|
||||
elseif (file_exists('modules/'.$this->module.'/metadata/searchdefs.php'))
|
||||
{
|
||||
require_once('modules/'.$this->module.'/metadata/searchdefs.php');
|
||||
}
|
||||
|
||||
if(!empty($metafiles[$this->module]['searchfields']))
|
||||
require_once($metafiles[$this->module]['searchfields']);
|
||||
elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php'))
|
||||
require_once('modules/'.$this->module.'/metadata/SearchFields.php');
|
||||
|
||||
$searchForm = new SearchForm($this->seed, $this->module, $this->action);
|
||||
$searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl', $view, $listViewDefs);
|
||||
|
||||
$searchForm->lv = $lv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(isset($this->options['show_title']) && $this->options['show_title'] && (!isset($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] != "true")) {
|
||||
$moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
|
||||
|
||||
echo "\n<p>\n";
|
||||
echo get_module_title($moduleName, $GLOBALS['mod_strings']['LBL_MODULE_TITLE'], true);
|
||||
echo "\n</p>\n";
|
||||
|
||||
}
|
||||
|
||||
$where = '';
|
||||
if(isset($_REQUEST['query']))
|
||||
{
|
||||
// we have a query
|
||||
if(!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) { // from EditView cancel
|
||||
$searchForm->populateFromArray($storeQuery->query);
|
||||
}
|
||||
else {
|
||||
$searchForm->populateFromRequest();
|
||||
}
|
||||
$where_clauses = $searchForm->generateSearchWhere(true, $this->seed->module_dir);
|
||||
if (count($where_clauses) > 0 )$where = '('. implode(' ) AND ( ', $where_clauses) . ')';
|
||||
$GLOBALS['log']->info("List View Where Clause: $where");
|
||||
}
|
||||
if($use_old_search){
|
||||
switch($view) {
|
||||
case 'basic_search':
|
||||
$searchForm->setup();
|
||||
$searchForm->displayBasic($headers);
|
||||
break;
|
||||
case 'advanced_search':
|
||||
$searchForm->setup();
|
||||
$searchForm->displayAdvanced($headers);
|
||||
break;
|
||||
case 'saved_views':
|
||||
echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers);
|
||||
break;
|
||||
}
|
||||
|
||||
}else{
|
||||
echo $searchForm->display($headers);
|
||||
}
|
||||
if(!$headers)
|
||||
return;
|
||||
|
||||
if(empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false){
|
||||
// $this->processQuickSearch();
|
||||
$lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params);
|
||||
$savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
|
||||
echo get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'] . $savedSearchName, '', false);
|
||||
echo $lv->display();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
146
modules/EcmStockStates/wz.php
Executable file
146
modules/EcmStockStates/wz.php
Executable file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
set_time_limit(9999999999);
|
||||
$sql=mysql_connect("localhost","root","");
|
||||
mysql_select_db("saascrm");
|
||||
mysql_query("set names utf8");
|
||||
mysql_query("truncate table ecmstockdocouts");
|
||||
mysql_query("truncate table ecmstockdocoutitems");
|
||||
|
||||
|
||||
function addWz($row,$i,$stock_id){
|
||||
$r=mysql_fetch_array(mysql_query("select id from accounts where name like '%".$row['PLATNIK']."%' and deleted='0'"));
|
||||
$parent_id=$r['id'];
|
||||
$rd=$row['DATA'];
|
||||
$a1=explode(" ",$row['ADRES1']);
|
||||
$r=mysql_fetch_array(mysql_query("select id from ecmstockdocouts where name like 'WZ ".$row['KOR_DO_WZ']."' and deleted='0'"));
|
||||
$correct_id=$r['id'];
|
||||
if($correct_id)$pre="WZKOR";
|
||||
else $pre="WZ";
|
||||
$id=create_guid();
|
||||
$arr=array(
|
||||
"id"=>$id,
|
||||
"name"=>$pre." ".$row['NR_WZ'],
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"document_no"=>$pre." ".$row['NR_WZ'],
|
||||
"number"=>($i+1),
|
||||
"modified_user_id"=>1,
|
||||
"assigned_user_id"=>1,
|
||||
"created_by"=>1,
|
||||
"parent_type"=>"Accounts",
|
||||
"parent_name"=>ch(str_replace("'","",$row['PLATNIK'])),
|
||||
"parent_id"=>$parent_id,
|
||||
"status"=>"accepted",
|
||||
"register_date"=>$rd[0].$rd[1].$rd[2].$rd[3]."-".$rd[4].$rd[5]."-".$rd[6].$rd[7],
|
||||
"validtill_date"=>$rd[0].$rd[1].$rd[2].$rd[3]."-".$rd[4].$rd[5]."-".$rd[6].$rd[7],
|
||||
"parent_address_street"=>ch(str_replace("'","",$row['ADRES2'])),
|
||||
"parent_address_city"=>ch($r1,$r2,$a1[1]),
|
||||
"parent_address_postalcode"=>$a1[0],
|
||||
"subtotal"=>($row['WARTOSC']-$row['PODATEK']),
|
||||
"total"=>$row['WARTOSC'],
|
||||
"discount"=>0,
|
||||
"ecmlanguage"=>"pl_pl",
|
||||
"template_id"=>"1d178dc6-0904-3fa3-f51b-4a4b4698a173",
|
||||
"template_name"=>"E5 Polska Sp. z o. o.",
|
||||
"stock_id"=>$stock_id,
|
||||
"currency_id"=>"PLN",
|
||||
"correct_id"=>$correct_id,
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
mysql_query("insert into ecmstockdocouts set ".implode(",",$in));
|
||||
return $id;
|
||||
}
|
||||
|
||||
function addProductLine($id,$i,$r){
|
||||
$vats=array(
|
||||
0=>"9b783d21-5548-6653-e1d6-49610eb3f9dd",
|
||||
22=>"9c592a4a-2de0-1fa3-e082-494aeceb122c",
|
||||
7=>"bf3a5fec-435f-af22-024a-4958b51863c8",
|
||||
);
|
||||
$rr=mysql_fetch_array(mysql_query("select id from ecmproducts where code like '".$r['INDEKS']."' and deleted='0'"));
|
||||
$pid=$rr['id'];
|
||||
if($pid==""){
|
||||
$pid=addProduct($r['INDEKS'],$r['NAZWA']);
|
||||
}
|
||||
$iid=create_guid();
|
||||
|
||||
$arr=array(
|
||||
"id"=>$iid,
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"deleted"=>0,
|
||||
"modified_user_id"=>1,
|
||||
"assigned_user_id"=>1,
|
||||
"created_by"=>1,
|
||||
"ecmstockdocout_id"=>$id,
|
||||
"ecmproduct_id"=>$pid,
|
||||
"position"=>$i,
|
||||
"code"=>ch(str_replace("'","",$r['INDEKS'])),
|
||||
"name"=>ch(str_replace("'","",$r['NAZWA'])),
|
||||
"quantity"=>$r['ILOSC'],
|
||||
"price"=>$r['CENA_SPRZ'],
|
||||
"discount"=>$r['RABAT'],
|
||||
"total"=>$r['WARTOSC'],
|
||||
"dd_unit_name"=>$r['NAZWA_J_M'],
|
||||
"dd_unit_id"=>1,
|
||||
"ecmvat_id"=>$vats[$r['VAT']],
|
||||
"ecmvat_value"=>$r['VAT'],
|
||||
"ecmvat_name"=>$r['VAT']."%",
|
||||
"currency_id"=>"PLN",
|
||||
"currency_name"=>"PLN",
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
mysql_query("insert into ecmstockdocoutitems set ".implode(",",$in));
|
||||
if(mysql_error()){
|
||||
echo mysql_error()."\n".implode(",",$in);
|
||||
}
|
||||
return $iid;
|
||||
}
|
||||
|
||||
include_once("class.dbf.php");
|
||||
include_once("helper.php");
|
||||
|
||||
$w=mysql_query("select id,name,dir from ecmstocks where deleted='0'");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
$dbfp = new dbf_class('klk/'.$r['dir'].'/_wz_list.dbf');
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
//$num_recp=10000;
|
||||
$unset_arr=array("INDEKS","NAZWA","CENA_SPRZ","ILOSC","RABAT","WARTOSC","NAZWA_J_M","VAT","NR_SYSTEM");
|
||||
for($i=0;$i<$num_recp;$i++){
|
||||
echo "products ".$i."/".$num_recp."\n";
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
foreach($rowp as $k=>$v){
|
||||
if(!in_array($k,$unset_arr))unset($rowp[$k]);
|
||||
}
|
||||
$products[$rowp['NR_SYSTEM']][]=$rowp;
|
||||
}
|
||||
|
||||
$dbf = new dbf_class('klk/'.$r['dir'].'/_wz.dbf');
|
||||
$num_rec=$dbf->dbf_num_rec;
|
||||
//$num_rec=1000;
|
||||
$unset_arr=array("NR_WZ","PLATNIK","PODATEK","WARTOSC","ADRES2","ANULOWANA","NR_SYSTEM","DATA","KOR_DO_WZ");
|
||||
for($i=0;$i<$num_rec;$i++){
|
||||
echo "docs ".$i."/".$num_rec."\n";
|
||||
$docs[$i]=$dbf->getRowAssoc($i);
|
||||
foreach($docs[$i] as $k=>$v){
|
||||
if(!in_array($k,$unset_arr))unset($docs[$i][$k]);
|
||||
}
|
||||
}
|
||||
|
||||
for($i=0;$i<$num_rec;$i++){
|
||||
echo $i."/".$num_rec."\n";
|
||||
if($docs[$i]['ANULOWANA']!="F")continue;
|
||||
$id=addWz($docs[$i],$i,$r['id']);
|
||||
$j=1;
|
||||
foreach($products[$docs[$i]['NR_SYSTEM']] as $prod){
|
||||
addProductLine($id,$j,$prod);
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
mysql_close($sql);
|
||||
?>
|
||||
78
modules/EcmStockStates/zest.php
Executable file
78
modules/EcmStockStates/zest.php
Executable file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
set_time_limit(-1);
|
||||
|
||||
$pos_id[]='a4fb8078-b63c-daff-1f38-57fb25db931d';
|
||||
$pos_id[]='17a50d1d-7b31-37e9-a19a-57fb259175f3';
|
||||
$pos_id[]='15ba8e07-4db7-3c85-e02d-57fb7b16bb5e';
|
||||
$pos_id[]='e67257b8-8732-ed61-71ed-57fc991e0815';
|
||||
$pos_id[]='133520bd-2e41-d86b-537e-57fc99b1dc99';
|
||||
$pos_id[]='2725ad25-0e46-e22c-f8b9-57fde0ed444a';
|
||||
$pos_id[]='129c7706-dcbe-3de5-a7c3-57fde0fb41e0';
|
||||
$pos_id[]='3e8498d8-2035-78d6-336a-57ff1ab07051';
|
||||
$pos_id[]='1e56c739-1827-52c7-df3a-57ff86c71ace';
|
||||
$pos_id[]='4ab334c3-4ebb-8ac9-3245-5800adec744f';
|
||||
$pos_id[]='4da463ec-7678-7799-ec16-5800add7aa84';
|
||||
$pos_id[]='be592636-e74a-8cf8-f4b5-5800ad989211';
|
||||
$pos_id[]='80e23280-0ad0-e829-3eae-5800ad182dec';
|
||||
$pos_id[]='45eef3d2-d3a6-19a2-c086-5800adbce828';
|
||||
$pos_id[]='cb50491c-34af-0c44-5c94-5804708d8137';
|
||||
$pos_id[]='b66093e7-a660-dc74-b567-5805b2ff40dd';
|
||||
$pos_id[]='dc89e781-9b74-2ae8-1913-5805b249f0bb';
|
||||
$pos_id[]='f928059f-d62b-8c50-5303-5805b2d129e0';
|
||||
$pos_id[]='7ec40ef9-fcc6-7f1e-a410-580746f72773';
|
||||
$pos_id[]='39ad09f7-414b-f9f1-6349-580856eb8eb7';
|
||||
$pos_id[]='17394fa1-9703-a3d6-4d12-58085654ea5d';
|
||||
$pos_id[]='94c43230-02c3-e300-e435-580856ab1dd6';
|
||||
$pos_id[]='39445382-fe94-6fbf-41d6-5808567c0419';
|
||||
$pos_id[]='a16ca498-48ad-3ee1-cfcd-580890e9706d';
|
||||
$pos_id[]='662588f3-7158-3600-d23a-5808902cc16e';
|
||||
$pos_id[]='aa5b5557-ecaa-b2fd-bd5e-580890f5c7b4';
|
||||
$pos_id[]='cdaa7345-397b-cb4e-3625-58089075a019';
|
||||
$pos_id[]='bb4371d7-cb60-b47b-44d2-5808903e5cb4';
|
||||
$pos_id[]='d92c0911-e2d8-48bb-6a21-580892cb0b1f';
|
||||
$pos_id[]='4547bf36-4a59-b7f5-cc7f-58089273fa94';
|
||||
$pos_id[]='3072e9f2-0e7e-9ce7-15a5-580892819deb';
|
||||
$pos_id[]='2b55406a-f071-6d5e-427d-580da11bf984';
|
||||
$pos_id[]='5d29fb6d-f106-3d26-27ff-580f0158a6ed';
|
||||
$pos_id[]='cbae5602-8c39-ddf5-cb39-580f010f6380';
|
||||
$pos_id[]='8941f7b5-3112-c748-cb93-580f47aead5b';
|
||||
$pos_id[]='9c34a116-ad85-b170-7a0d-580f4e880ac6';
|
||||
$pos_id[]='2f2ee0b6-e590-ca43-8399-5812ede1dd7d';
|
||||
$pos_id[]='ce9987d5-2356-c404-db25-5812edf6f08e';
|
||||
$pos_id[]='727b4b0b-5f8c-5bdf-71a9-5812edb2728d';
|
||||
$pos_id[]='c214e940-97ad-acf4-cfff-5812ed3daf52';
|
||||
$pos_id[]='547aee15-b7da-8871-a902-5812edec7398';
|
||||
$pos_id[]='d791be49-28c1-d94a-fcb8-5816e4216236';
|
||||
$pos_id[]='b2790591-ff4d-6391-d4dc-5816e41eea90';
|
||||
$pos_id[]='e1514266-8535-26e7-e5da-581719db7a96';
|
||||
$pos_id[]='efc4b550-a27c-d898-32a6-581719c14a75';
|
||||
$pos_id[]='a6e4d7c1-2aef-6ee6-0d37-58172d73916f';
|
||||
$pos_id[]='86aa15fa-29ca-f641-739f-58196ae16baf';
|
||||
$pos_id[]='397dc68b-4cc5-be50-5d36-5819717585d2';
|
||||
$pos_id[]='951d20ae-cce3-9953-646b-581971dcb578';
|
||||
$pos_id[]='974ca3dc-f881-3d4f-1c05-581aec15da8c';
|
||||
/*
|
||||
$documents=array();
|
||||
$db=$GLOBALS['db'];
|
||||
foreach ($pos_id as $id){
|
||||
$sql1="update ecmstockoperations set price=0.60 where documentitem_id = '".$id."'";
|
||||
$sql_s="select quantity,ecmstockdocinsideout_id from ecmstockdocinsideoutitems where id = '".$id."'";
|
||||
$s=$db->query($sql_s);
|
||||
$s_w=$db->fetchByAssoc($s);
|
||||
|
||||
$total=round($s_w['quantity']*0.6,2);
|
||||
$documents[]=$s_w['ecmstockdocinsideout_id'];
|
||||
$sql2="update ecmstockdocinsideoutitems set price=0.60, total='".$total."' where id = '".$id."'";
|
||||
echo $sql1."<br>;".$sql2.';<br>';
|
||||
$db->query($sql1);
|
||||
$db->query($sql2);
|
||||
}
|
||||
$documents = array_unique($documents);
|
||||
foreach($documents as $doc){
|
||||
$query="update ecmstockdocinsideouts set total=(select sum(quantity*price) from
|
||||
ecmstockdocinsideoutitems where ecmstockdocinsideout_id ='".$doc."') where id='".$doc."'";
|
||||
$db->query($query);
|
||||
|
||||
}
|
||||
*/
|
||||
?>
|
||||
Reference in New Issue
Block a user