function add()
 {
     if (!$this->acl_add) {
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uilocation.stop', 'perm' => 2, 'acl_location' => $this->acl_location));
     }
     $GLOBALS['phpgw_info']['flags']['menu_selection'] .= '::add';
     $receipt = $GLOBALS['phpgw']->session->appsession('session_data', 'add_receipt');
     if (!$receipt) {
         $receipt = array();
     }
     if (isset($receipt['voucher_id']) && $receipt['voucher_id']) {
         $link_receipt = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiinvoice.receipt', 'voucher_id' => $receipt['voucher_id']));
     }
     $GLOBALS['phpgw']->session->appsession('session_data', 'add_receipt', '');
     $bolocation = CreateObject('property.bolocation');
     $referer = parse_url(phpgw::get_var('HTTP_REFERER', 'string', 'SERVER'));
     parse_str($referer['query']);
     // produce $menuaction
     if (phpgw::get_var('cancel', 'bool') || $menuaction != 'property.uiinvoice.add') {
         $GLOBALS['phpgw']->session->appsession('session_data', 'add_values', '');
     }
     if (!$GLOBALS['phpgw']->session->appsession('session_data', 'add_values') && phpgw::get_var('add_invoice', 'bool')) {
         $values['art'] = phpgw::get_var('art', 'int');
         $values['type'] = phpgw::get_var('type');
         $values['dim_b'] = phpgw::get_var('dim_b', 'int');
         $values['invoice_num'] = phpgw::get_var('invoice_num');
         $values['kid_nr'] = phpgw::get_var('kid_nr');
         $values['vendor_id'] = phpgw::get_var('vendor_id', 'int');
         $values['vendor_name'] = phpgw::get_var('vendor_name');
         $values['janitor'] = phpgw::get_var('janitor');
         $values['supervisor'] = phpgw::get_var('supervisor');
         $values['budget_responsible'] = phpgw::get_var('budget_responsible');
         $values['invoice_date'] = urldecode(phpgw::get_var('invoice_date'));
         $values['num_days'] = phpgw::get_var('num_days', 'int');
         $values['payment_date'] = urldecode(phpgw::get_var('payment_date'));
         $values['sday'] = phpgw::get_var('sday', 'int');
         $values['smonth'] = phpgw::get_var('smonth', 'int');
         $values['syear'] = phpgw::get_var('syear', 'int');
         $values['eday'] = phpgw::get_var('eday', 'int');
         $values['emonth'] = phpgw::get_var('emonth', 'int');
         $values['eyear'] = phpgw::get_var('eyear', 'int');
         $values['auto_tax'] = phpgw::get_var('auto_tax', 'bool');
         $values['merknad'] = phpgw::get_var('merknad');
         $values['b_account_id'] = phpgw::get_var('b_account_id', 'int');
         $values['b_account_name'] = phpgw::get_var('b_account_name');
         $values['amount'] = phpgw::get_var('amount');
         // float - has to accept string until client side validation is in place.
         if (isset($GLOBALS['phpgw_info']['user']['preferences']['common']['currency'])) {
             $values['amount'] = str_ireplace($GLOBALS['phpgw_info']['user']['preferences']['common']['currency'], '', $values['amount']);
         }
         $values['amount'] = str_replace(' ', '', $values['amount']);
         $values['amount'] = str_replace(',', '.', $values['amount']);
         $values['order_id'] = phpgw::get_var('order_id');
         $insert_record = $GLOBALS['phpgw']->session->appsession('insert_record', 'property');
         $values = $this->bocommon->collect_locationdata($values, $insert_record);
         $GLOBALS['phpgw']->session->appsession('session_data', 'add_values', $values);
     } else {
         $values = $GLOBALS['phpgw']->session->appsession('session_data', 'add_values');
         $GLOBALS['phpgw']->session->appsession('session_data', 'add_values', '');
     }
     $location_code = phpgw::get_var('location_code');
     $debug = phpgw::get_var('debug', 'bool');
     $add_invoice = phpgw::get_var('add_invoice', 'bool');
     if ($location_code) {
         $values['location_data'] = $bolocation->read_single($location_code, array('tenant_id' => $tenant_id, 'p_num' => $p_num));
     }
     if ($add_invoice && is_array($values)) {
         $order = false;
         if ($values['order_id'] && !ctype_digit($values['order_id'])) {
             $receipt['error'][] = array('msg' => lang('Please enter an integer for order!'));
             unset($values['order_id']);
         } else {
             if ($values['order_id']) {
                 $order = true;
             }
         }
         if (!$values['amount']) {
             $receipt['error'][] = array('msg' => lang('Please - enter an amount!'));
         }
         if (!$values['art']) {
             $receipt['error'][] = array('msg' => lang('Please - select type invoice!'));
         }
         if (!$values['vendor_id'] && !$order) {
             $receipt['error'][] = array('msg' => lang('Please - select Vendor!'));
         }
         if (!$values['type']) {
             $receipt['error'][] = array('msg' => lang('Please - select type order!'));
         }
         if (!$values['budget_responsible'] && (!isset($order) || !$order)) {
             $receipt['error'][] = array('msg' => lang('Please - select budget responsible!'));
         }
         if (!$values['invoice_num']) {
             $receipt['error'][] = array('msg' => lang('Please - enter a invoice num!'));
         }
         if (!$order && $values['vendor_id']) {
             if (!$this->bo->check_vendor($values['vendor_id'])) {
                 $receipt['error'][] = array('msg' => lang('That Vendor ID is not valid !') . ' : ' . $values['vendor_id']);
             }
         }
         if (!$values['payment_date'] && !$values['num_days']) {
             $receipt['error'][] = array('msg' => lang('Please - select either payment date or number of days from invoice date !'));
         }
         //_debug_array($values);
         if (!is_array($receipt['error'])) {
             if ($values['invoice_date']) {
                 $sdateparts = phpgwapi_datetime::date_array($values['invoice_date']);
                 $values['sday'] = $sdateparts['day'];
                 $values['smonth'] = $sdateparts['month'];
                 $values['syear'] = $sdateparts['year'];
                 unset($sdateparts);
                 $edateparts = phpgwapi_datetime::date_array($values['payment_date']);
                 $values['eday'] = $edateparts['day'];
                 $values['emonth'] = $edateparts['month'];
                 $values['eyear'] = $edateparts['year'];
                 unset($edateparts);
             }
             $values['regtid'] = date($GLOBALS['phpgw']->db->datetime_format());
             $_receipt = array();
             //local errors
             $receipt = $this->bo->add($values, $debug);
             if (!$receipt['message'] && $values['order_id'] && !$receipt[0]['spvend_code']) {
                 $_receipt['error'][] = array('msg' => lang('vendor is not defined in order %1', $values['order_id']));
                 $debug = false;
                 // try again..
                 if ($receipt[0]['location_code']) {
                     //					$values['location_data'] = $bolocation->read_single($receipt['location_code'],array('tenant_id'=>$tenant_id,'p_num'=>$p_num));
                 }
             }
             if ($debug) {
                 $this->debug($receipt);
                 return;
             }
             if (!$_receipt['error']) {
                 unset($values);
                 $GLOBALS['phpgw']->session->appsession('session_data', 'add_receipt', $receipt);
                 $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiinvoice.add'));
             }
         } else {
             if ($values['location']) {
                 $location_code = implode("-", $values['location']);
                 $values['location_data'] = $bolocation->read_single($location_code, isset($values['extra']) ? $values['extra'] : '');
             }
             $GLOBALS['phpgw']->session->appsession('session_data', 'add_values', '');
         }
     }
     if (isset($receipt['voucher_id']) && $receipt['voucher_id']) {
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiinvoice.list_sub', 'user_lid' => $GLOBALS['phpgw_info']['user']['account_lid'], 'voucher_id' => $receipt['voucher_id']));
     }
     $location_data = $bolocation->initiate_ui_location(array('values' => isset($values['location_data']) ? $values['location_data'] : '', 'type_id' => -1, 'no_link' => false, 'tenant' => false, 'lookup_type' => 'form', 'lookup_entity' => false, 'entity_data' => false));
     $b_account_data = $this->bocommon->initiate_ui_budget_account_lookup(array('b_account_id' => isset($values['b_account_id']) ? $values['b_account_id'] : '', 'b_account_name' => isset($values['b_account_name']) ? $values['b_account_name'] : ''));
     $link_data = array('menuaction' => 'property.uiinvoice.add', 'debug' => true);
     if ($_receipt) {
         $receipt = array_merge($receipt, $_receipt);
     }
     $msgbox_data = $this->bocommon->msgbox_data($receipt);
     $GLOBALS['phpgw']->jqcal->add_listener('invoice_date');
     $GLOBALS['phpgw']->jqcal->add_listener('payment_date');
     $data = array('menu' => $this->bocommon->get_menu(), 'msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data), 'form_action' => $GLOBALS['phpgw']->link('/index.php', $link_data), 'cancel_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiinvoice.index')), 'lang_cancel' => lang('Cancel'), 'lang_cancel_statustext' => lang('cancel'), 'action_url' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property' . '.uiinvoice.add')), 'tsvfilename' => '', 'lang_add' => lang('add'), 'lang_add_statustext' => lang('click this button to add a invoice'), 'lang_invoice_date' => lang('invoice date'), 'lang_payment_date' => lang('Payment date'), 'lang_no_of_days' => lang('Days'), 'lang_invoice_number' => lang('Invoice Number'), 'lang_invoice_num_statustext' => lang('Enter Invoice Number'), 'lang_select' => lang('Select per button !'), 'lang_kidnr' => lang('KID nr'), 'lang_kid_nr_statustext' => lang('Enter Kid nr'), 'lang_vendor' => lang('Vendor'), 'addressbook_link' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilookup.vendor')), 'lang_invoice_date_statustext' => lang('Enter the invoice date'), 'lang_num_days_statustext' => lang('Enter the payment date or the payment delay'), 'lang_payment_date_statustext' => lang('Enter the payment date or the payment delay'), 'lang_vendor_statustext' => lang('Select the vendor by clicking the button'), 'lang_vendor_name_statustext' => lang('Select the vendor by clicking the button'), 'lang_select_vendor_statustext' => lang('Select the vendor by clicking this button'), 'value_invoice_date' => isset($values['invoice_date']) ? $values['invoice_date'] : '', 'value_payment_date' => isset($values['payment_date']) ? $values['payment_date'] : '', 'value_belop' => isset($values['belop']) ? $values['belop'] : '', 'value_vendor_id' => isset($values['vendor_id']) ? $values['vendor_id'] : '', 'value_vendor_name' => isset($values['vendor_name']) ? $values['vendor_name'] : '', 'value_kid_nr' => isset($values['kid_nr']) ? $values['kid_nr'] : '', 'value_dim_b' => isset($values['dim_b']) ? $values['dim_b'] : '', 'value_invoice_num' => isset($values['invoice_num']) ? $values['invoice_num'] : '', 'value_merknad' => isset($values['merknad']) ? $values['merknad'] : '', 'value_num_days' => isset($values['num_days']) ? $values['num_days'] : '', 'value_amount' => isset($values['amount']) ? $values['amount'] : '', 'value_order_id' => isset($values['order_id']) ? $values['order_id'] : '', 'lang_auto_tax' => lang('Auto TAX'), 'lang_auto_tax_statustext' => lang('Set tax'), 'lang_amount' => lang('Amount'), 'lang_amount_statustext' => lang('Amount of the invoice'), 'lang_order' => lang('Order ID'), 'lang_order_statustext' => lang('Order # that initiated the invoice'), 'lang_art' => lang('Art'), 'art_list' => $this->bo->get_lisfm_ecoart(isset($values['art']) ? $values['art'] : ''), 'select_art' => 'art', 'lang_select_art' => lang('Select Invoice Type'), 'lang_art_statustext' => lang('You have to select type of invoice'), 'lang_type' => lang('Type invoice II'), 'type_list' => $this->bo->get_type_list(isset($values['type']) ? $values['type'] : ''), 'select_type' => 'type', 'lang_no_type' => lang('No type'), 'lang_type_statustext' => lang('Select the type  invoice. To do not use type -  select NO TYPE'), 'lang_dimb' => lang('Dim B'), 'dimb_list' => $this->bo->select_dimb_list(isset($values['dim_b']) ? $values['dim_b'] : ''), 'select_dimb' => 'dim_b', 'lang_no_dimb' => lang('No Dim B'), 'lang_dimb_statustext' => lang('Select the Dim B for this invoice. To do not use Dim B -  select NO DIM B'), 'lang_janitor' => lang('Janitor'), 'janitor_list' => $this->bocommon->get_user_list_right(32, isset($values['janitor']) ? $values['janitor'] : '', '.invoice'), 'select_janitor' => 'janitor', 'lang_no_janitor' => lang('No janitor'), 'lang_janitor_statustext' => lang('Select the janitor responsible for this invoice. To do not use janitor -  select NO JANITOR'), 'lang_supervisor' => lang('Supervisor'), 'supervisor_list' => $this->bocommon->get_user_list_right(64, isset($values['supervisor']) ? $values['supervisor'] : '', '.invoice'), 'select_supervisor' => 'supervisor', 'lang_no_supervisor' => lang('No supervisor'), 'lang_supervisor_statustext' => lang('Select the supervisor responsible for this invoice. To do not use supervisor -  select NO SUPERVISOR'), 'lang_budget_responsible' => lang('B - responsible'), 'budget_responsible_list' => $this->bocommon->get_user_list_right(128, isset($values['budget_responsible']) ? $values['budget_responsible'] : '', '.invoice'), 'select_budget_responsible' => 'budget_responsible', 'lang_select_budget_responsible' => lang('Select B-Responsible'), 'lang_budget_responsible_statustext' => lang('You have to select a budget responsible for this invoice in order to add the invoice'), 'lang_merknad' => lang('Descr'), 'lang_merknad_statustext' => lang('Descr'), 'location_data' => $location_data, 'b_account_data' => $b_account_data, 'link_receipt' => isset($link_receipt) ? $link_receipt : '', 'lang_receipt' => lang('receipt'));
     //_debug_array($data);
     $GLOBALS['phpgw']->xslttpl->add_file(array('invoice'));
     $appname = lang('Invoice');
     $function_msg = lang('Add invoice');
     $GLOBALS['phpgw_info']['flags']['app_header'] = lang('property') . ' - ' . $appname . ': ' . $function_msg;
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('add' => $data));
     //	$GLOBALS['phpgw']->xslttpl->pp();
 }
 function save($values)
 {
     $document_date = phpgwapi_datetime::date_array($values['document_date']);
     $values['document_date'] = mktime(2, 0, 0, $document_date['month'], $document_date['day'], $document_date['year']);
     //_debug_array($values);
     if ($values['document_id']) {
         if ($values['document_id'] != 0) {
             $receipt = $this->so->edit($values);
         }
     } else {
         $receipt = $this->so->add($values);
     }
     return $receipt;
 }
