Jump to content


ezgoen

Member Since 21 Mar 2013
Offline Last Active May 20 2013 08:17 AM
-----

Topics I've Started

to set_relation_n_n or not?

20 May 2013 - 01:23 AM

Hi Folks,

 

I'm in a dilemma - which way to go

 

The scenario

 

Table Items

 

Table Sales

 

I want to be able to bulk add items to a sale

with a relation table items-sales I can do this BUT and this is a BIG BUT!!

 

I DONT want to be able to select items that are already assigned to another sale

with set_relation_n_n.

 

Sooooo 

 

I could set some constraints - and disallow  adding the sale item twice

but thats still confusing to the user - they would wonder why cant they add an item they select.

un selectable items should not be visible at all.

 

So I can use the mutiselct field and populate the array in a callback - but thats not the interface

users want - they want to be able to bulk-select items not add one at a time.

 

I guess I'm hinting at using functionality like that in get_relation_n_n_input

 

 

 

any suggestions??

 

 

cheers

 

Ez


Active / Inactive bit field on add

23 April 2013 - 07:44 AM

Ho folks,

 

I hope this hasn't been asked and answered - i've searched and found no solution.

 

I didn't spot this until after deployment.

 

Scenario

Table has a bit field that is rendered as active /inactive

This field is set up as mandatory

 

on Add New record it default to active just fine - this is what I want and what is expected.

if - instead of "save and go back to list" i click 'Save', I am presented with a new record - as expected.

The default for the bit field is active - as expected.

When I click "save" on this I get error - the active field is mandatory.

I don't understand why nor can I track down why in the code.

I suspect jQuery is the culprit here but I haven't had time to track it down.

 

Has anyone else encountered this problem - if so - whats the fix??

 

I appreciate any help with this..

 

Cheers

 

Ez

 


datebase column Comments as hints

18 April 2013 - 03:36 AM

This one was real easy folks - so I'll pass it on

 

Maybe someone will attach some JS or jQuery so they pop up or something??

 

anyhow this is how I did it, it was sooooo easy.

 

 

Create a custom GC MODEL

 

copy the code for

 

       get_field_types_basic_table()

 

code from grocery_crud_model into it 

 

then make the following changes

 

function get_field_types_basic_table()
    {
    	$db_field_types = array();
        //change this..
    	//foreach($this->db->query("SHOW COLUMNS FROM `{$this->table_name}`")->result() as $db_field_type)
        //to this
        foreach($this->db->query("SHOW FULL COLUMNS FROM `{$this->table_name}`")->result() as $db_field_type)
and 
 
$db_field_types[$db_field_type->Field]['db_max_length'] = $length;
$db_field_types[$db_field_type->Field]['db_type'] = $db_type;
$db_field_types[$db_field_type->Field]['db_null'] = $db_field_type->Null == 'YES' ? true : false;
$db_field_types[$db_field_type->Field]['db_extra'] = $db_field_type->Extra;
 

 

add the following line
 

 

$db_field_types[$db_field_type->Field]['db_comment'] = $db_field_type->Comment;
 

 

 

Thats it - now just change your theme files edit.php and add.php

 

here's my change to /assets/grocerycrud/flexigrid/views/edit.php

 

 

            <div class='form-field-box <?php echo $even_odd?>' id="<?php echo $field->field_name; ?>_field_box">
                <div class='form-display-as-box' id="<?php echo $field->field_name; ?>_display_as_box">
                    <?php echo $input_fields[$field->field_name]->display_as?><?php echo ($input_fields[$field->field_name]->required)? "<span class='required'>*</span> " : ""?> :
                </div>
                <div class='form-input-box' id="<?php echo $field->field_name; ?>_input_box">
                    <?php echo $input_fields[$field->field_name]->input?>
<?php // **********My Changes**************************************************************************** ?>
                    <div class='form_hint_box' id="<?php echo $field->field_name; ?>_hint_box">
                        <?php echo $input_fields[$field->field_name]->db_comment?>
                    </div>
<?php // ************************************************************************************** ?>


                </div>
                <div class='clear'></div>    
            </div>

 

I also added the following to flexigrid.css

 

 

.form_hint_box
{
    padding: 5px 5px;
    margin: 0px 0px 0px 0px;    
    font-size:7px;
}
 

 

Thats it - no go back and put nice comments into your mysql column definitions 

and you'll have them show up on the add & edit forms.

I'm sure the idea could be easily incorperated into core gc at which time I'm sure someone will come up with a language file mechanism for it too .

 

Cheers

 

 

Enjoy

 

PS - sometimes code tags here in the forum throw some of the code outside them - dunno why??


Superfish Menu CI plugin

15 April 2013 - 06:42 AM

 

Hi Folks,

 

There is a new version - now with a breadcrumb trail!

 

I've create a new post and attached the new file.

Full documentation is inside the archive! 

 

Please note, I've UPDATED the code and commented on it here.

 


While not strictly grocerycrud  I'm sharing here in an effort to give back a little.


 


I needed a simple menu system and I've used the Superfish jquery library before.


I did merge it into the fuelcms menu but I wasnt happy with it.


 


This is simpler to use and really easy to get a good looking menu out of a few lines of code.

 

here's all you have to do to use the library (after you've installed as per the included instructions)

 


 

