Esempio n. 1
0
 /**
  * Define columns
  */
 protected static function _columns($page = 'index')
 {
     $columns_for = array('view' => array('mk_id' => array('label' => 'MK No.', 'grid' => array('process' => function ($data) {
         return Petro_Lookup::table('docmk', 'id', 'mk_no', $data->mk_id);
     })), 'suggest_roll', 'length', 'remark', 'user_id'));
     if ($page == 'index') {
         $columns_for['view']['_action_'] = Petro_Grid::default_actions();
         return $columns_for['view'];
     }
     return $columns_for[$page];
 }
Esempio n. 2
0
File: form.php Progetto: ratiw/petro
 public function add_field($name, $label = '', $value = '', $form = array(), $rules = array())
 {
     // get options' values from language file, if available
     if (isset($form['options'])) {
         foreach ($form['options'] as $key => $val) {
             $form['options'][$key] = \Lang::get($val) ?: $val;
         }
     }
     // lookup attribute
     if (isset($form['type']) and $form['type'] == 'select' and isset($form['lookup'])) {
         $source = $form['lookup'];
         if (is_array($source)) {
             $form['options'] = Petro_Lookup::table($source['table'], $source['key'], $source['value']);
         } else {
             $form['options'] = Petro_Lookup::get($source);
         }
     }
     // editable attribute
     if (!isset($form['editable'])) {
         $form['editable'] = true;
     }
     if (empty($label)) {
         $label = \Lang::get($name) ?: \Inflector::humanize($name);
     }
     $this->fields[$name] = array('name' => $name, 'label' => $label, 'value' => $value, 'form' => $form, 'rules' => $rules);
 }
Esempio n. 3
0
						<div class="controls">
							<?php 
echo Form::input('mk_no', Input::post('mk_no', isset($docmk) ? $docmk->mk_no : $docinfo['next']), $attr);
?>
							<?php 
if ($this_method == 'create') {
    ?>
								<button class="btn" id="btn_next_docno" name="get_next_docno"><i class="icon-refresh"></i></button>
							<?php 
}
?>
						</div>
					</div>
					<?php 
echo Petro_Form::input('mk_date', Input::post('mk_date', isset($docmk) ? Petro::to_app_date($docmk->mk_date) : ''), array('id' => 'form1_mk_date', 'placeholder' => 'dd/mm/yy', 'class' => 'datepicker'), __('mk_date'), $errors);
$client = Petro_Lookup::table('clients', 'id', 'name');
echo Petro_Form::select('client_id', Input::post('client_id', isset($docmk) ? $docmk->client_id : ''), array_merge(array('0' => '-- เลือก --'), $client), array('id' => 'form1_client_id'), __('client_id'), $errors);
echo Petro_Form::input('client_po', Input::post('client_po', isset($docmk) ? $docmk->client_po : ''), array('id' => 'form1_client_po'), __('client_po'), $errors);
?>
				</div>
				<div class="span6">
					<h3><?php 
echo __('delivery_head');
?>
</h3>
					<?php 
echo Petro_Form::input('delivery_date', Input::post('delivery_date', isset($docmk) ? Petro::to_app_date($docmk->delivery_date) : ''), array('id' => 'form1_delivery_date', 'placeholder' => 'dd/mm/yy', 'class' => 'datepicker '), __('delivery_date'), $errors);
echo Petro_Form::textarea('deliver_to', Input::post('deliver_to', isset($docmk) ? $docmk->deliver_to : ''), array('id' => 'form1_deliver_to', 'style' => 'width:90%'), __('deliver_to'), $errors);
?>
				</div>
			</div><!--/row-->
Esempio n. 4
0
<?php

$this_controller = Str::lower(Uri::segment(1));
$this_method = Str::lower(Uri::segment(2));
isset($edit_mode) or $edit_mode = false;
isset($errors) or $errors = array();
echo Form::open(array('class' => 'form-horizontal'));
?>
	<div class="row-fluid">
		<div class="well span8">
			<?php 
echo Petro_Form::input('first_name', Input::post('first_name', isset($user) ? $user->profile_fields['first_name'] : ''), array(), 'First Name', $errors);
echo Petro_Form::input('last_name', Input::post('last_name', isset($user) ? $user->profile_fields['last_name'] : ''), array(), 'Last Name', $errors);
echo Petro_Form::input('email', Input::post('email', isset($user) ? $user->email : ''), array(), 'Email', $errors);
echo '<hr/>';
echo Petro_Form::input('username', Input::post('username', isset($user) ? $user->username : ''), $edit_mode ? array('readonly' => 'readonly') : array(), 'Username', $errors);
if (!$edit_mode) {
    echo Petro_Form::password('password', Input::post('password', ''), array(), 'Password', $errors);
    echo Petro_Form::password('password2', Input::post('password2', ''), array(), 'Confirm Password', $errors);
}
echo '<hr/>';
$groups = Petro_Lookup::table('groups', 'level', 'name');
echo Petro_Form::select('group', Input::post('group', isset($user) ? $user->group : '1'), $groups, array(), 'Group', $errors);
echo Petro_Form::render_buttons(array(\Form::submit('submit', 'Submit', array('class' => 'btn btn-primary')), \Html::anchor('users', 'Cancel', array('class' => 'btn'))));
?>
		</div>
	</div><!--/row-->

<?php 
echo Form::close();
Esempio n. 5
0
 /**
  * Index
  */
 public function action_index($curr_page = 1, $order_by = null, $scope = null, $filter = null)
 {
     $data['filters'] = Input::param('q');
     $grid = new Petro_Grid('Model_DocMK', static::_columns('index'));
     $this->setup_scope($grid);
     $grid->add_summary('belt_price_net', 'sum');
     $grid->add_summary('belt_amount', 'sum');
     $data['index_content'] = $grid->render();
     //$curr_page, $order_by, $scope, $data['filters']);
     $this->sidebars->add('Filters', Petro::render_group_filters(array(array("By Document info", array('mk_date' => array('type' => 'date_range'), 'mk_no' => array('type' => 'string'), 'client_id' => array('label' => 'Customer', 'type' => 'select', 'collection' => Petro_Lookup::table('clients', 'id', 'name')), 'status' => array('type' => 'select', 'collection' => Petro_Lookup::get('prd.status')))), array("By Belt info", array('belt_type' => array('type' => 'select', 'collection' => Petro_Lookup::get('belt.type')), 'belt_width' => array('type' => 'numeric'), 'belt_grade' => array('type' => 'select', 'collection' => Petro_Lookup::get('belt.grade')), 'belt_color' => array('type' => 'select', 'collection' => Petro_Lookup::get('belt.color')), 'belt_thick' => array('label' => 'Thickness', 'type' => 'numeric'), 'belt_length' => array('label' => 'Length', 'type' => 'numeric'), 'belt_end' => array('label' => 'End Type', 'type' => 'select', 'collection' => Petro_Lookup::get('belt.end')))))));
     $this->action_items = array(array('title' => 'Add New Docmk', 'link' => Petro::get_routes('new')));
     // set this to override default page_title
     $this->template->page_title = "MK Index";
     $this->template->content = View::forge('docmk2/index', $data, false);
 }