Exemplo n.º 3
0
 function import()
 {
     if (!$this->acl_add) {
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uilocation.stop', 'perm' => 2, 'acl_location' => $this->acl_location));
     }
     $GLOBALS['phpgw_info']['flags']['menu_selection'] .= '::import';
     $receipt = $GLOBALS['phpgw']->session->appsession('session_data', 'import_receipt');
     $GLOBALS['phpgw']->session->appsession('session_data', 'import_receipt', '');
     $art = phpgw::get_var('art', 'int');
     $type = phpgw::get_var('type');
     $dim_b = phpgw::get_var('dim_b', 'int');
     $invoice_num = phpgw::get_var('invoice_num');
     $kid_nr = phpgw::get_var('kid_nr');
     $vendor_id = phpgw::get_var('vendor_id', 'int');
     $vendor_name = phpgw::get_var('vendor_name');
     $janitor = phpgw::get_var('janitor');
     $supervisor = phpgw::get_var('supervisor');
     $budget_responsible = phpgw::get_var('budget_responsible');
     $invoice_date = urldecode(phpgw::get_var('invoice_date'));
     $num_days = phpgw::get_var('num_days', 'int');
     $payment_date = urldecode(phpgw::get_var('payment_date'));
     $cancel = phpgw::get_var('cancel', 'bool');
     $convert = phpgw::get_var('convert', 'bool');
     $conv_type = phpgw::get_var('conv_type');
     $sday = phpgw::get_var('sday', 'int');
     $smonth = phpgw::get_var('smonth', 'int');
     $syear = phpgw::get_var('syear', 'int');
     $eday = phpgw::get_var('eday', 'int');
     $emonth = phpgw::get_var('emonth', 'int');
     $eyear = phpgw::get_var('eyear', 'int');
     $download = phpgw::get_var('download', 'bool');
     $auto_tax = phpgw::get_var('auto_tax', 'bool');
     $tsvfile = $_FILES['tsvfile']['tmp_name'];
     if (!$tsvfile) {
         $tsvfile = phpgw::get_var('tsvfile');
     }
     if ($cancel && $tsvfile) {
         unlink($tsvfile);
     }
     if ($convert) {
         unset($receipt);
         if ($conv_type == '') {
             $receipt['error'][] = array('msg' => lang('Please - select a import format !'));
         }
         if (!$tsvfile) {
             $receipt['error'][] = array('msg' => lang('Please - select a file to import from !'));
         }
         if (!$art) {
             $receipt['error'][] = array('msg' => lang('Please - select type invoice!'));
         }
         if (!$vendor_id) {
             $receipt['error'][] = array('msg' => lang('Please - select Vendor!'));
         }
         if (!$type) {
             $receipt['error'][] = array('msg' => lang('Please - select type order!'));
         }
         if (!$budget_responsible) {
             $receipt['error'][] = array('msg' => lang('Please - select budget responsible!'));
         }
         if (!$this->invoice->check_vendor($vendor_id)) {
             $receipt['error'][] = array('msg' => lang('That Vendor ID is not valid !') . ' : ' . $vendor_id);
         }
         if (!$payment_date && !$num_days) {
             $receipt['error'][] = array('msg' => lang('Please - select either payment date or number of days from invoice date !'));
         }
         if (!file_exists($tsvfile)) {
             $receipt['error'][] = array('msg' => lang('The file is empty or removed!'));
         }
         if (!is_array($receipt['error'])) {
             if ($invoice_date) {
                 $sdateparts = phpgwapi_datetime::date_array($invoice_date);
                 $sday = $sdateparts['day'];
                 $smonth = $sdateparts['month'];
                 $syear = $sdateparts['year'];
                 unset($sdateparts);
                 $edateparts = phpgwapi_datetime::date_array($payment_date);
                 $eday = $edateparts['day'];
                 $emonth = $edateparts['month'];
                 $eyear = $edateparts['year'];
                 unset($edateparts);
             }
             $old = $tsvfile;
             $tsvfile = $GLOBALS['phpgw_info']['server']['temp_dir'] . '/invoice_import_' . basename($tsvfile);
             rename($old, $tsvfile);
             $invoice_common = array('bilagsnr' => $this->invoice->next_bilagsnr(), 'art' => $art, 'type' => $type, 'dim_b' => $dim_b, 'invoice_num' => $invoice_num, 'kid_nr' => $kid_nr, 'vendor_id' => $vendor_id, 'vendor_name' => $vendor_name, 'janitor' => $janitor, 'supervisor' => $supervisor, 'budget_responsible' => $budget_responsible, 'num_days' => $num_days, 'sday' => $sday, 'smonth' => $smonth, 'syear' => $syear, 'eday' => $eday, 'emonth' => $emonth, 'eyear' => $eyear, 'tsvfile' => $tsvfile, 'conv_type' => $conv_type, 'invoice_date' => $invoice_date, 'payment_date' => $payment_date, 'auto_tax' => $auto_tax);
             $buffer = $this->bo->import($invoice_common, $download);
             if (!$download) {
                 $receipt = $buffer;
                 $GLOBALS['phpgw']->session->appsession('session_data', 'import_receipt', $receipt);
                 unlink($tsvfile);
                 unset($invoice_common);
                 unset($art);
                 unset($type);
                 unset($dim_b);
                 unset($invoice_num);
                 unset($kid_nr);
                 unset($vendor_id);
                 unset($vendor_name);
                 unset($janitor);
                 unset($supervisor);
                 unset($budget_responsible);
                 unset($invoice_date);
                 unset($num_days);
                 unset($payment_date);
                 unset($conv_type);
                 unset($auto_tax);
                 //						$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 'property.uiXport.import'));
             } else {
                 $GLOBALS['phpgw_info']['flags']['noframework'] = true;
                 $this->debug_import($buffer, $invoice_common);
                 return;
             }
         }
     }
     set_time_limit(0);
     $link_data = array('menuaction' => 'property.uiXport.import', 'sub' => $sub);
     $msgbox_data = $this->bocommon->msgbox_data($receipt);
     $GLOBALS['phpgw']->jqcal->add_listener('invoice_date');
     $GLOBALS['phpgw']->jqcal->add_listener('payment_date');
     $data = array('menu' => $this->bocommon->get_menu(), 'msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data), 'form_action' => $GLOBALS['phpgw']->link('/index.php', $link_data), 'cancel_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiinvoice.index', 'sub' => $sub)), 'lang_cancel' => lang('Cancel'), 'lang_cancel_statustext' => lang('cancel the import'), 'action_url' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property' . '.uiXport.import')), 'tsvfilename' => '', 'lang_debug' => lang('Debug output in browser'), 'lang_debug_statustext' => lang('Check this to have the output to screen before import (recommended)'), 'value_debug' => $download, 'lang_import' => lang('Import'), 'lang_import_statustext' => lang('click this button to start the import'), 'lang_invoice_date' => lang('invoice date'), 'lang_payment_date' => lang('Payment date'), 'lang_no_of_days' => lang('Days'), 'lang_invoice_number' => lang('Invoice Number'), 'lang_invoice_num_statustext' => lang('Enter Invoice Number'), 'lang_select' => lang('Select per button !'), 'lang_kidnr' => lang('KID nr'), 'lang_kid_nr_statustext' => lang('Enter Kid nr'), 'lang_vendor' => lang('Vendor'), 'addressbook_link' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilookup.vendor')), 'lang_invoice_date_statustext' => lang('Enter the invoice date'), 'lang_num_days_statustext' => lang('Enter the payment date or the payment delay'), 'lang_payment_date_statustext' => lang('Enter the payment date or the payment delay'), 'lang_file_statustext' => lang('Select the file to import from'), 'lang_vendor_statustext' => lang('Select the vendor by clicking the button'), 'lang_vendor_name_statustext' => lang('Select the vendor by clicking the button'), 'lang_select_vendor_statustext' => lang('Select the vendor by clicking this button'), 'value_invoice_date' => $invoice_date, 'value_payment_date' => $payment_date, 'value_belop' => $belop, 'value_vendor_id' => $vendor_id, 'value_vendor_name' => $vendor_name, 'value_kid_nr' => $kid_nr, 'value_dim_b' => $dim_b, 'value_invoice_num' => $invoice_num, 'value_merknad' => $merknad, 'value_num_days' => $num_days, 'lang_file' => lang('File'), 'lang_conv' => lang('Conversion'), 'conv_list' => $this->bo->select_import_conv($conv_type), 'select_conv' => 'conv_type', 'lang_select_conversion' => lang('Select the type of conversion:'), 'lang_conv_statustext' => lang('You have to select the Conversion for this import'), 'lang_auto_tax' => lang('Auto TAX'), 'lang_auto_tax_statustext' => lang('Set tax during import'), 'lang_art' => lang('Art'), 'art_list' => $this->invoice->get_lisfm_ecoart($art), 'select_art' => 'art', 'lang_select_art' => lang('Select Invoice Type'), 'lang_art_statustext' => lang('You have to select type of invoice'), 'lang_type' => lang('Type invoice II'), 'type_list' => $this->invoice->get_type_list($type), 'select_type' => 'type', 'lang_no_type' => lang('No type'), 'lang_type_statustext' => lang('Select the type  invoice. To do not use type -  select NO TYPE'), 'lang_dimb' => lang('Dim B'), 'dimb_list' => $this->invoice->select_dimb_list($dim_b), 'select_dimb' => 'dim_b', 'lang_no_dimb' => lang('No Dim B'), 'lang_dimb_statustext' => lang('Select the Dim B for this invoice. To do not use Dim B -  select NO DIM B'), 'lang_janitor' => lang('Janitor'), 'janitor_list' => $this->bocommon->get_user_list_right(32, $janitor, '.invoice'), 'select_janitor' => 'janitor', 'lang_no_janitor' => lang('No janitor'), 'lang_janitor_statustext' => lang('Select the janitor responsible for this invoice. To do not use janitor -  select NO JANITOR'), 'lang_supervisor' => lang('Supervisor'), 'supervisor_list' => $this->bocommon->get_user_list_right(64, $supervisor, '.invoice'), 'select_supervisor' => 'supervisor', 'lang_no_supervisor' => lang('No supervisor'), 'lang_supervisor_statustext' => lang('Select the supervisor responsible for this invoice. To do not use supervisor -  select NO SUPERVISOR'), 'lang_budget_responsible' => lang('B - responsible'), 'budget_responsible_list' => $this->bocommon->get_user_list_right(128, $budget_responsible, '.invoice'), 'select_budget_responsible' => 'budget_responsible', 'lang_select_budget_responsible' => lang('Select B-Responsible'), 'lang_budget_responsible_statustext' => lang('You have to select a budget responsible for this invoice in order to make the import'));
     $GLOBALS['phpgw']->xslttpl->add_file(array('invoice'));
     $appname = lang('Invoice');
     $function_msg = lang('Import from CSV');
     $GLOBALS['phpgw_info']['flags']['app_header'] = lang('property') . ' - ' . $appname . ': ' . $function_msg;
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('import' => $data));
     //	$GLOBALS['phpgw']->xslttpl->pp();
 }
 function update_investment($values)
 {
     $date_array = phpgwapi_datetime::date_array($values['date']);
     $date = mktime(2, 0, 0, $date_array['month'], $date_array['day'], $date_array['year']);
     $date = date($GLOBALS['phpgw']->db->date_format(), $date);
     $new_index = str_replace(",", ".", $values['new_index']);
     $update = array();
     foreach ($values['update'] as $entry) {
         $local_error = false;
         $n = $entry;
         if ($values['value'][$n]) {
             if (abs($values['value'][$n]) - abs($values['initial_value'][$n] * $new_index) < 0) {
                 $new_value = 0;
                 $new_index = $values['value'][$n] / $values['initial_value'][$n];
             } else {
                 $new_value = $values['value'][$n] - $values['initial_value'][$n] * $new_index;
             }
             $update[] = array('entity_id' => $values['entity_id'][$n], 'invest_id' => $values['investment_id'][$n], 'new_index' => $new_index, 'new_value' => $new_value, 'initial_value' => $values['initial_value'][$n], 'date' => $date);
         }
     }
     return $this->so->update_investment($update);
 }
 /**
  * Prepare an attribute value so it can be saved in the database
  *
  * @param array $values_attribute an attribute structure
  *
  * @return array the structure with the value prepared
  *
  * @internal the name of this method is misleading
  */
 public function convert_attribute_save($values_attribute = null)
 {
     if (!is_array($values_attribute)) {
         return '';
     }
     foreach ($values_attribute as &$attrib) {
         if (!$attrib['value']) {
             continue;
         }
         switch ($attrib['datatype']) {
             case 'CH':
                 $attrib['value'] = ',' . implode(',', $attrib['value']) . ',';
                 break;
             case 'R':
                 $attrib['value'] = $attrib['value'][0];
                 break;
             case 'N':
                 $attrib['value'] = str_replace(',', '.', $attrib['value']);
                 break;
             case 'D':
                 $ts = phpgwapi_datetime::date_to_timestamp($attrib['value']) - phpgwapi_datetime::user_timezone();
                 $attrib['value'] = date($this->_dateformat, $ts);
                 break;
             case 'DT':
                 if ($attrib['value']['date']) {
                     $date_array = phpgwapi_datetime::date_array($attrib['value']['date']);
                     $ts = mktime((int) $attrib['value']['hour'], (int) $attrib['value']['min'], 0, $date_array['month'], $date_array['day'], $date_array['year']) - phpgwapi_datetime::user_timezone();
                     $attrib['value'] = date($this->_datetimeformat, $ts);
                 } else {
                     $attrib['value'] = '';
                 }
                 break;
         }
     }
     return $values_attribute;
 }
Exemplo n.º 6
0
 function date_to_timestamp($date)
 {
     if ($date) {
         $date_array = phpgwapi_datetime::date_array($date);
         $date = mktime(8, 0, 0, $date_array['month'], $date_array['day'], $date_array['year']);
     }
     return $date;
 }
 function add_activity_first_prize($values)
 {
     $date_array = phpgwapi_datetime::date_array($values['date']);
     $date = mktime(2, 0, 0, $date_array['month'], $date_array['day'], $date_array['year']);
     //			$date= date($GLOBALS['phpgw']->db->date_format(),$date);
     $m_cost = str_replace(",", ".", $values['m_cost']);
     $w_cost = str_replace(",", ".", $values['w_cost']);
     $total_cost = $m_cost + $w_cost;
     $activity_id = $values['activity_id'][0];
     $agreement_id = $values['agreement_id'][0];
     $receipt = $this->so->add_activity_first_prize($m_cost, $w_cost, $total_cost, $activity_id, $agreement_id, $date);
     return $receipt;
 }