$this->load->library('superfish',
                            array('container_tag_id'=>'admin_menu', 
                                  'container_tag_id'=>'nav',
                                  'container_tag_class'=>'sf-menu',
                                  'background_color'=>'FFD833',
                                  'highlight_color'=>'FAC101',
                                  'text_color'=>'670001'));    

//make a shortcut to superfish 
$SuperFish=$this->superfish;  //the same name as the load->library statement

$SuperFish->set_menu_item('home','Home',$active_item);
$SuperFish->set_menu_item('admin/usr_accounts','Administrative Tasks/Manage User Accounts',$active_item);
$SuperFish->set_menu_item('admin/site_man','Administrative Tasks/Perform Site Management Tasks',$active_item);

$menu=$SuperFish->render();


 

 


Note the change in my example - I made a small mistake  that Elgger picked up.  Thanks Elgger



 


the following is only necessary if you want to merge css and js with grocery crud


 

 


        //merge our includes 

        $arr=$menu->includes->css_files;

        foreach ($arr as $key => $value){

            $css_files[$key]=$value;

        }

        $arr=$menu->includes->js_files;

        foreach ($arr as $key => $value){

            $js_files[$key]=$value;

        }





        $output->inline.=$menu->includes->inline;

        $output->js_files=$js_files;

        $output->css_files=$css_files;

        

        $output->menu=$menu->output;
 

 

 



I've updated the code. (The attached file has been modified to include the change)


 


To do a vanilla render :


 

 

$menu=$this->superfish->render(); //or if you made a shortcut like above
//$menu=SuperFish->render();
 

 

 

 


To render AND merge with crud output


 


 

$output=$this->menu->renderToCrud($output);//or if you made a shortcut like above
//$output=$SuperFish->renderToCrud($output)
 

 



 


and in your template , if you've done the above merge :


 


 

<?php print $menu; ?>
 
 

 

 


Feedback is welcome but so is maintenance - if its broke feel free to fix it


if you need help just ask


 


Hope its useful to someone


 


Cheers


 


Ez


BUG $crud->set_subject("Image for {$Type} Item : '...

11 April 2013 - 12:44 AM

 

Hi folks,

 

Sorry Boss - I found a little one - urgency very low but ...

 

its a bug

 

a line like this :

 

     

 

$crud->set_subject("Image for {$Type} Item : '{$CatName}'");
 

 

 

will break the jquery

 

when you set the javascript vars the embedded quote breaks stuff.

not a big problem but its there.

 

Have to mod the line like this :

 

    

 

 $crud->set_subject("Image for {$Type} Item : {$CatName}");
 

 

 

Cheers

 

Ez