[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [12038] property: multi order from project
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [12038] property: multi order from project |
Date: |
Tue, 01 Jul 2014 07:35:43 +0000 |
Revision: 12038
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12038
Author: sigurdne
Date: 2014-07-01 07:35:37 +0000 (Tue, 01 Jul 2014)
Log Message:
-----------
property: multi order from project
Modified Paths:
--------------
trunk/property/inc/class.boproject.inc.php
trunk/property/inc/class.soproject.inc.php
trunk/property/inc/class.soworkorder.inc.php
trunk/property/inc/class.uiproject.inc.php
trunk/property/inc/class.uiwo_hour.inc.php
trunk/property/inc/hook_config.inc.php
trunk/property/templates/base/config.tpl
Modified: trunk/property/inc/class.boproject.inc.php
===================================================================
--- trunk/property/inc/class.boproject.inc.php 2014-06-30 07:52:58 UTC (rev
12037)
+++ trunk/property/inc/class.boproject.inc.php 2014-07-01 07:35:37 UTC (rev
12038)
@@ -871,6 +871,25 @@
$receipt['id'] = $project['id'];
}
}
+ if(isset($project['send_order']) &&
$project['send_order'])
+ {
+ $uiwo_hour =
CreateObject('property.uiwo_hour');
+
+ foreach($project['send_order'] as
$_order_id)
+ {
+ try
+ {
+
$uiwo_hour->send_order($_order_id);
+ }
+ catch(Exception $e)
+ {
+ if ( $e )
+ {
+
phpgwapi_cache::message_set($e->getMessage(), 'error');
+ }
+ }
+ }
+ }
}
else
{
Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php 2014-06-30 07:52:58 UTC (rev
12037)
+++ trunk/property/inc/class.soproject.inc.php 2014-07-01 07:35:37 UTC (rev
12038)
@@ -925,7 +925,8 @@
}
$this->db->query("SELECT DISTINCT fm_workorder.id AS
workorder_id, fm_workorder.title, fm_workorder.vendor_id,
fm_workorder.addition,"
- . " fm_workorder_status.descr as status,
fm_workorder_status.closed, fm_workorder.account_id AS b_account_id,
fm_workorder.charge_tenant"
+ . " fm_workorder_status.descr as status,
fm_workorder_status.closed, fm_workorder.account_id AS b_account_id,
fm_workorder.charge_tenant,"
+ . " fm_workorder.mail_recipients"
. " FROM fm_workorder"
. " {$this->join} fm_workorder_status ON
fm_workorder.status = fm_workorder_status.id"
. " {$this->join} fm_workorder_budget ON
fm_workorder.id = fm_workorder_budget.order_id"
@@ -943,6 +944,7 @@
'charge_tenant' =>
$this->db->f('charge_tenant'),
'status'
=> $this->db->f('status'),
'closed'
=> !!$this->db->f('closed'),
+ 'mail_recipients' =>
explode(',', trim($this->db->f('mail_recipients'), ',')),
'b_account_id' =>
$this->db->f('b_account_id'),
'addition_percentage' => (int)
$this->db->f('addition'),
'calculation' =>
$this->db->f('calculation'),
Modified: trunk/property/inc/class.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php 2014-06-30 07:52:58 UTC
(rev 12037)
+++ trunk/property/inc/class.soworkorder.inc.php 2014-07-01 07:35:37 UTC
(rev 12038)
@@ -79,49 +79,70 @@
{
$this->db->query("SELECT descr FROM fm_b_account where
id='$id' ");
$this->db->next_record();
- return $this->db->f('descr');
+ return $this->db->f('descr',true);
}
function select_status_list()
{
+ static $values = array();
+ if($values)
+ {
+ return $values;
+ }
+
$this->db->query("SELECT id, descr FROM
fm_workorder_status ORDER BY id ");
- $i = 0;
while($this->db->next_record())
{
- $status_entries[$i]['id'] =
$this->db->f('id');
- $status_entries[$i]['name'] =
stripslashes($this->db->f('descr'));
- $i++;
+ $values[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('descr',true)
+ );
}
- return $status_entries;
+ return $values;
}
function select_branch_list()
{
+ static $values = array();
+ if($values)
+ {
+ return $values;
+ }
+
$this->db->query("SELECT id, descr FROM fm_branch ORDER
BY id ");
- $i = 0;
while($this->db->next_record())
{
- $branch_entries[$i]['id'] =
$this->db->f('id');
- $branch_entries[$i]['name'] =
stripslashes($this->db->f('descr'));
- $i++;
+ $values[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('descr',true)
+ );
}
- return $branch_entries;
+ return $values;
}
function select_key_location_list()
{
+ static $values = array();
+ if($values)
+ {
+ return $values;
+ }
+
$this->db->query("SELECT id, descr FROM fm_key_loc
ORDER BY descr ");
- $i = 0;
while($this->db->next_record())
{
- $key_location_entries[$i]['id'] =
$this->db->f('id');
- $key_location_entries[$i]['name'] =
stripslashes($this->db->f('descr'));
- $i++;
+ $values[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('descr',true)
+ );
}
- return (isset($key_location_entries) ?
$key_location_entries : '');
+ return $values;
}
function read($data)
@@ -2836,4 +2857,84 @@
}
}
+ function update_status($data)
+ {
+ $order_id = $data['order_id'];
+ $status = $data['status'];
+
+ $historylog = CreateObject('property.historylog',
'workorder');
+
+ $this->db->query("SELECT status FROM fm_workorder WHERE
id = {$order_id}", __LINE__, __FILE__);
+ $this->db->next_record();
+
+ $old_status =
$this->db->f('status');
+ $check_pending_action = false;
+
+ $this->db->transaction_begin();
+
+ if($old_status != $status)
+ {
+ $historylog->add('S', $order_id, $status,
$old_status);
+ $check_pending_action = true;
+ $this->db->query("UPDATE fm_workorder SET
status = '{$status}' WHERE id = '{$order_id}'", __LINE__, __FILE__);
+ }
+
+ if($check_pending_action)
+ {
+ $this->db->query("SELECT * FROM
fm_workorder_status WHERE id = '{$status}'");
+ $this->db->next_record();
+ if($this->db->f('approved'))
+ {
+ $action_params = array
+ (
+ 'appname'
=> 'property',
+ 'location'
=> '.project.workorder',
+ 'id'
=> $order_id,
+ 'responsible' =>
$this->account,
+ 'responsible_type' =>
'user',
+ 'action'
=> 'approval',
+ 'remark'
=> '',
+ 'deadline'
=> ''
+ );
+
+
execMethod('property.sopending_action.close_pending_action', $action_params);
+ unset($action_params);
+ }
+ if($this->db->f('in_progress'))
+ {
+ $action_params = array
+ (
+ 'appname'
=> 'property',
+ 'location'
=> '.project.workorder',
+ 'id'
=> $order_id,
+ 'responsible' =>
$workorder['vendor_id'],
+ 'responsible_type' =>
'vendor',
+ 'action'
=> 'remind',
+ 'remark'
=> '',
+ 'deadline'
=> ''
+ );
+
+
execMethod('property.sopending_action.close_pending_action', $action_params);
+ unset($action_params);
+ }
+ if($this->db->f('delivered') ||
$this->db->f('closed'))
+ {
+ $action_params = array
+ (
+ 'appname'
=> 'property',
+ 'location'
=> '.project.workorder',
+ 'id'
=> $order_id,
+ 'responsible' =>
$this->account,
+ 'responsible_type' =>
'user',
+ 'action'
=> 'approval',
+ 'remark'
=> '',
+ 'deadline'
=> ''
+ );
+
+
execMethod('property.sopending_action.close_pending_action', $action_params);
+ unset($action_params);
+ }
+ }
+ return $this->db->transaction_commit();
+ }
}
Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php 2014-06-30 07:52:58 UTC (rev
12037)
+++ trunk/property/inc/class.uiproject.inc.php 2014-07-01 07:35:37 UTC (rev
12038)
@@ -1964,6 +1964,16 @@
//_debug_array($values['workorder_budget']);die();
$content_orders = $this->get_orders($id, date('Y'));
+// _debug_array($content_orders);die();
+ foreach($content_orders as & $_order_entry)
+ {
+ $_order_entry['send_order'] = '';
+ if(isset($_order_entry['mail_recipients'][0])
&& $_order_entry['mail_recipients'][0])
+ {
+ $_title = implode(';',
$_order_entry['mail_recipients']);
+ $_order_entry['send_order'] = "<input
type='checkbox' name='values[send_order][]'
value='{$_order_entry['workorder_id']}' title='{$_title}'>";
+ }
+ }
//FIXME: deviation from this one
$datavalues[1] = array
(
@@ -1990,7 +2000,8 @@
array('key' =>
'actual_cost','label'=>lang('actual
cost'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
array('key' =>
'diff','label'=>lang('difference'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
array('key' =>
'vendor_name','label'=>lang('Vendor'),'sortable'=>true,'resizeable'=>true),
-
array('key' =>
'status','label'=>lang('Status'),'sortable'=>true,'resizeable'=>true)))
+
array('key' =>
'status','label'=>lang('Status'),'sortable'=>true,'resizeable'=>true),
+
array('key' => 'send_order','label'=>lang('send
workorder'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter')))
);
Modified: trunk/property/inc/class.uiwo_hour.inc.php
===================================================================
--- trunk/property/inc/class.uiwo_hour.inc.php 2014-06-30 07:52:58 UTC (rev
12037)
+++ trunk/property/inc/class.uiwo_hour.inc.php 2014-07-01 07:35:37 UTC (rev
12038)
@@ -3659,4 +3659,97 @@
return $result;
}
+ function send_order($workorder_id)
+ {
+ $workorder =
$this->boworkorder->read_single($workorder_id);
+ $show_cost = true;
+ $email_receipt = true;
+ $pdfcode = $this->pdf_order($workorder_id, $show_cost);
+ $dir =
"{$GLOBALS['phpgw_info']['server']['temp_dir']}/pdf_files";
+ $attachments = array();
+
+ //save the file
+ if (!file_exists($dir))
+ {
+ mkdir ($dir,0777);
+ }
+ $fname = tempnam($dir.'/','PDF_').'.pdf';
+ $fp = fopen($fname,'w');
+ fwrite($fp,$pdfcode);
+ fclose($fp);
+
+ $attachments[] = array
+ (
+ 'file' => $fname,
+ 'name' => "order_{$workorder_id}.pdf",
+ 'type' => 'application/pdf'
+ );
+
+ $body = lang('order') . '.</br></br>' . lang('see
attachment');
+ $_to = isset($workorder['mail_recipients'][0]) &&
$workorder['mail_recipients'][0] ? implode(';', $workorder['mail_recipients'])
: '';
+// _debug_array($_to);die();
+
$GLOBALS['phpgw']->preferences->set_account_id($workorder['user_id'], true);
+
+ $from_name =
$GLOBALS['phpgw']->accounts->get($workorder['user_id'])->__toString();
+ $from_email =
"{$from_name}<{$GLOBALS['phpgw']->preferences->data['property']['email']}>";
+
if($GLOBALS['phpgw']->preferences->data['property']['order_email_rcpt']==1)
+ {
+ $bcc = $from_email;
+ }
+
+ $subject = lang('Workorder').": ".$workorder_id;
+
+ $address_element =
execMethod('property.botts.get_address_element', $workorder['location_code']);
+ $_address = array();
+ foreach($address_element as $entry)
+ {
+ $_address[] = "{$entry['text']}:
{$entry['value']}";
+ }
+
+ if($_address)
+ {
+ $subject .= ', ' . implode(', ', $_address);
+ }
+
+ if (!is_object($GLOBALS['phpgw']->send))
+ {
+ $GLOBALS['phpgw']->send =
CreateObject('phpgwapi.send');
+ }
+
+ $_status =
isset($this->config->config_data['workorder_ordered_status']) &&
$this->config->config_data['workorder_ordered_status'] ?
$this->config->config_data['workorder_ordered_status'] : 0;
+
+ if(!$_status)
+ {
+ throw new Exception('status on ordered not
given in config');
+ }
+
+ try
+ {
+ $GLOBALS['phpgw']->send->msg('email', $_to,
$subject, $body, '', $cc, $bcc, $from_email, $from_name, 'html', '',
$attachments, $email_receipt);
+ }
+ catch(Exception $e)
+ {
+ if ( $e )
+ {
+ throw $e;
+ }
+ }
+
+ try
+ {
+
execMethod('property.soworkorder.update_status', array('order_id' =>
$workorder_id, 'status' => $_status));
+ }
+ catch(Exception $e)
+ {
+ if ( $e )
+ {
+ throw $e;
+ }
+ }
+
+ $_attachment_log = $attachment_log ?
"::$attachment_log" : '';
+ $historylog =
CreateObject('property.historylog','workorder');
+
$historylog->add('M',$workorder_id,"{$_to}{$_attachment_log}");
+
+ }
}
Modified: trunk/property/inc/hook_config.inc.php
===================================================================
--- trunk/property/inc/hook_config.inc.php 2014-06-30 07:52:58 UTC (rev
12037)
+++ trunk/property/inc/hook_config.inc.php 2014-07-01 07:35:37 UTC (rev
12038)
@@ -222,8 +222,36 @@
return $out;
}
+ /**
+ * Get HTML listbox with workorder status that are to be set when asking
for approval
+ *
+ * @param $config
+ * @return string HTML checkboxes to be placed in a table
+ */
+ function workorder_ordered_status($config)
+ {
+ $status_entries =
execMethod('property.soworkorder.select_status_list');
+ $status_assigned = isset($config['workorder_ordered_status']) ?
$config['workorder_ordered_status'] : array();
+ $out = '<option value="">' . lang('none selected') .
'</option>' . "\n";
+ foreach ( $status_entries as $status)
+ {
+ $selected = '';
+ if ( $status_assigned == $status['id'])
+ {
+ $selected = ' selected = "selected"';
+ }
+
+ $out .= <<<HTML
+ <option
value='{$status['id']}'{$selected}>{$status['name']}</option>
+HTML;
+ }
+
+ return $out;
+ }
+
+
/**
* Get HTML listbox with request status that are to be set when request
is added to a project
*
Modified: trunk/property/templates/base/config.tpl
===================================================================
--- trunk/property/templates/base/config.tpl 2014-06-30 07:52:58 UTC (rev
12037)
+++ trunk/property/templates/base/config.tpl 2014-07-01 07:35:37 UTC (rev
12038)
@@ -105,7 +105,7 @@
</td>
</tr>
- <tr class="row_off">
+ <tr class="row_on">
<td>{lang_project_status_on_last_order_closed}:</td>
<td>
<select
name="newsettings[project_status_on_last_order_closed]">
@@ -114,7 +114,7 @@
</td>
</tr>
- <tr class="row_on">
+ <tr class="row_off">
<td>{lang_workorder_status_on_approval}:</td>
<td>
<select
name="newsettings[workorder_approval_status]">
@@ -122,8 +122,16 @@
</select>
</td>
</tr>
+ <tr class="row_on">
+ <td>{lang_workorder_status_on_ordered}:</td>
+ <td>
+ <select
name="newsettings[workorder_ordered_status]">
+ {hook_workorder_ordered_status}
+ </select>
+ </td>
+ </tr>
- <tr class="row_on">
+ <tr class="row_off">
<td>{lang_request_status_on_project_hookup}:</td>
<td>
<select
name="newsettings[request_project_hookup_status]">
@@ -133,14 +141,14 @@
</tr>
- <tr class="row_off">
+ <tr class="row_on">
<td>{lang_workorder_status_that_are_to_be_set_when_invoice_is_processed}:</td>
<td>
<select name="newsettings[workorder_closed_status]">
{hook_workorder_closed_status}
</select>
</td>
- <tr class="row_on">
+ <tr class="row_off">
<td>{lang_workorder_reopen_status_that_are_to_be_set_when_invoice_is_processed}:</td>
<td>
<select
name="newsettings[workorder_reopen_status]">
@@ -157,7 +165,7 @@
</select>
</td>
</tr>
- <tr class="row_on">
+ <tr class="row_off">
<td>{lang_delay_operation_workorder_end_date},
{lang_last_day_in_year}:</td>
<td>
<select
name="newsettings[delay_operation_workorder_end_date]">
@@ -168,25 +176,25 @@
</tr>
- <tr class="row_off">
+ <tr class="row_on">
<td>{lang_Default_municipal_number}:</td>
<td><input name="newsettings[default_municipal]"
value="{value_default_municipal}"></td>
</tr>
- <tr class="row_on">
+ <tr class="row_off">
<td>{lang_Tax}: [%]</td>
<td><input name="newsettings[fm_tax]"
value="{value_fm_tax}"></td>
</tr>
- <tr class="row_off">
+ <tr class="row_on">
<td>{lang_Enter_the_location_of_files_URL} <br>
{lang_Example}: http://www.domain.com/files</td>
<td><input name="newsettings[files_url]"
value="{value_files_url}"></td>
</tr>
- <tr class="row_on">
+ <tr class="row_off">
<td>{lang_Path_to_external_files_for_use_with_location}:<br>
{lang_On_windows_use}: "//computername/share"
{lang_or} "\\\\computername\share"</td>
<td><input name="newsettings[external_files]"
value="{value_external_files}"></td>
</tr>
- <tr class="row_off">
+ <tr class="row_on">
<td>{lang_max_recursive_level_at_external_files}:</td>
<td>
<select
name="newsettings[external_files_maxlevel]">
@@ -202,7 +210,7 @@
</select>
</td>
</tr>
- <tr class="row_on">
+ <tr class="row_of">
<td>{lang_filter_at_level_at_external_files}:
<br/>(loc1)</td>
<td>
<select
name="newsettings[external_files_filterlevel]">
@@ -218,17 +226,17 @@
</select>
</td>
</tr>
- <tr class="row_on">
+ <tr class="row_off">
<td>{lang_Enter_MAP_URL} <br>
{lang_Example}: http://www.domain.com/map</td>
<td><input name="newsettings[map_url]"
value="{value_map_url}"></td>
</tr>
- <tr class="row_off">
+ <tr class="row_on">
<td>{lang_Enter_GAB_Location_Level} <br>
{lang_Default_value_is}: 3</td>
<td><input name="newsettings[gab_insert_level]"
value="{value_gab_insert_level}"></td>
</tr>
- <tr class="row_on">
+ <tr class="row_off">
<td>{lang_Enter_GAB_URL} <br>
{lang_Example}: http://www.domain.com/gab</td>
<td><input name="newsettings[gab_url]"
value="{value_gab_url}"></td>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [12038] property: multi order from project,
Sigurd Nes <=