Hi,
First of all let me congratulate John Skoumbourdis for the excellent tool he created, as well to @Amit Shah and @davidoster for the support given to newbies in this forum.
I just started using GC and indeed it's a huge step forward in comparison to my excel sheets.
I kindly ask the community for support to help me solve this issue. I really want to get this app started, in order to test it and request professional development to management.
Here it goes:
When I add a new order, the form records the 'customer_id' in the `table_orders`. What I need to retrieve is the 'customer_priority' from the `table_customers` (1 to 50 depending on the customer) and show it in the orders Crud.
That value is going to be the one to set the "order by" to print our daily job list and bring some organization to our department.
What's the best way to do that? I've searched through forums and documentation, tried callbacks and custom models, but so far I haven't figured it out yet.
Bellow is my code and screenshots:
[attachment=1309:LIST_AMOSTRAS.png] - Orders Crud
[attachment=1310:VIEW_AMOSTRA.png] - Order View
[attachment=1311:LIST_CLIENTES.png] - Customers Crud
[attachment=1312:php_TBL_AMOSTRAS.png] - Orders Table
[attachment=1313:php_TBL_CLIENTES.png] - Customers Table
public function amostras_gestao_hoje(){ // SHOW TODAY'S ORDERS //@TODO - RETRIEVE CUSTOMER PRIORITY FROM TBL_CUSTOMERS $crud = new grocery_CRUD(); $crud->set_theme('flexigrid'); //https://stackoverflow.com/questions/31047890/select-query-with-date-of-today-not-working $date = new DateTime("now"); $curr_date = $date->format('Y-m-d '); $crud->where('DATE(data_prevista)',$curr_date);//use date function $crud->set_table('amostras'); $crud->set_subject('Amostra'); $crud->unset_columns('quantidade','observacoes','data_enviada','tracking_no'); $crud->required_fields('designer','cliente','referencia','quantidade','tipo_amostra'); $crud->set_field_upload('foto','assets/uploads/amostras'); //$crud->set_relation('campodepesquisa','tabeladepesquisa','colunaaretornar'); $crud->set_relation('designer','utilizadores','nome_completo'); $crud->set_relation('cliente','clientes','cliente_nome'); $crud->set_relation('tipo_amostra','amostras_tipos','amostra_tipo'); $crud->set_relation('destino','amostras_destinos','amostra_destino'); $crud->unset_delete(); $output = $crud->render(); $this->_example_output($output); }
Regards,
tiagorookie