Change Input Type of Field Customer - Creating Invoice

status:resolved
Tags: #<Tag:0x00007ff4a7119650>

#1

When creating invoices I had problems with the field customer name. The name proposal does not always appear. So I changed the type of the field to the same as in Settings->Standard Country and it works great.

Since I have no experience with community projects, I post the code this way:

modal_create_invoice.php

<script type="text/javascript">
    $().ready(function () {
        $("[name='client_name']").select2({allowClear: true});
        $("#client_name").focus();
    });
</script>

    <div class="form-group">

    <label for="client_name"><?php echo lang('client'); ?></label>
        <select name="client_name" id="client_name" class="input-sm form-control" autofocus>
            <option></option>
            <?php foreach ($clients as $client) { ?>
                <option value="<?php echo $client->client_name; ?>"
                    <?php if ($client_name == $client->client_name) { ?>selected="selected"<?php } ?>
                > <?php echo $client->client_name; ?>     </option>

            <?php } ?>
        </select>
    </div>

invoices/controllers/ajax.php - public function modal_create_invoice()

 $this->load->model('clients/mdl_clients');   

    $data = array(
        'invoice_groups' => $this->mdl_invoice_groups->get()->result(),
        'tax_rates' => $this->mdl_tax_rates->get()->result(),
        'client_name' => $this->input->post('client_name')   ,
        'clients' => $this->mdl_clients->get()->result(),   //<--- add this line
    );

Martin


#2

[size=10]Last Update: 06.05.2015 (fixed)[/size]


#3

Thanks for the contribution, works way better than with the old ajax loading! :+1:


closed #4

This topic was automatically closed after 24 hours. New replies are no longer allowed.