function get_form_html($form_id, $id) { ob_start(); ?> <div id="head_div" style="height: 150px; width: 320px; background-color: #ECECEC; border-radius: 5px;margin-left: auto;display: none; "> </div> <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <style> div#purchace_items td{ border: 1px solid #21ACD7; } div#purchace_items tbody td{ padding: 5px 0 5px 5px; } div#purchace_items tbody td input,div#purchace_items tbody td select{ padding: 0; border: 0; margin: 0; height: 100%; width: 100%; background-color: transparent; } </style> <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> <table id="items_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7;"> <thead style="text-align: center;"> <tr status="not_selected"> <td> # </td> <td> ID </td> <td> SHOP NAME </td> <td style=""> SHOP CODE </td> </tr> </thead> <tbody style="padding-left: 3px; text-align: center; "> <?php $company = new company(); $companies = $company->getCompanies(); $i = 0; if ($companies == NULL || sizeof($companies) == 0) { echo '<tr><td colspan="8"> No Shop Found </td></tr>'; } else { foreach ($companies as $company) { ?> <tr id="<?php echo $company->id; ?> " onclick="select_row(this)"> <td style="text-align: center;"><?php echo ++$i; ?> </td> <td id="company_id"><?php echo 'SHOP-' . $company->id; ?> </td> <td id="company_name"><?php echo $company->company_name; ?> </td> <td id="company_code"><?php echo $company->company_code; ?> </td> </tr> <?php } } ?> </tbody> </table> </div> </div> <script type="text/javascript"> function select_row(row) { var j_row = $(row); if(j_row.attr('status') == 'selected'){ $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); $('img#edit').css('display', 'none'); $('img#edit_fade').css('display', 'block'); $('img#delete').css('display', 'none'); $('img#delete_fade').css('display', 'block'); }else{ $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); j_row.attr('status', 'selected'); j_row.css('background-color', '#C0EFFD'); $('img#edit').css('display', 'block'); $('img#edit_fade').css('display', 'none'); $('img#delete').css('display', 'block'); $('img#delete_fade').css('display', 'none'); } } function on_edit_clicked(){ var selected_row = $('tr[status="selected"]'); var id = selected_row.attr('id'); get_form(27, ///shop create form function (html, tools){ $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); var form = $('div#form-body').find('form.action_form'); form.attr('operation', 'update'); form.attr('company_id', id); form.find('input[type=submit]').val('UPDATE'); $('div#head_div').html('ID : SHOP - '+id); $('div#head_div').css('display', 'block'); }, function (message){ $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); }, id ); } function on_add_clicked(){ get_form(27, ///shop create form function (html, tools){ $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function (message){ $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); } ); } function on_delete_clicked(){ var selected_row = $('tr[status="selected"]'); var id = selected_row.attr('id'); if(confirm('Are you sure you want to delete SHOP-'+id+' ?' )){ var data = { form_id : 26, company_id : id } delete_form_data(data, function(message) { get_form(26, function(html, tools) { $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function(message) { $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); }); alert(message); }, function(message) { alert(message); }); } } </script> <?php $form = ob_get_clean(); return $form; }
function get_form_html($form_id, $id) { ob_start(); ?> <style> .field_name{ width: 20%; } .field input{ width: 100%; margin-left: 0px; } .field .parent{ padding: 0px 0px; } .field select{ width: 100%; } </style> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto;display: none; text-align: center; "> </div> <?php $user = new user(); if ($id != 0) { $user->id = $id; $user->getUser(); } ?> <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <form action="#" method="post" class="action_form" operation="add" style="width:100%;" > <table style="width:100%;"> <tr> <td class="field_name"> <font>NAME</font> </td> <td class="field"> <div class="parent"> <input value="<?php echo $user->name; ?> " type="text" id="name" required /> </div> </td> </tr> <tr> <td class="field_name"> <font>SHOP</font> </td> <td class="field"> <div class="parent"> <select id="shop" required <?php if ($id != 0) { echo 'disabled = "disabled"'; } ?> > <option value=""></option> <?php $company = new company(); $companies = $company->getCompanies(); if (is_array($companies) and count($companies) != 0) { foreach ($companies as $company) { echo '<option'; if ($user->company_id === $company->id) { echo ' selected '; } echo ' value="' . $company->id . '"'; echo ' >'; echo $company->company_name . ' - ' . $company->company_code; echo '</option>'; } } //print_r($companies); ?> </select> </div> </td> </tr> <tr> <td class="field_name"> <font>TYPE</font> </td> <td class="field"> <div class="parent"> <select id="type" required ="" <?php if ($id != 0) { echo 'disabled = "disabled"'; } ?> > <option value=""></option> <?php $user_type = new user_type(); $user_types = $user_type->getUserTypes(); if (is_array($user_types) and count($user_types) != 0) { foreach ($user_types as $user_type) { echo '<option'; if ($user->user_type_id === $user_type->id) { echo ' selected '; } echo ' value="' . $user_type->id . '"'; echo ' >'; echo $user_type->user_type_name; echo '</option>'; } } //print_r($companies); ?> </select> </div> </td> </tr> <tr> <td class="field_name"> <font>USER NAME</font> </td> <td class="field"> <div class="parent"> <input value="<?php echo $user->user_name; ?> " type="text" id="username" required /> </div> </td> </tr> <tr> <td class="field_name"> <font>PASSWORD</font> </td> <td class="field"> <div class="parent"> <input type="password" value="" autocomplete="off" id="paswd" <?php if ($id == 0) { echo 'required'; } ?> /> </div> </td> </tr> <tr> <td class="field_name"> <font>RE-ENTER PASSWORD</font> </td> <td class="field"> <div class="parent"> <input type="password" value="" autocomplete="off" id="re_password" <?php if ($id == 0) { echo 'required'; } ?> /> </div> </td> </tr> <tr></tr> <tr> <td></td> <td> <div style="padding: 0px 12px;"> <div style="width: 100%; margin-left: -12px; padding: 12px; background-color: #0d92bb; border-radius: 5px; float: left;"> <div style="width: 50%; float: right; "> <input style="width: 100%;" type="submit" value="ADD" /> </div> <div style="width: 50%;"> <input style="width: 100%;" type="reset" value="CANCEL" /> </div> </div> </div> </td> </tr> </table> </form> </div> <script type="text/javascript"> function setFormActionListener(){ $('form.action_form').on('submit', function(e) { e.preventDefault(); var id = 29; var operation = $(this).attr('operation'); if (operation == 'add') { var paswd = $('form input#paswd').val(); var re_password = $('form input#re_password').val(); if(paswd != re_password){ alert('Both passwords are not matching !'); $('form input#paswd').val(''); $('form input#re_password').val(''); $('form input#paswd').focus(); return; } var data = { form_id: id, name: $('form input#name').val(), username: $('form input#username').val(), shop: $('form select#shop').val(), type: $('form select#type').val(), password: paswd } add_form_data(data, function(message) { load_users_list(); alert(message); }, function(message) { alert(message); }); } else if (operation == 'update') { var user_id = $('form.action_form').attr('user_id'); var paswd = $('form input#paswd').val(); if(paswd !== ''){ var re_password = $('form input#re_password').val(); if(paswd != re_password){ alert('Both passwords are not matching !'); $('form input#paswd').val(''); $('form input#re_password').val(''); $('form input#paswd').focus(); return; } } var data = { form_id: id, user_id: user_id, name: $('form input#name').val(), username: $('form input#username').val(), password: paswd } update_form_data(data, function(message) { load_users_list(); alert(message); }, function(message) { alert(message); }); } else { alert("Invalid Operation " + id + ' - ' + operation); } }); }; setFormActionListener(); </script> <?php $form = ob_get_clean(); return $form; }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $dataView = array(); $dataView['page_title'] = "Editar un Evento"; $dataView['event'] = Event::find($id); $dataView['venues'] = venue::getVenues(); $dataView['companies'] = company::getCompanies(); $dataView['categories'] = category::all(); // make a array of categories related to this event. $categories_inEvent = array(); foreach (Category_to_Event::getAllRelByEventID($id) as $rel) { $categories_inEvent[] = $rel->category_id; } $dataView['categories_inEvent'] = $categories_inEvent; return view('event.edit', $dataView); }
function get_form_html($form_id, $date) { ob_start(); ?> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto; text-align: center; "> DAY END REPORT OF <input id="date_field" value="<?php if ($date == 0) { $date = date('d/m/Y', time()); } echo $date; ?> " /> </div> <div id="sales_items_table" style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <style> div#purchace_items td{ border: 1px solid #21ACD7; } div#purchace_items tbody td{ padding: 5px 0 5px 5px; } div#purchace_items tbody td input,div#purchace_items tbody td select{ padding: 0; border: 0; margin: 0; height: 100%; width: 100%; background-color: transparent; } </style> <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> <table id="sales_items_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7;"> <thead style="text-align: center;"> <tr> <td style="width: 5%;"> # </td> <td> SHOP </td> <td style="width: 25%;"> INCOME (SALES) </td> <td style="width: 25%;"> EXPENSE (PURCHASE) </td> </tr> </thead> <tbody style="padding-left: 3px; text-align: center; "> <?php $total_income = 0; $total_expense = 0; // $sale_item = new sales_items(); // $user = new user(); // $user->id = $_SESSION['user_id']; // $user->getUser(); $date = str_replace('/', '-', $date); $date = date('Y-m-d', strtotime($date)); $shop = new company(); $shops = $shop->getCompanies(); $i = 0; if (is_array($shops) and count($shops)) { foreach ($shops as $shop) { $sale = new sales(); $sale_income_for_this_shop = $sale->getOneDaySaleIncome($shop->id, $date); $total_income += $sale_income_for_this_shop['amount']; $purchace = new purchaces(); $purchace_expence_for_this_shop = $purchace->getOneDayPurchaseExpence($shop->id, $date); $total_expense += $purchace_expence_for_this_shop['amount']; ?> <tr> <td style="text-align: center;"> <?php echo ++$i; ?> </td> <td style="text-align: left;"> <?php echo $shop->company_name . ' - ' . $shop->company_code; ?> </td> <td> <?php echo number_format($sale_income_for_this_shop['amount'], 2, '.', ''); ?> </td> <td id="tax"> <?php echo number_format($purchace_expence_for_this_shop['amount'], 2, '.', ''); ?> </td> </tr> <?php } } else { echo '<tr><td colspan="8"> No Shop Found </td></tr>'; } ?> <tr> <td></td> <td style="text-align: right;"> TOTAL </td> <td><?php echo number_format($total_income, 2, '.', ''); ?> </td> <td><?php echo number_format($total_expense, 2, '.', ''); ?> </td> </tr> </tbody> </table> </div> </div> <script type="text/javascript"> function load_day_end_report() { var date = $('input#date_field').val(); get_form(40, function(html, tools) { $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function(message) { $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); }, date); } function on_print_clicked() { var date = $('input#date_field').val(); var header = '<font style="color:#21ACD7; font-size:20px; ">Nutiez</font>' +'<br/><br/>' +'<font style="color:#21ACD7; font-size:20px; ">BALANCE SHEET OF ' + date + '</font>'; $('div#print_container_header') .html(header); var html = $('div#sales_items_table').html(); $('div#print_container_body').html(html); print(); $('div#print_container_header').empty(); $('div#print_container_body').empty(); $('div#print_container_footer').empty(); } function setup_datepicker() { $('input#date_field').datepick({ minDate: '26/04/2015', dateFormat: 'dd/mm/yyyy', maxDate: '0', onSelect: function() { load_day_end_report(); } }); } setup_datepicker(); </script> <?php $form = ob_get_clean(); return $form; }