[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/class.sopricebook.php, 1.1.1.3
From: |
nomail |
Subject: |
[Phpgroupware-cvs] property/class.sopricebook.php, 1.1.1.3 |
Date: |
Fri, 21 May 2004 19:14:06 -0000 |
Update of /property
Modified Files:
Branch:
class.sopricebook.php
date: 2004/04/23 21:26:33; author: sigurdne; state: Exp; lines: +783 -783
Log Message:
no message
=====================================================================
Index: property/class.sopricebook.php
diff -u property/class.sopricebook.php:1.1.1.2
property/class.sopricebook.php:1.1.1.3
--- property/class.sopricebook.php:1.1.1.2 Fri Apr 23 20:25:56 2004
+++ property/class.sopricebook.php Fri Apr 23 21:26:33 2004
@@ -1,783 +1,783 @@
-<?php
-
/**************************************************************************\
- * phpGroupWare - property
*
- * http://www.phpgroupware.org
*
- *
*
- * Facilities Management
*
- * Written by Sigurd Nes [sigurdne at online.no]
*
- *
------------------------------------------------------------------------ *
- * Copyright 2000 - 2003 Free Software Foundation, Inc
*
- * This program is part of the GNU project, see http://www.gnu.org/
*
- *
------------------------------------------------------------------------ *
- * This program is free software; you can redistribute it and/or modify
it *
- * under the terms of the GNU General Public License as published by the
*
- * Free Software Foundation; either version 2 of the License, or (at
your *
- * option) any later version.
*
-
\**************************************************************************/
-
- class property_sopricebook
- {
-
- function property_sopricebook()
- {
- $this->currentapp = 'property';
//$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account = $GLOBALS['phpgw_data']['user']['id'];
- $this->socommon =
CreateObject($this->currentapp.'_socommon');
-
- $this->join = $this->socommon->join;
- }
-
- function
add_activity_first_prize($m_cost,$w_cost,$total_cost,$activity_id,$vendor_id,$date)
- {
- $GLOBALS['phpgw']->db->Execute("UPDATE
fm_activity_price_index set index_count='1',this_index='1',
m_cost='$m_cost',w_cost='$w_cost',total_cost='$total_cost',date='$date',current_index='1'
where activity_id='$activity_id' and vendor_id= '$vendor_id' and index_count=
'1'");
-
- $receipt['message'][] = array('msg'=>lang('First entry
is added!'));
-
- return $receipt;
- }
-
- function update_pricebook($update)
- {
- for ($i=0; $i<count($update); $i++)
- {
- $dbresult =
$GLOBALS['phpgw']->db->Execute("SELECT max(index_count) as max_index_count from
fm_activity_price_index Where activity_id='". $update[$i]['activity_id'] . "'
and vendor_id='".$update[$i]['vendor_id'] . "'");
-
- $next_index_count =
$dbresult->fields['max_index_count']+1;
-
- $GLOBALS['phpgw']->db->Execute("UPDATE
fm_activity_price_index set current_index = Null"
- . " WHERE activity_id='" .
$update[$i]['activity_id'] . "' and vendor_id='" . $update[$i]['vendor_id'] .
"'");
-
- $GLOBALS['phpgw']->db->Execute("INSERT into
fm_activity_price_index (activity_id, vendor_id, index_count, this_index,
m_cost, w_cost, total_cost, date,current_index) "
- . " values ('" .
- $update[$i]['activity_id'] . "','" .
- $update[$i]['vendor_id'] . "','" .
- $next_index_count . "','" .
- $update[$i]['new_index'] . "','" .
- $update[$i]['new_m_cost'] . "','" .
- $update[$i]['new_w_cost'] . "','" .
- $update[$i]['new_total_cost'] . "','" .
- $update[$i]['new_date']. "', '1')");
- }
-
- $receipt['message'][] = array('msg'=>lang('%1 entries
is updated!',$i));
-
- return $receipt;
-
- }
-
- function get_vendor_list()
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
phpgw_addressbook.org_name ,vendor_id "
- . " FROM (fm_activities $this->join
fm_activity_price_index ON fm_activities.id =
fm_activity_price_index.activity_id) $this->join phpgw_addressbook ON
fm_activity_price_index.vendor_id = phpgw_addressbook.id "
- . " GROUP by phpgw_addressbook.org_name
,vendor_id "
- . " ORDER BY phpgw_addressbook.org_name ");
- while (!$dbresult->EOF)
- {
-//--------->fix this------->
- if($dbresult->fields['vendor_id'])
- {
- $vendor_list[]=array
- (
- 'id' =>
$dbresult->fields['vendor_id'],
- 'name' =>
$dbresult->fields['org_name']
- );
- }
- $dbresult->MoveNext();
- }
- return $vendor_list;
- }
-
- function get_agreement_list()
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT *
FROM fm_agreement ORDER BY descr asc");
- while (!$dbresult->EOF)
- {
- $agreement_list[]=array
- (
- 'id' => $dbresult->fields['id'],
- 'name' =>
$GLOBALS['phpgw']->strip_html($dbresult->fields['descr']).' [ '.
$GLOBALS['phpgw']->strip_html($dbresult->fields['status']).' ] '
- );
- $dbresult->MoveNext();
- }
- return $agreement_list;
- }
-
- function get_dim_d_list()
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT *
FROM fm_dim_d ORDER BY descr asc");
- while (!$dbresult->EOF)
- {
- $dim_d_list[]=array
- (
- 'id' => $dbresult->fields['id'],
- 'name' => $dbresult->fields['id']
- );
- $dbresult->MoveNext();
- }
- return $dim_d_list;
- }
-
- function get_unit_list()
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT *
FROM fm_standard_unit ORDER BY descr asc");
- while (!$dbresult->EOF)
- {
- $unit_list[]=array
- (
- 'id' => $dbresult->fields['id'],
- 'name' =>
$GLOBALS['phpgw']->strip_html($dbresult->fields['descr'])
- );
- $dbresult->MoveNext();
- }
- return $unit_list;
- }
-
- function get_branch_list()
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT *
FROM fm_branch ORDER BY descr asc");
- while (!$dbresult->EOF)
- {
- $branch_list[]=array
- (
- 'id' => $dbresult->fields['id'],
- 'name' =>
$GLOBALS['phpgw']->strip_html($dbresult->fields['descr'])
- );
- $dbresult->MoveNext();
- }
- return $branch_list;
- }
-
- function check_activity_num($num='',$agreement_id='')
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
count(*) FROM fm_activities where num='$num' and agreement_id
='$agreement_id'");
-
-
-
- if ( $dbresult->fields[0])
- {
- return True;
- }
- }
-
- function check_agreement_num($num='')
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
count(*) FROM fm_agreement where num='$num'");
-
-
-
- if ( $dbresult->fields[0])
- {
- return True;
- }
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
-//html_print_r($data);
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by
phpgw_addressbook.org_name,activity_id';
- }
-
- if ($cat_id > 0)
- {
- $filtermethod .= " AND cat_id='$cat_id' ";
- $vendor_condition= "= $cat_id";
- }
- else
- {
- $vendor_condition= " IS NULL";
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND (fm_activities.descr LIKE
'%$query%' or fm_activities.num LIKE '%$query%')";
- }
-
- $sql = "SELECT
fm_activities.num,fm_activities.unit,fm_activities.dim_d,fm_activities.ns3420,fm_activities.descr
as descr, fm_activities.base_descr,activity_id,
phpgw_addressbook.org_name,fm_branch.descr as branch
,vendor_id,total_cost,m_cost,w_cost,index_count,fm_activity_price_index.this_index
"
- . " FROM (fm_activities $this->join
fm_activity_price_index ON fm_activities.id =
fm_activity_price_index.activity_id) $this->join phpgw_addressbook ON
fm_activity_price_index.vendor_id = phpgw_addressbook.id "
- . " $this->join fm_branch ON
fm_activities.branch_id = fm_branch.id "
- . " WHERE (vendor_id $vendor_condition and
current_index is not null "
- . " OR (fm_activity_price_index.vendor_id
$vendor_condition) AND (fm_activity_price_index.this_index IS NULL))
$querymethod";
-
- $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
- $this->total_records = $dbresult2->_numOfRows;
-
-
- $maxmatchs = 15;
-
- if(!$allrows)
- {
- $dbresult =
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
-
- }
- else
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute($sql
. $ordermethod);
- }
-
- while (!$dbresult->EOF)
- {
- $pricebook[] = array
- (
- 'activity_id' =>
$dbresult->fields['activity_id'],
- 'num' =>
$dbresult->fields['num'],
- 'branch' =>
$dbresult->fields['branch'],
- 'vendor_id' =>
$dbresult->fields['vendor_id'],
- 'm_cost' =>
$dbresult->fields['m_cost'],
- 'w_cost' =>
$dbresult->fields['w_cost'],
- 'total_cost' =>
$dbresult->fields['total_cost'],
- 'this_index' =>
$dbresult->fields['this_index'],
- 'unit' =>
$dbresult->fields['unit'],
- 'dim_d' =>
$dbresult->fields['dim_d'],
- 'ns3420_id' =>
$dbresult->fields['ns3420'],
- 'descr' =>
stripslashes($dbresult->fields['descr']),
- 'base_descr' =>
stripslashes($dbresult->fields['base_descr']),
- 'index_count' =>
$dbresult->fields['index_count']
- );
- $dbresult->MoveNext();
- }
-// html_print_r($pricebook);
- return $pricebook;
- }
-
- function read_agreement($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $where = 'WHERE';
-
- if ($cat_id)
- {
- $filtermethod .= " $where status='$cat_id' ";
- $where = 'AND';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where (descr LIKE '%$query%'
or num LIKE '%$query%')";
- }
-
- $sql = "SELECT * FROM fm_agreement $filtermethod
$querymethod";
-
- $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
- $this->total_records = $dbresult2->_numOfRows;
-
- $maxmatchs = 15;
-
- if(!$allrows)
- {
- $dbresult =
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
-
- }
- else
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute($sql
. $ordermethod);
- }
-
- while (!$dbresult->EOF)
- {
- $agreement[] = array
- (
- 'agreement_id' =>
$dbresult->fields['id'],
- 'num' =>
$dbresult->fields['num'],
- 'status' =>
$dbresult->fields['status'],
- 'descr' =>
stripslashes($dbresult->fields['descr'])
- );
- $dbresult->MoveNext();
- }
-// html_print_r($agreement);
- return $agreement;
- }
-
- function select_status_list()
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT id,
descr FROM fm_agreement_status ORDER BY id ");
-
- $i = 0;
- while (!$dbresult->EOF)
- {
- $status_entries[$i]['id']
= $dbresult->fields['id'];
- $status_entries[$i]['name']
= stripslashes($dbresult->fields['descr'));
- $i++;
- $dbresult->MoveNext();
- }
- return $status_entries;
- }
-
-
- function read_activity_prize($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $activity_id =
(isset($data['activity_id'])?$data['activity_id']:0);
- $vendor_id =
(isset($data['vendor_id'])?$data['vendor_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by index_count';
- }
-
- if ($cat_id > 0)
- {
- $filtermethod .= " AND cat_id='$cat_id' ";
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND (fm_activities.descr LIKE
'%$query%' or fm_activities.num LIKE '%$query%')";
- }
-
- $sql = "SELECT
index_count,this_index,current_index,m_cost,w_cost,total_cost,date"
- . " FROM fm_activity_price_index Where
activity_id= '$activity_id' and vendor_id= '$vendor_id'";
-
-
- $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
- $this->total_records = $dbresult2->_numOfRows;
-
-
- $maxmatchs = 15;
-
- if(!$allrows)
- {
- $dbresult =
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
-
- }
- else
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute($sql
. $ordermethod);
- }
-
- while (!$dbresult->EOF)
- {
- $pricebook[] = array
- (
- 'index_count' =>
$dbresult->fields['index_count'],
- 'this_index' =>
$dbresult->fields['this_index'],
- 'current_index' =>
$dbresult->fields['current_index'],
- 'm_cost' =>
$dbresult->fields['m_cost'],
- 'w_cost' =>
$dbresult->fields['w_cost'],
- 'total_cost' =>
$dbresult->fields['total_cost'],
- 'date' =>
$dbresult->fields['date']
- );
- $dbresult->MoveNext();
- }
-// html_print_r($pricebook);
- return $pricebook;
- }
-
- function read_activities_pr_aggreement($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = " order by activity_id asc";
- }
-
- if ($cat_id > 0)
- {
- $filtermethod .= " Where agreement_id='$cat_id'
";
- }
- else
- {
- $filtermethod = " Where agreement_id IS NULL";
- }
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
-// $querymethod = " AND (fm_activities.descr LIKE
'%$query%' or fm_activities.num LIKE '%$query%')";
- $querymethod = " and (fm_activities.descr like
'%$query%' or fm_activities.base_descr like '%$query%' or fm_activities.num
like '%$query%') ";
- }
-
- $sql = "SELECT fm_activities.id AS activity_id,
fm_activities.num, fm_activities.base_descr, fm_activities.unit,
fm_activities.dim_d, fm_branch.descr as branch, fm_activities.descr, ns3420 "
- . " FROM fm_activities $this->join fm_branch
on fm_activities.branch_id=fm_branch.id"
- . " $filtermethod $querymethod ";
-
- $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
- $this->total_records = $dbresult2->_numOfRows;
-
-
- $maxmatchs = 15;
-
- if(!$allrows)
- {
- $dbresult =
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
-
- }
- else
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute($sql
. $ordermethod);
- }
-
- while (!$dbresult->EOF)
- {
- $pricebook[] = array
- (
- 'activity_id' =>
$dbresult->fields['activity_id'],
- 'num' =>
$dbresult->fields['num'],
- 'base_descr' =>
stripslashes($dbresult->fields['base_descr']),
- 'branch' =>
$dbresult->fields['branch'],
- 'dim_d' =>
$dbresult->fields['dim_d'],
- 'ns3420' =>
$dbresult->fields['ns3420'],
- 'unit' =>
$dbresult->fields['unit'],
- 'descr' =>
stripslashes($dbresult->fields['descr'])
- );
- $dbresult->MoveNext();
- }
-// html_print_r($pricebook);
- return $pricebook;
- }
-
- function read_vendor_pr_activity($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $activity_id =
(isset($data['activity_id'])?$data['activity_id']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = " order by
phpgw_addressbook.org_name asc";
- }
-
- if ($cat_id > 0)
- {
- $filtermethod .= " Where agreement_id='$cat_id'
";
- }
- else
- {
- $filtermethod = " Where agreement_id = ''";
- }
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND
(phpgw_addressbook.org_name LIKE '%$query%' or vendor_id LIKE '%$query%')";
- }
-
- $sql = "SELECT fm_activities.id as
activity_id,fm_activities.num, phpgw_addressbook.org_name,fm_branch.descr as
branch ,vendor_id "
- . " FROM (fm_activities $this->join
fm_activity_price_index ON fm_activities.id =
fm_activity_price_index.activity_id) $this->join phpgw_addressbook ON
fm_activity_price_index.vendor_id = phpgw_addressbook.id "
- . " $this->join fm_branch on fm_branch.id =
fm_activities.branch_id "
- . " Where fm_activity_price_index.activity_id=
'$activity_id' $querymethod group by
fm_activities.id,fm_activities.num,fm_branch.descr,org_name ,vendor_id ";
-
- $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
- $this->total_records = $dbresult2->_numOfRows;
-
-
- $maxmatchs = 15;
-
- if(!$allrows)
- {
- $dbresult =
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
-
- }
- else
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute($sql
. $ordermethod);
- }
-
- while (!$dbresult->EOF)
- {
- $pricebook[] = array
- (
- 'activity_id' =>
$dbresult->fields['activity_id'],
- 'num' =>
$dbresult->fields['num'],
- 'branch' =>
$dbresult->fields['branch'],
- 'vendor_name' =>
$dbresult->fields['org_name'],
- 'vendor_id' =>
$dbresult->fields['vendor_id']
- );
- $dbresult->MoveNext();
- }
- return $pricebook;
- }
-
- function read_single_activity($id)
- {
- $sql = "SELECT * FROM fm_activities where id='$id'";
-
- $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
-
- if (!$dbresult->EOF)
- {
- $activity['activity_id']= $id;
- $activity['num'] =
$dbresult->fields['num'];
- $activity['unit'] =
$dbresult->fields['unit'];
- $activity['cat_id'] =
$dbresult->fields['agreement_id'];
- $activity['ns3420_id'] =
$dbresult->fields['ns3420'];
- $activity['descr'] =
stripslashes($dbresult->fields['descr']);
- $activity['base_descr'] =
stripslashes($dbresult->fields['base_descr']);
- $activity['dim_d'] =
$dbresult->fields['dim_d'];
- $activity['branch_id'] =
$dbresult->fields['branch_id'];
-
- return $activity;
- }
- }
-
- function read_single_agreement($id)
- {
- $sql = "SELECT * FROM fm_agreement where id='$id'";
-
- $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
-
- if (!$dbresult->EOF)
- {
- $agreement['agreement_id'] = $id;
- $agreement['num'] =
$dbresult->fields['num'];
- $agreement['status'] =
$dbresult->fields['status'];
- $agreement['descr'] =
stripslashes($dbresult->fields['descr']);
-
- return $agreement;
- }
- }
-
- function add_activity($values)
- {
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
- $values['base_descr'] =
$this->db->db_addslashes($values['base_descr']);
-
- $GLOBALS['phpgw']->db->Execute("INSERT INTO
fm_activities (id,
num,unit,agreement_id,ns3420,dim_d,branch_id,descr,base_descr) "
- . "VALUES ('" .
- $values['activity_id']. "','" .
- $values['num'] . "','" .
- $values['unit'] . "','" .
- $values['cat_id'] . "','" . // agreement
- $values['ns3420_id'] . "','" .
- $values['dim_d'] . "','" .
- $values['branch_id'] ."','" .
- $values['descr'] ."','" .
- $values['base_descr']. "')");
-
- $receipt['message'][] = array('msg'=>lang('Activity has
been saved'));
- $receipt['activity_id']= $values['activity_id'];
- return $receipt;
- }
-
- function edit_activity($values)
- {
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
- $values['base_descr'] =
$this->db->db_addslashes($values['base_descr']);
-
- $GLOBALS['phpgw']->db->Execute("UPDATE fm_activities set
- num='" . $values['num'] . "',
- unit='" . $values['unit'] . "',
- agreement_id='" . $values['cat_id'] . "',
- ns3420='" . $values['ns3420_id'] . "',
- dim_d='" . $values['dim_d'] . "',
- branch_id='" . $values['branch_id'] . "',
- descr='" . $values['descr'] . "',
- base_descr='" . $values['base_descr']
- . "' WHERE id= '" . $values['activity_id'] .
"'");
-
- $receipt['activity_id']= $values['activity_id'];
- $receipt['message'][] = array('msg'=>lang('Activity has
been edited'));
- return $receipt;
- }
-
- function add_agreement($values)
- {
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $GLOBALS['phpgw']->db->Execute("INSERT INTO
fm_agreement (id,num,status,descr) "
- . "VALUES ('" .
- $values['agreement_id']. "','" .
- $values['num'] . "','" .
- $values['status'] . "','" .
- $values['descr']. "')");
-
- $receipt['message'][] = array('msg'=>lang('Agreement
has been saved'));
- $receipt['agreement_id'] = $values['agreement_id'];
- return $receipt;
- }
-
- function edit_agreement($values)
- {
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $GLOBALS['phpgw']->db->Execute("UPDATE fm_agreement set
- num='" . $values['num'] . "',
- status='" . $values['status'] . "',
- descr='" . $values['descr']
- . "' WHERE id= '" . $values['agreement_id'] .
"'");
-
- $receipt['message'][] = array('msg'=>lang('Agreement
has been edited'));
- return $receipt;
- }
-
- function delete_activity_vendor($activity_id,$vendor_id)
- {
- $GLOBALS['phpgw']->db->Execute("DELETE FROM
fm_activity_price_index WHERE activity_id='$activity_id' and
vendor_id='$vendor_id'");
- }
-
- function delete_activity($activity_id)
- {
- $GLOBALS['phpgw']->db->Execute("DELETE FROM
fm_activities WHERE id='$activity_id'");
- $GLOBALS['phpgw']->db->Execute("DELETE FROM
fm_activity_price_index WHERE activity_id='$activity_id'");
- }
-
- function
delete_prize_index($activity_id,$vendor_id,$index_count)
- {
- if ($index_count==1)
- {
- $GLOBALS['phpgw']->db->Execute("UPDATE
fm_activity_price_index set index_count = '1', current_index = '0',
this_index=Null, m_cost=Null,w_cost=Null,total_cost=Null,date=Null where
activity_id='$activity_id' and vendor_id= '$vendor_id' and index_count= '1'");
- }
- else
- {
- $GLOBALS['phpgw']->db->Execute("DELETE from
fm_activity_price_index where activity_id='$activity_id' and vendor_id=
'$vendor_id' and index_count= '$index_count'");
-
- $new_index_count= $index_count -1;
-
- $GLOBALS['phpgw']->db->Execute("UPDATE
fm_activity_price_index set current_index = '1' where
activity_id='$activity_id' and vendor_id= '$vendor_id' and index_count=
'$new_index_count'");
- }
-
- }
-
- function delete_agreement($agreement_id)
- {
- $GLOBALS['phpgw']->db->Execute("DELETE FROM
fm_agreement WHERE id='$agreement_id'");
-//how to handle the activities and vendors ...?
- }
-
-
- function add_activity_vendor($values)
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
count(*) FROM fm_activity_price_index where activity_id='" .
$values['activity_id'] . "' and vendor_id='" . $values['vendor_id'] . "'");
-
-
-
- if ( $dbresult->fields[0])
- {
- $receipt['error'][] = array('msg'=>lang('This
Vendor is already registered for this activity'));
- }
- else
- {
- $GLOBALS['phpgw']->db->Execute("INSERT into
fm_activity_price_index (activity_id, vendor_id,
index_count,current_index,m_cost,w_cost,total_cost) "
- . " values ('" .
- $values['activity_id']. "','" .
- $values['vendor_id'].
"','1','0',NULL,NULL,NULL)");
-
- $receipt['message'][] =
array('msg'=>lang('Vendor has been added'));
-
- }
- return $receipt;
- }
- }
-?>
+<?php
+
/**************************************************************************\
+ * phpGroupWare - property
*
+ * http://www.phpgroupware.org
*
+ *
*
+ * Facilities Management
*
+ * Written by Sigurd Nes [sigurdne at online.no]
*
+ *
------------------------------------------------------------------------ *
+ * Copyright 2000 - 2003 Free Software Foundation, Inc
*
+ * This program is part of the GNU project, see http://www.gnu.org/
*
+ *
------------------------------------------------------------------------ *
+ * This program is free software; you can redistribute it and/or modify
it *
+ * under the terms of the GNU General Public License as published by the
*
+ * Free Software Foundation; either version 2 of the License, or (at
your *
+ * option) any later version.
*
+
\**************************************************************************/
+
+ class property_sopricebook
+ {
+
+ function property_sopricebook()
+ {
+ $this->currentapp = 'property';
//$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->db = $GLOBALS['phpgw']->db;
+ $this->db2 = $this->db;
+ $this->account = $GLOBALS['phpgw_data']['user']['id'];
+ $this->socommon =
CreateObject($this->currentapp.'_socommon');
+
+ $this->join = $this->socommon->join;
+ }
+
+ function
add_activity_first_prize($m_cost,$w_cost,$total_cost,$activity_id,$vendor_id,$date)
+ {
+ $GLOBALS['phpgw']->db->Execute("UPDATE
fm_activity_price_index set index_count='1',this_index='1',
m_cost='$m_cost',w_cost='$w_cost',total_cost='$total_cost',date='$date',current_index='1'
where activity_id='$activity_id' and vendor_id= '$vendor_id' and index_count=
'1'");
+
+ $receipt['message'][] = array('msg'=>lang('First entry
is added!'));
+
+ return $receipt;
+ }
+
+ function update_pricebook($update)
+ {
+ for ($i=0; $i<count($update); $i++)
+ {
+ $dbresult =
$GLOBALS['phpgw']->db->Execute("SELECT max(index_count) as max_index_count from
fm_activity_price_index Where activity_id='". $update[$i]['activity_id'] . "'
and vendor_id='".$update[$i]['vendor_id'] . "'");
+
+ $next_index_count =
$dbresult->fields['max_index_count']+1;
+
+ $GLOBALS['phpgw']->db->Execute("UPDATE
fm_activity_price_index set current_index = Null"
+ . " WHERE activity_id='" .
$update[$i]['activity_id'] . "' and vendor_id='" . $update[$i]['vendor_id'] .
"'");
+
+ $GLOBALS['phpgw']->db->Execute("INSERT into
fm_activity_price_index (activity_id, vendor_id, index_count, this_index,
m_cost, w_cost, total_cost, date,current_index) "
+ . " values ('" .
+ $update[$i]['activity_id'] . "','" .
+ $update[$i]['vendor_id'] . "','" .
+ $next_index_count . "','" .
+ $update[$i]['new_index'] . "','" .
+ $update[$i]['new_m_cost'] . "','" .
+ $update[$i]['new_w_cost'] . "','" .
+ $update[$i]['new_total_cost'] . "','" .
+ $update[$i]['new_date']. "', '1')");
+ }
+
+ $receipt['message'][] = array('msg'=>lang('%1 entries
is updated!',$i));
+
+ return $receipt;
+
+ }
+
+ function get_vendor_list()
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
phpgw_addressbook.org_name ,vendor_id "
+ . " FROM (fm_activities $this->join
fm_activity_price_index ON fm_activities.id =
fm_activity_price_index.activity_id) $this->join phpgw_addressbook ON
fm_activity_price_index.vendor_id = phpgw_addressbook.id "
+ . " GROUP by phpgw_addressbook.org_name
,vendor_id "
+ . " ORDER BY phpgw_addressbook.org_name ");
+ while (!$dbresult->EOF)
+ {
+//--------->fix this------->
+ if($dbresult->fields['vendor_id'])
+ {
+ $vendor_list[]=array
+ (
+ 'id' =>
$dbresult->fields['vendor_id'],
+ 'name' =>
$dbresult->fields['org_name']
+ );
+ }
+ $dbresult->MoveNext();
+ }
+ return $vendor_list;
+ }
+
+ function get_agreement_list()
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT *
FROM fm_agreement ORDER BY descr asc");
+ while (!$dbresult->EOF)
+ {
+ $agreement_list[]=array
+ (
+ 'id' => $dbresult->fields['id'],
+ 'name' =>
$GLOBALS['phpgw']->strip_html($dbresult->fields['descr']).' [ '.
$GLOBALS['phpgw']->strip_html($dbresult->fields['status']).' ] '
+ );
+ $dbresult->MoveNext();
+ }
+ return $agreement_list;
+ }
+
+ function get_dim_d_list()
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT *
FROM fm_dim_d ORDER BY descr asc");
+ while (!$dbresult->EOF)
+ {
+ $dim_d_list[]=array
+ (
+ 'id' => $dbresult->fields['id'],
+ 'name' => $dbresult->fields['id']
+ );
+ $dbresult->MoveNext();
+ }
+ return $dim_d_list;
+ }
+
+ function get_unit_list()
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT *
FROM fm_standard_unit ORDER BY descr asc");
+ while (!$dbresult->EOF)
+ {
+ $unit_list[]=array
+ (
+ 'id' => $dbresult->fields['id'],
+ 'name' =>
$GLOBALS['phpgw']->strip_html($dbresult->fields['descr'])
+ );
+ $dbresult->MoveNext();
+ }
+ return $unit_list;
+ }
+
+ function get_branch_list()
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT *
FROM fm_branch ORDER BY descr asc");
+ while (!$dbresult->EOF)
+ {
+ $branch_list[]=array
+ (
+ 'id' => $dbresult->fields['id'],
+ 'name' =>
$GLOBALS['phpgw']->strip_html($dbresult->fields['descr'])
+ );
+ $dbresult->MoveNext();
+ }
+ return $branch_list;
+ }
+
+ function check_activity_num($num='',$agreement_id='')
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
count(*) FROM fm_activities where num='$num' and agreement_id
='$agreement_id'");
+
+
+
+ if ( $dbresult->fields[0])
+ {
+ return True;
+ }
+ }
+
+ function check_agreement_num($num='')
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
count(*) FROM fm_agreement where num='$num'");
+
+
+
+ if ( $dbresult->fields[0])
+ {
+ return True;
+ }
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+//html_print_r($data);
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by
phpgw_addressbook.org_name,activity_id';
+ }
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " AND cat_id='$cat_id' ";
+ $vendor_condition= "= $cat_id";
+ }
+ else
+ {
+ $vendor_condition= " IS NULL";
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND (fm_activities.descr LIKE
'%$query%' or fm_activities.num LIKE '%$query%')";
+ }
+
+ $sql = "SELECT
fm_activities.num,fm_activities.unit,fm_activities.dim_d,fm_activities.ns3420,fm_activities.descr
as descr, fm_activities.base_descr,activity_id,
phpgw_addressbook.org_name,fm_branch.descr as branch
,vendor_id,total_cost,m_cost,w_cost,index_count,fm_activity_price_index.this_index
"
+ . " FROM (fm_activities $this->join
fm_activity_price_index ON fm_activities.id =
fm_activity_price_index.activity_id) $this->join phpgw_addressbook ON
fm_activity_price_index.vendor_id = phpgw_addressbook.id "
+ . " $this->join fm_branch ON
fm_activities.branch_id = fm_branch.id "
+ . " WHERE (vendor_id $vendor_condition and
current_index is not null "
+ . " OR (fm_activity_price_index.vendor_id
$vendor_condition) AND (fm_activity_price_index.this_index IS NULL))
$querymethod";
+
+ $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
+ $this->total_records = $dbresult2->_numOfRows;
+
+
+ $maxmatchs = 15;
+
+ if(!$allrows)
+ {
+ $dbresult =
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
+
+ }
+ else
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql
. $ordermethod);
+ }
+
+ while (!$dbresult->EOF)
+ {
+ $pricebook[] = array
+ (
+ 'activity_id' =>
$dbresult->fields['activity_id'],
+ 'num' =>
$dbresult->fields['num'],
+ 'branch' =>
$dbresult->fields['branch'],
+ 'vendor_id' =>
$dbresult->fields['vendor_id'],
+ 'm_cost' =>
$dbresult->fields['m_cost'],
+ 'w_cost' =>
$dbresult->fields['w_cost'],
+ 'total_cost' =>
$dbresult->fields['total_cost'],
+ 'this_index' =>
$dbresult->fields['this_index'],
+ 'unit' =>
$dbresult->fields['unit'],
+ 'dim_d' =>
$dbresult->fields['dim_d'],
+ 'ns3420_id' =>
$dbresult->fields['ns3420'],
+ 'descr' =>
stripslashes($dbresult->fields['descr']),
+ 'base_descr' =>
stripslashes($dbresult->fields['base_descr']),
+ 'index_count' =>
$dbresult->fields['index_count']
+ );
+ $dbresult->MoveNext();
+ }
+// html_print_r($pricebook);
+ return $pricebook;
+ }
+
+ function read_agreement($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $where = 'WHERE';
+
+ if ($cat_id)
+ {
+ $filtermethod .= " $where status='$cat_id' ";
+ $where = 'AND';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where (descr LIKE '%$query%'
or num LIKE '%$query%')";
+ }
+
+ $sql = "SELECT * FROM fm_agreement $filtermethod
$querymethod";
+
+ $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
+ $this->total_records = $dbresult2->_numOfRows;
+
+ $maxmatchs = 15;
+
+ if(!$allrows)
+ {
+ $dbresult =
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
+
+ }
+ else
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql
. $ordermethod);
+ }
+
+ while (!$dbresult->EOF)
+ {
+ $agreement[] = array
+ (
+ 'agreement_id' =>
$dbresult->fields['id'],
+ 'num' =>
$dbresult->fields['num'],
+ 'status' =>
$dbresult->fields['status'],
+ 'descr' =>
stripslashes($dbresult->fields['descr'])
+ );
+ $dbresult->MoveNext();
+ }
+// html_print_r($agreement);
+ return $agreement;
+ }
+
+ function select_status_list()
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT id,
descr FROM fm_agreement_status ORDER BY id ");
+
+ $i = 0;
+ while (!$dbresult->EOF)
+ {
+ $status_entries[$i]['id']
= $dbresult->fields['id'];
+ $status_entries[$i]['name']
= stripslashes($dbresult->fields['descr'));
+ $i++;
+ $dbresult->MoveNext();
+ }
+ return $status_entries;
+ }
+
+
+ function read_activity_prize($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $activity_id =
(isset($data['activity_id'])?$data['activity_id']:0);
+ $vendor_id =
(isset($data['vendor_id'])?$data['vendor_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by index_count';
+ }
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " AND cat_id='$cat_id' ";
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND (fm_activities.descr LIKE
'%$query%' or fm_activities.num LIKE '%$query%')";
+ }
+
+ $sql = "SELECT
index_count,this_index,current_index,m_cost,w_cost,total_cost,date"
+ . " FROM fm_activity_price_index Where
activity_id= '$activity_id' and vendor_id= '$vendor_id'";
+
+
+ $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
+ $this->total_records = $dbresult2->_numOfRows;
+
+
+ $maxmatchs = 15;
+
+ if(!$allrows)
+ {
+ $dbresult =
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
+
+ }
+ else
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql
. $ordermethod);
+ }
+
+ while (!$dbresult->EOF)
+ {
+ $pricebook[] = array
+ (
+ 'index_count' =>
$dbresult->fields['index_count'],
+ 'this_index' =>
$dbresult->fields['this_index'],
+ 'current_index' =>
$dbresult->fields['current_index'],
+ 'm_cost' =>
$dbresult->fields['m_cost'],
+ 'w_cost' =>
$dbresult->fields['w_cost'],
+ 'total_cost' =>
$dbresult->fields['total_cost'],
+ 'date' =>
$dbresult->fields['date']
+ );
+ $dbresult->MoveNext();
+ }
+// html_print_r($pricebook);
+ return $pricebook;
+ }
+
+ function read_activities_pr_aggreement($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = " order by activity_id asc";
+ }
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " Where agreement_id='$cat_id'
";
+ }
+ else
+ {
+ $filtermethod = " Where agreement_id IS NULL";
+ }
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+// $querymethod = " AND (fm_activities.descr LIKE
'%$query%' or fm_activities.num LIKE '%$query%')";
+ $querymethod = " and (fm_activities.descr like
'%$query%' or fm_activities.base_descr like '%$query%' or fm_activities.num
like '%$query%') ";
+ }
+
+ $sql = "SELECT fm_activities.id AS activity_id,
fm_activities.num, fm_activities.base_descr, fm_activities.unit,
fm_activities.dim_d, fm_branch.descr as branch, fm_activities.descr, ns3420 "
+ . " FROM fm_activities $this->join fm_branch
on fm_activities.branch_id=fm_branch.id"
+ . " $filtermethod $querymethod ";
+
+ $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
+ $this->total_records = $dbresult2->_numOfRows;
+
+
+ $maxmatchs = 15;
+
+ if(!$allrows)
+ {
+ $dbresult =
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
+
+ }
+ else
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql
. $ordermethod);
+ }
+
+ while (!$dbresult->EOF)
+ {
+ $pricebook[] = array
+ (
+ 'activity_id' =>
$dbresult->fields['activity_id'],
+ 'num' =>
$dbresult->fields['num'],
+ 'base_descr' =>
stripslashes($dbresult->fields['base_descr']),
+ 'branch' =>
$dbresult->fields['branch'],
+ 'dim_d' =>
$dbresult->fields['dim_d'],
+ 'ns3420' =>
$dbresult->fields['ns3420'],
+ 'unit' =>
$dbresult->fields['unit'],
+ 'descr' =>
stripslashes($dbresult->fields['descr'])
+ );
+ $dbresult->MoveNext();
+ }
+// html_print_r($pricebook);
+ return $pricebook;
+ }
+
+ function read_vendor_pr_activity($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $activity_id =
(isset($data['activity_id'])?$data['activity_id']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = " order by
phpgw_addressbook.org_name asc";
+ }
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " Where agreement_id='$cat_id'
";
+ }
+ else
+ {
+ $filtermethod = " Where agreement_id = ''";
+ }
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND
(phpgw_addressbook.org_name LIKE '%$query%' or vendor_id LIKE '%$query%')";
+ }
+
+ $sql = "SELECT fm_activities.id as
activity_id,fm_activities.num, phpgw_addressbook.org_name,fm_branch.descr as
branch ,vendor_id "
+ . " FROM (fm_activities $this->join
fm_activity_price_index ON fm_activities.id =
fm_activity_price_index.activity_id) $this->join phpgw_addressbook ON
fm_activity_price_index.vendor_id = phpgw_addressbook.id "
+ . " $this->join fm_branch on fm_branch.id =
fm_activities.branch_id "
+ . " Where fm_activity_price_index.activity_id=
'$activity_id' $querymethod group by
fm_activities.id,fm_activities.num,fm_branch.descr,org_name ,vendor_id ";
+
+ $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
+ $this->total_records = $dbresult2->_numOfRows;
+
+
+ $maxmatchs = 15;
+
+ if(!$allrows)
+ {
+ $dbresult =
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
+
+ }
+ else
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql
. $ordermethod);
+ }
+
+ while (!$dbresult->EOF)
+ {
+ $pricebook[] = array
+ (
+ 'activity_id' =>
$dbresult->fields['activity_id'],
+ 'num' =>
$dbresult->fields['num'],
+ 'branch' =>
$dbresult->fields['branch'],
+ 'vendor_name' =>
$dbresult->fields['org_name'],
+ 'vendor_id' =>
$dbresult->fields['vendor_id']
+ );
+ $dbresult->MoveNext();
+ }
+ return $pricebook;
+ }
+
+ function read_single_activity($id)
+ {
+ $sql = "SELECT * FROM fm_activities where id='$id'";
+
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
+
+ if (!$dbresult->EOF)
+ {
+ $activity['activity_id']= $id;
+ $activity['num'] =
$dbresult->fields['num'];
+ $activity['unit'] =
$dbresult->fields['unit'];
+ $activity['cat_id'] =
$dbresult->fields['agreement_id'];
+ $activity['ns3420_id'] =
$dbresult->fields['ns3420'];
+ $activity['descr'] =
stripslashes($dbresult->fields['descr']);
+ $activity['base_descr'] =
stripslashes($dbresult->fields['base_descr']);
+ $activity['dim_d'] =
$dbresult->fields['dim_d'];
+ $activity['branch_id'] =
$dbresult->fields['branch_id'];
+
+ return $activity;
+ }
+ }
+
+ function read_single_agreement($id)
+ {
+ $sql = "SELECT * FROM fm_agreement where id='$id'";
+
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
+
+ if (!$dbresult->EOF)
+ {
+ $agreement['agreement_id'] = $id;
+ $agreement['num'] =
$dbresult->fields['num'];
+ $agreement['status'] =
$dbresult->fields['status'];
+ $agreement['descr'] =
stripslashes($dbresult->fields['descr']);
+
+ return $agreement;
+ }
+ }
+
+ function add_activity($values)
+ {
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+ $values['base_descr'] =
$this->db->db_addslashes($values['base_descr']);
+
+ $GLOBALS['phpgw']->db->Execute("INSERT INTO
fm_activities (id,
num,unit,agreement_id,ns3420,dim_d,branch_id,descr,base_descr) "
+ . "VALUES ('" .
+ $values['activity_id']. "','" .
+ $values['num'] . "','" .
+ $values['unit'] . "','" .
+ $values['cat_id'] . "','" . // agreement
+ $values['ns3420_id'] . "','" .
+ $values['dim_d'] . "','" .
+ $values['branch_id'] ."','" .
+ $values['descr'] ."','" .
+ $values['base_descr']. "')");
+
+ $receipt['message'][] = array('msg'=>lang('Activity has
been saved'));
+ $receipt['activity_id']= $values['activity_id'];
+ return $receipt;
+ }
+
+ function edit_activity($values)
+ {
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+ $values['base_descr'] =
$this->db->db_addslashes($values['base_descr']);
+
+ $GLOBALS['phpgw']->db->Execute("UPDATE fm_activities set
+ num='" . $values['num'] . "',
+ unit='" . $values['unit'] . "',
+ agreement_id='" . $values['cat_id'] . "',
+ ns3420='" . $values['ns3420_id'] . "',
+ dim_d='" . $values['dim_d'] . "',
+ branch_id='" . $values['branch_id'] . "',
+ descr='" . $values['descr'] . "',
+ base_descr='" . $values['base_descr']
+ . "' WHERE id= '" . $values['activity_id'] .
"'");
+
+ $receipt['activity_id']= $values['activity_id'];
+ $receipt['message'][] = array('msg'=>lang('Activity has
been edited'));
+ return $receipt;
+ }
+
+ function add_agreement($values)
+ {
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $GLOBALS['phpgw']->db->Execute("INSERT INTO
fm_agreement (id,num,status,descr) "
+ . "VALUES ('" .
+ $values['agreement_id']. "','" .
+ $values['num'] . "','" .
+ $values['status'] . "','" .
+ $values['descr']. "')");
+
+ $receipt['message'][] = array('msg'=>lang('Agreement
has been saved'));
+ $receipt['agreement_id'] = $values['agreement_id'];
+ return $receipt;
+ }
+
+ function edit_agreement($values)
+ {
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $GLOBALS['phpgw']->db->Execute("UPDATE fm_agreement set
+ num='" . $values['num'] . "',
+ status='" . $values['status'] . "',
+ descr='" . $values['descr']
+ . "' WHERE id= '" . $values['agreement_id'] .
"'");
+
+ $receipt['message'][] = array('msg'=>lang('Agreement
has been edited'));
+ return $receipt;
+ }
+
+ function delete_activity_vendor($activity_id,$vendor_id)
+ {
+ $GLOBALS['phpgw']->db->Execute("DELETE FROM
fm_activity_price_index WHERE activity_id='$activity_id' and
vendor_id='$vendor_id'");
+ }
+
+ function delete_activity($activity_id)
+ {
+ $GLOBALS['phpgw']->db->Execute("DELETE FROM
fm_activities WHERE id='$activity_id'");
+ $GLOBALS['phpgw']->db->Execute("DELETE FROM
fm_activity_price_index WHERE activity_id='$activity_id'");
+ }
+
+ function
delete_prize_index($activity_id,$vendor_id,$index_count)
+ {
+ if ($index_count==1)
+ {
+ $GLOBALS['phpgw']->db->Execute("UPDATE
fm_activity_price_index set index_count = '1', current_index = '0',
this_index=Null, m_cost=Null,w_cost=Null,total_cost=Null,date=Null where
activity_id='$activity_id' and vendor_id= '$vendor_id' and index_count= '1'");
+ }
+ else
+ {
+ $GLOBALS['phpgw']->db->Execute("DELETE from
fm_activity_price_index where activity_id='$activity_id' and vendor_id=
'$vendor_id' and index_count= '$index_count'");
+
+ $new_index_count= $index_count -1;
+
+ $GLOBALS['phpgw']->db->Execute("UPDATE
fm_activity_price_index set current_index = '1' where
activity_id='$activity_id' and vendor_id= '$vendor_id' and index_count=
'$new_index_count'");
+ }
+
+ }
+
+ function delete_agreement($agreement_id)
+ {
+ $GLOBALS['phpgw']->db->Execute("DELETE FROM
fm_agreement WHERE id='$agreement_id'");
+//how to handle the activities and vendors ...?
+ }
+
+
+ function add_activity_vendor($values)
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
count(*) FROM fm_activity_price_index where activity_id='" .
$values['activity_id'] . "' and vendor_id='" . $values['vendor_id'] . "'");
+
+
+
+ if ( $dbresult->fields[0])
+ {
+ $receipt['error'][] = array('msg'=>lang('This
Vendor is already registered for this activity'));
+ }
+ else
+ {
+ $GLOBALS['phpgw']->db->Execute("INSERT into
fm_activity_price_index (activity_id, vendor_id,
index_count,current_index,m_cost,w_cost,total_cost) "
+ . " values ('" .
+ $values['activity_id']. "','" .
+ $values['vendor_id'].
"','1','0',NULL,NULL,NULL)");
+
+ $receipt['message'][] =
array('msg'=>lang('Vendor has been added'));
+
+ }
+ return $receipt;
+ }
+ }
+?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/class.sopricebook.php, 1.1.1.3,
nomail <=