Beispiel #1
0
 public function generateControlPanelHTML($cp_array, &$messages)
 {
     $string = '';
     // Amount of active deals should be shown.
     $query = 'SELECT count(id) AS amount FROM deal WHERE status = 1';
     $result = $this->db->select($query);
     $active = $result[0]['amount'];
     foreach ($cp_array as $index => $row) {
         $request_params = array();
         $request_params['class_name'] = 'ajax_accounting_modules_AjaxControlPanel';
         $request_params['action'] = $row['action'];
         $request_params = json_encode($request_params);
         $options = array();
         $options['id'] = 'btn_cp_' . $index;
         $options['css_class'] = 'btn btn-primary btn-block';
         $options['onclick'] = 'ajax_request(' . $request_params . ')';
         $options['content'] = $row['button_name'];
         if ($row['action'] === 'show_deals') {
             $options['content'] .= ' <span id=\'deals_badge\' class=\'badge\'>' . $active . '</span>';
         }
         $button = new html_elements_Button($options);
         $string .= $button->generateButtonHTML();
     }
     return $string;
 }
Beispiel #2
0
 public function showDeals()
 {
     $buttonHTML = '';
     $contentHTML = '';
     // This will be fired each time the deals are saved.
     $script = '$("#deals_table").tableConstructor(\'DealTable\', true);';
     // Amount of active deals should be shown.
     $query = 'SELECT count(id) AS amount FROM deal WHERE status = 1';
     $activeAmount = $this->db->select($query)[0]['amount'];
     $script .= '$(\'#deals_badge\').text(\'' . $activeAmount . '\');';
     // Add button on the bottom of control panel.
     $request_params['class_name'] = 'ajax_accounting_AjaxDeal';
     $request_params['action'] = 'generate_form';
     $request_params = json_encode($request_params);
     $options = array();
     $options['id'] = 'add_deal_button';
     $options['css_class'] = 'btn btn-default btn-block btn-info text-left';
     $options['onclick'] = 'ajax_request(' . $request_params . ')';
     $options['content'] = '<span class=\'glyphicon glyphicon-plus\' aria-hidden=\'true\'>&nbsp</span>Добавить';
     $button = new html_elements_Button($options);
     $buttonHTML .= $button->generateButtonHTML();
     // Add table with all payments.
     $contentHTML .= '<h2>Сделки</h2>';
     $contentHTML .= '<table id=\'deals_table\' class=\'table table-hover table-striped\'></table>';
     $response[0]['id'] = 'extra_button';
     $response[0]['html'] = $buttonHTML;
     $response[1]['id'] = 'extra_content';
     $response[1]['html'] = '';
     $response[2]['id'] = 'content';
     $response[2]['html'] = $contentHTML;
     $response['script'] = $script;
     return $response;
 }
Beispiel #3
0
    public function generateCustomerForm()
    {
        $id = 0;
        $last_name = '';
        $first_name = '';
        $middle_name = '';
        $nick_name = '';
        $email = '';
        $extras = '';
        $country = '';
        $zip_code = '';
        $city = '';
        $street = '';
        $street_number = '';
        $room_number = '';
        $phone = '';
        $action = 'add_customer';
        // If an existing id was passed then we need to edit an object.
        if (array_key_exists('id', $this->params) === TRUE && (int) $this->params['id'] > 0) {
            $id = (int) $this->params['id'];
            $action = 'edit_customer';
        }
        if (array_key_exists('row_data', $this->params) === TRUE) {
            if (array_key_exists('last_name', $this->params['row_data']) === TRUE) {
                $last_name = $this->params['row_data']['last_name'];
            }
            if (array_key_exists('first_name', $this->params['row_data']) === TRUE) {
                $first_name = $this->params['row_data']['first_name'];
            }
            if (array_key_exists('middle_name', $this->params['row_data']) === TRUE) {
                $middle_name = $this->params['row_data']['middle_name'];
            }
            if (array_key_exists('nick_name', $this->params['row_data']) === TRUE) {
                $nick_name = $this->params['row_data']['nick_name'];
            }
            if (array_key_exists('email', $this->params['row_data']) === TRUE) {
                $email = $this->params['row_data']['email'];
            }
            if (array_key_exists('extras', $this->params['row_data']) === TRUE) {
                $extras = $this->params['row_data']['extras'];
            }
            if (array_key_exists('country', $this->params['row_data']) === TRUE) {
                $country = $this->params['row_data']['country'];
            }
            if (array_key_exists('zip_code', $this->params['row_data']) === TRUE) {
                $zip_code = $this->params['row_data']['zip_code'];
            }
            if (array_key_exists('city', $this->params['row_data']) === TRUE) {
                $city = $this->params['row_data']['city'];
            }
            if (array_key_exists('street', $this->params['row_data']) === TRUE) {
                $street = $this->params['row_data']['street'];
            }
            if (array_key_exists('street_number', $this->params['row_data']) === TRUE) {
                $street_number = $this->params['row_data']['street_number'];
            }
            if (array_key_exists('room_number', $this->params['row_data']) === TRUE) {
                $room_number = $this->params['row_data']['room_number'];
            }
            if (array_key_exists('phone', $this->params['row_data']) === TRUE) {
                $phone = $this->params['row_data']['phone'];
            }
        }
        $options = array();
        $options['id'] = 'add_button';
        $options['css_class'] = 'btn btn-default btn-add';
        $options['onclick'] = 'addCustomer()';
        $options['content'] = 'Сохранить';
        $button = new html_elements_Button($options);
        $buttonHTML = '';
        $buttonHTML = $button->generateButtonHTML();
        $string = '
            <form class="form-horizontal" method="post" action="ajax.php">
                <div class="form-group">
                    <label for="input_last_name" class="col-sm-2 control-label">Фамилия</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="input_last_name" name="input_last_name" placeholder=\'Фамилия\' value=\'' . $last_name . '\'>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input_first_name" class="col-sm-2 control-label">Имя</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="input_first_name" name="input_first_name" placeholder=\'Имя\' value=\'' . $first_name . '\'>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input_middle_name" class="col-sm-2 control-label">Отчество</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="input_middle_name" name="input_middle_name" placeholder=\'Отчество\' value=\'' . $middle_name . '\'>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input_nick_name" class="col-sm-2 control-label">Ник</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="input_nick_name" name="input_nick_name" placeholder=\'Ник\' value=\'' . $nick_name . '\'>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input_email" class="col-sm-2 control-label">email</label>
                    <div class="col-sm-6">
                        <input type="email" class="form-control" id="input_email" name="input_email" placeholder=\'email\' value=\'' . $email . '\'>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input_extras" class="col-sm-2 control-label">Доп. инфо</label>
                    <div class="col-sm-6">
                        <input type="email" class="form-control" id="input_extras" name="input_extras" placeholder=\'Доп. инфо\' value=\'' . $extras . '\'>
                    </div>
                </div>
                                
<!-- Address -->                                
                <div class="form-group">
                    <label for="input_country" class="col-sm-2 control-label">Страна</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="input_country" name="input_country" placeholder=\'Страна\' value=\'' . $country . '\'>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input_zip_code" class="col-sm-2 control-label">ZIP</label>
                    <div class="col-sm-6">
                        <input type="number" class="form-control" id="input_zip_code" name="input_zip_code" placeholder=\'ZIP\' value=\'' . $zip_code . '\'>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input_city" class="col-sm-2 control-label">Город</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="input_city" name="input_city" placeholder=\'Город\' value=\'' . $city . '\'>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input_street" class="col-sm-2 control-label">Улица</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="input_street" name="input_street" placeholder=\'Улица\' value=\'' . $street . '\'>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input_street_number" class="col-sm-2 control-label">Номер дома</label>
                    <div class="col-sm-6">
                        <input type="number" class="form-control" id="input_street_number" name="input_street_number" placeholder=\'Номер дома\' value=\'' . $street_number . '\'>
                    </div>
                </div>
                <div class="form-group">
                    <label for="input_room_number" class="col-sm-2 control-label">Квартира</label>
                    <div class="col-sm-6">
                        <input type="number" class="form-control" id="input_room_number" name="input_room_number" placeholder=\'Квартира\' value=\'' . $room_number . '\'>
                    </div>
                </div>                
                <div class="form-group">
                    <label for="input_phone" class="col-sm-2 control-label">Телефон</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="input_phone" name="input_phone" placeholder=\'Телефон\' value=\'' . $phone . '\'>
                    </div>
                </div>
                
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        ' . $buttonHTML . '
                    </div>
                </div>
            </form>';
        $script = '
                function addCustomer() {
                    var last_name = $(\'#input_last_name\').val();
                    var first_name = $(\'#input_first_name\').val();
                    var middle_name = $(\'#input_middle_name\').val();
                    var nick_name = $(\'#input_nick_name\').val();
                    var email = $(\'#input_email\').val();
                    var extras = $(\'#input_extras\').val();
                    var country = $(\'#input_country\').val();
                    var zip_code = $(\'#input_zip_code\').val();
                    var city = $(\'#input_city\').val();
                    var street = $(\'#input_street\').val();
                    var street_number = $(\'#input_street_number\').val();
                    var room_number = $(\'#input_room_number\').val();
                    var phone = $(\'#input_phone\').val();
                    ajax_request(
                        {
                            "id": \'' . $id . '\',
                            "class_name": "ajax_accounting_AjaxCustomer",
                            "action": \'' . $action . '\',
                            "last_name": last_name,
                            "first_name": first_name,
                            "middle_name": middle_name,
                            "nick_name": nick_name,
                            "email": email,
                            "extras": extras,
                            "country": country,
                            "zip_code": zip_code,
                            "city": city,
                            "street": street,
                            "street_number": street_number,
                            "room_number": room_number,
                            "phone": phone,
                                    
                        }
                    );
    
                }';
        $response[0]['id'] = 'extra_content';
        $response[0]['html'] = $string;
        $response['script'] = $script;
        return $response;
    }
Beispiel #4
0
 public function generateDealForm()
 {
     $id = 0;
     $article_id = 0;
     $customer_id = 0;
     $amount = 0;
     $total_price = 0.0;
     $platform_name = '';
     $commented = FALSE;
     $extras = '';
     $status = 1;
     $action = 'add_deal';
     // If an existing id was passed then we need to edit an object.
     if (array_key_exists('id', $this->params) === TRUE && (int) $this->params['id'] > 0) {
         $id = (int) $this->params['id'];
         $action = 'edit_deal';
     }
     if (array_key_exists('row_data', $this->params) === TRUE) {
         if (array_key_exists('customer_id', $this->params['row_data']) === TRUE) {
             $customer_id = $this->params['row_data']['customer_id'];
         }
         if (array_key_exists('article_id', $this->params['row_data']) === TRUE) {
             $article_id = $this->params['row_data']['article_id'];
         }
         if (array_key_exists('amount', $this->params['row_data']) === TRUE) {
             $amount = $this->params['row_data']['amount'];
         }
         if (array_key_exists('total_price', $this->params['row_data']) === TRUE) {
             $total_price = $this->params['row_data']['total_price'];
         }
         if (array_key_exists('platform_name', $this->params['row_data']) === TRUE) {
             $platform_name = $this->params['row_data']['platform_name'];
         }
         if (array_key_exists('commented', $this->params['row_data']) === TRUE) {
             // If there is a success word in the span .
             if (strpos($this->params['row_data']['commented'], 'success') !== FALSE) {
                 $commented = TRUE;
             } else {
                 $commented = FALSE;
             }
         }
         if (array_key_exists('extras', $this->params['row_data']) === TRUE) {
             $extras = $this->params['row_data']['extras'];
         }
         if (array_key_exists('status', $this->params['row_data']) === TRUE) {
             // If there is a success word in the span .
             if (strpos($this->params['row_data']['status'], 'success') !== FALSE) {
                 $status = 2;
             } else {
                 if (strpos($this->params['row_data']['status'], 'warning') !== FALSE) {
                     $status = 1;
                 } else {
                     $status = 0;
                 }
             }
         }
     }
     $options = array();
     $options['id'] = 'add_button';
     $options['css_class'] = 'btn btn-default btn-add';
     $options['onclick'] = 'addDeal()';
     $options['content'] = 'Сохранить';
     $button = new html_elements_Button($options);
     $buttonHTML = '';
     $buttonHTML = $button->generateButtonHTML();
     $customer = new objects_Customer();
     $customersSelectFieldArray = $customer->getSelectFieldArray();
     if ($customersSelectFieldArray['result'] === FALSE) {
         $response['messages']['danger'] = $customersSelectFieldArray['error'];
         return $response;
     }
     $selectField = new html_elements_SelectField('input_customer_id', 'input_customer_id', 'form-control', $customer_id);
     $customersHTML = $selectField->generateHTML($customersSelectFieldArray['result']);
     $article = new objects_Article();
     $articlesSelectFieldArray = $article->getSelectFieldArray();
     if ($articlesSelectFieldArray['result'] === FALSE) {
         $response['messages']['danger'] = $articlesSelectFieldArray['error'];
         return $response;
     }
     $selectField = new html_elements_SelectField('input_article_id', 'input_article_id', 'form-control', $article_id);
     $articlesHTML = $selectField->generateHTML($articlesSelectFieldArray['result']);
     $checkbox = new html_elements_Checkbox('input_commented', 'input_commented', 'form-control', $commented);
     $commentedHTML = $checkbox->generateCheckboxHTML();
     $statusSelectFieldArray = array();
     $statusSelectFieldArray[] = array('id' => '0', 'sf_option' => 'Сделка не состоялась');
     $statusSelectFieldArray[] = array('id' => '1', 'sf_option' => 'В работе');
     $statusSelectFieldArray[] = array('id' => '2', 'sf_option' => 'Прошла успешно');
     $selectField = new html_elements_SelectField('input_status', 'input_status', 'form-control', $status);
     $statusHTML = $selectField->generateHTML($statusSelectFieldArray);
     $string = '
         <form class="form-horizontal" method="post" action="ajax.php">
             <div class="form-group">
                 <label for="input_customer_id" class="col-sm-2 control-label">Покупатель</label>
                 <div class="col-sm-6">' . $customersHTML . '</div>
             </div>
             <div class="form-group">
                 <label for="input_article_id" class="col-sm-2 control-label">Товар</label>
                 <div class="col-sm-6">' . $articlesHTML . '</div>
             </div>                        
             <div class="form-group">
                 <label for="input_amount" class="col-sm-2 control-label">Количество, шт.</label>
                 <div class="col-sm-6">
                     <input type="number" class="form-control" id="input_amount" name="input_amount" placeholder="Количество, шт." value=\'' . $amount . '\'>
                 </div>
             </div>
             <div class="form-group">
                 <label for="input_total_price" class="col-sm-2 control-label">Сумма</label>
                 <div class="col-sm-6">
                     <input type="number" class="form-control" id="input_total_price" name="input_total_price" placeholder="Сумма" value=\'' . $total_price . '\'>
                 </div>
             </div>
             <div class="form-group">
                 <label for="input_platform_name" class="col-sm-2 control-label">Платформа</label>
                 <div class="col-sm-6">
                     <input type="text" class="form-control" id="input_platform_name" name="input_platform_name" placeholder="Платформа" value=\'' . $platform_name . '\'>
                 </div>
             </div>
             <div class="form-group">
                 <label for="input_commented" class="col-sm-2 control-label">Отзыв</label>
                 <div class="col-sm-6">
                     ' . $commentedHTML . '
                 </div>
             </div>
             <div class="form-group">
                 <label for="input_extras" class="col-sm-2 control-label">Доп. информация</label>
                 <div class="col-sm-6">
                     <input type="text" class="form-control" id="input_extras" name="input_extras" placeholder="Доп. информация" value=\'' . $extras . '\'>
                 </div>
             </div>
             <div class="form-group">
                 <label for="input_status" class="col-sm-2 control-label">Статус</label>
                 <div class="col-sm-6">' . $statusHTML . '</div>
             </div>
             <div class="form-group">
                 <div class="col-sm-offset-2 col-sm-10">
                     ' . $buttonHTML . '
                 </div>
             </div>
         </form>';
     $script = '
             function addDeal() {
                 var customer_id = $(\'#input_customer_id\').val();
                 var article_id = $(\'#input_article_id\').val();
                 var amount = $(\'#input_amount\').val();
                 var total_price = $(\'#input_total_price\').val();
                 var platform_name = $(\'#input_platform_name\').val();
                 
                 if ($(\'#input_commented\').is(\':checked\')) {
                     var commented = 1;
                 } else {
                     var commented = 0;
                 }
                 
                 var status = $(\'#input_status\').val();
                 var extras = $(\'#input_extras\').val();
                 ajax_request(
                     {
                         "id": \'' . $id . '\',
                         "class_name": "ajax_accounting_AjaxDeal",
                         "action": \'' . $action . '\',
                         "customer_id": customer_id,
                         "article_id": article_id,
                         "amount": amount,
                         "total_price": total_price,
                         "platform_name": platform_name,
                         "commented": commented,
                         "status": status,
                         "extras": extras
                     }
                 );
 
             }';
     $response[0]['id'] = 'extra_content';
     $response[0]['html'] = $string;
     $response['script'] = $script;
     return $response;
 }
Beispiel #5
0
 public function generateShipmentForm()
 {
     $id = 0;
     $number = 0;
     $date = '';
     $transport_charge = 0.0;
     $extras = '';
     $action = 'add_shipment';
     // If an existing id was passed then we need to edit an object.
     if (array_key_exists('id', $this->params) === TRUE && (int) $this->params['id'] > 0) {
         $id = (int) $this->params['id'];
         $action = 'edit_shipment';
     }
     if (array_key_exists('row_data', $this->params) === TRUE) {
         if (array_key_exists('date', $this->params['row_data']) === TRUE) {
             $date = $this->params['row_data']['date'];
         }
         if (array_key_exists('number', $this->params['row_data']) === TRUE) {
             $number = $this->params['row_data']['number'];
         }
         if (array_key_exists('transport_charge', $this->params['row_data']) === TRUE) {
             $transport_charge = $this->params['row_data']['transport_charge'];
         }
         if (array_key_exists('extras', $this->params['row_data']) === TRUE) {
             $extras = $this->params['row_data']['extras'];
         }
     }
     $options = array();
     $options['id'] = 'add_button';
     $options['css_class'] = 'btn btn-default btn-add';
     $options['onclick'] = 'addShipment()';
     $options['content'] = 'Сохранить';
     $button = new html_elements_Button($options);
     $buttonHTML = '';
     $buttonHTML = $button->generateButtonHTML();
     $string = '
         <form class="form-horizontal" method="post" action="ajax.php">
             <div class="form-group">
                 <label for="input_number" class="col-sm-2 control-label">Номер отправления</label>
                 <div class="col-sm-6">
                     <input type="text" class="form-control" id="input_number" name="input_number" placeholder="Номер" value=\'' . $number . '\'>
                 </div>
             </div>
             <div class="form-group">
                 <label for="input_date" class="col-sm-2 control-label">Дата</label>
                 <div class="col-sm-6">
                     <input type="text" class="form-control" id="input_date" name="input_date" placeholder="Дата" value=\'' . $date . '\'>
                 </div>
             </div>
             <div class="form-group">
                 <label for="input_transport_charge" class="col-sm-2 control-label">Транспортные расходы</label>
                 <div class="col-sm-6">
                     <input type="number" class="form-control" id="input_transport_charge" name="input_transport_charge" placeholder="Транспортные расходы" value=\'' . $transport_charge . '\'>
                 </div>
             </div>
             <div class="form-group">
                 <label for="input_extras" class="col-sm-2 control-label">Доп. инфо</label>
                 <div class="col-sm-6">
                     <input type="text" class="form-control" id="input_extras" name="input_extras" placeholder="Доп. инфо" value=\'' . $extras . '\'>
                 </div>
             </div>
             <div class="form-group">
                 <div class="col-sm-offset-2 col-sm-10">
                     ' . $buttonHTML . '
                 </div>
             </div>
         </form>';
     $script = '
             function addShipment() {
                 var date = $(\'#input_date\').val();
                 var number = $(\'#input_number\').val();
                 var transport_charge = $(\'#input_transport_charge\').val();
                 var extras = $(\'#input_extras\').val();
                 ajax_request(
                     {
                         "id": \'' . $id . '\',
                         "class_name": "ajax_accounting_AjaxShipment",
                         "action": \'' . $action . '\',
                         "date": date,
                         "number": number,
                         "transport_charge": transport_charge,
                         "extras": extras,
                     }
                 );
     
             }';
     $response[0]['id'] = 'extra_content';
     $response[0]['html'] = $string;
     $response['script'] = $script;
     return $response;
 }
Beispiel #6
0
 public function generatePaymentForm()
 {
     $id = 0;
     $date = date("d.m.Y");
     $paid_amount = '';
     $bank_name = '';
     $extras = '';
     $action = 'add_payment';
     // If an existing id was passed then we need to edit an object.
     if (array_key_exists('id', $this->params) === TRUE && (int) $this->params['id'] > 0) {
         $id = (int) $this->params['id'];
         $action = 'edit_payment';
     }
     if (array_key_exists('row_data', $this->params) === TRUE) {
         if (array_key_exists('date', $this->params['row_data']) === TRUE) {
             $date = $this->params['row_data']['date'];
         }
         if (array_key_exists('paid_amount', $this->params['row_data']) === TRUE) {
             $paid_amount = $this->params['row_data']['paid_amount'];
         }
         if (array_key_exists('bank_name', $this->params['row_data']) === TRUE) {
             $bank_name = $this->params['row_data']['bank_name'];
         }
         if (array_key_exists('extras', $this->params['row_data']) === TRUE) {
             $extras = $this->params['row_data']['extras'];
         }
     }
     $options = array();
     $options['id'] = 'add_button';
     $options['css_class'] = 'btn btn-default btn-add';
     $options['onclick'] = 'addPayment()';
     $options['content'] = 'Сохранить';
     $button = new html_elements_Button($options);
     $buttonHTML = '';
     $buttonHTML = $button->generateButtonHTML();
     $string = '
         <form class="form-horizontal" method="post" action="ajax.php">
             <div class="form-group">
                 <label for="input_date" class="col-sm-2 control-label">Дата</label>
                 <div class="col-sm-6">
                     <input type="text" class="form-control" id="input_date" name="input_date" placeholder="Дата" value=\'' . $date . '\'>
                 </div>
             </div>
             <div class="form-group">
                 <label for="input_paid_amount" class="col-sm-2 control-label">Оплаченная сумма</label>
                 <div class="col-sm-6">
                     <input type="text" class="form-control" id="input_paid_amount" name="input_paid_amount" placeholder="Оплаченная сумма" value=\'' . $paid_amount . '\'>
                 </div>
             </div>
             <div class="form-group">
                 <label for="input_bank_name" class="col-sm-2 control-label">Банк</label>
                 <div class="col-sm-6">
                     <input type="text" class="form-control" id="input_bank_name" name="input_bank_name" placeholder="Банк" value=\'' . $bank_name . '\'>
                 </div>
             </div>
             <div class="form-group">
                 <label for="input_extras" class="col-sm-2 control-label">Доп. условия</label>
                 <div class="col-sm-6">
                     <input type="text" class="form-control" id="input_extras" name="input_extras" placeholder="Доп. условия" value=\'' . $extras . '\'>
                 </div>
             </div>
             <div class="form-group">
                 <div class="col-sm-offset-2 col-sm-10">
                     ' . $buttonHTML . '
                 </div>
             </div>
         </form>';
     $script = '
             function addPayment() {
                 var date = $(\'#input_date\').val();
                 var paid_amount = $(\'#input_paid_amount\').val();
                 var bank_name = $(\'#input_bank_name\').val();
                 var extras = $(\'#input_extras\').val();
                 ajax_request(
                     {
                         "id": \'' . $id . '\',
                         "class_name": "ajax_accounting_AjaxPayment",
                         "action": \'' . $action . '\',
                         "date": date,
                         "paid_amount": paid_amount,
                         "bank_name": bank_name,
                         "extras": extras
                     }
                 );
     
             }';
     $response[0]['id'] = 'extra_content';
     $response[0]['html'] = $string;
     $response['script'] = $script;
     return $response;
 }
Beispiel #7
0
    public function generateArticleForm()
    {
        $id = 0;
        $name = '';
        $price = 0;
        $extras = '';
        $action = 'add_article';
        // If an existing id was passed then we need to edit an object.
        if (array_key_exists('id', $this->params) === TRUE && (int) $this->params['id'] > 0) {
            $id = (int) $this->params['id'];
            $action = 'edit_article';
        }
        if (array_key_exists('row_data', $this->params) === TRUE) {
            if (array_key_exists('name', $this->params['row_data']) === TRUE) {
                $name = $this->params['row_data']['name'];
            }
            if (array_key_exists('price', $this->params['row_data']) === TRUE) {
                $price = $this->params['row_data']['price'];
            }
            if (array_key_exists('extras', $this->params['row_data']) === TRUE) {
                $extras = $this->params['row_data']['extras'];
            }
        }
        $options = array();
        $options['id'] = 'add_button';
        $options['css_class'] = 'btn btn-default btn-add';
        $options['onclick'] = 'addArticle()';
        $options['content'] = 'Сохранить';
        $button = new html_elements_Button($options);
        $saveButtonHTML = '';
        $saveButtonHTML = $button->generateButtonHTML();
        $string = '
                <form class="form-horizontal" method="post" action="ajax.php" enctype="multipart/form-data">
                    <div class="form-group">
                        <label for="input_name" class="col-sm-2 control-label">Название</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="input_name" name="input_name" placeholder="Название" value=\'' . $name . '\'>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="input_price" class="col-sm-2 control-label">Себестоимость</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="input_price" name="input_price" placeholder="Себестоимость" value=\'' . $price . '\'>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="input_extras" class="col-sm-2 control-label">Доп. инфо</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="input_extras" name="input_extras" placeholder="Доп. инфо" value=\'' . $extras . '\'>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            ' . $saveButtonHTML . '
                        </div>
                    </div>
                </form>';
        $script = '
                function addArticle() {
                    var name = $(\'#input_name\').val();
                    var price = $(\'#input_price\').val();
                    var extras = $(\'#input_extras\').val();
                    ajax_request(
                        {
                            "id": \'' . $id . '\',
                            "class_name": "ajax_accounting_AjaxArticle",
                            "action": \'' . $action . '\',
                            "name": name,
                            "price": price,
                            "extras": extras
                        }
                    );
    
                }';
        $response[0]['id'] = 'extra_content';
        $response[0]['html'] = $string;
        $response['script'] = $script;
        return $response;
    }