<inserisci-ordine>
    <section class="content">
        <div class="row">
            <div class="col-md-6">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">Cliente</h3>
                    </div>
                    <form role="form" class="form-horizontal form_user">
                        <div class="box-body">
                            <div if="{ ordine && ordine.get('utente') && ordine.get('utente').get('tipo_utente') == 'privato' }" class="form-group">
                                <label for="nome" class="col-sm-2 control-label">Nome</label>
                                <div class="col-sm-10">
                                    <input class="form-control " type="text" placeholder="Nome" name="nome" disabled value="{ ordine.get('utente').get('nome') }">
                                </div>
                            </div>
                            <div if="{ ordine && ordine.get('utente') && ordine.get('utente').get('tipo_utente') == 'privato' }" class="form-group">
                                <label for="cognome" class="col-sm-2 control-label">Cognome</label>
                                <div class="col-sm-10">
                                    <input class="form-control " type="text" placeholder="Cognome" name="cognome" disabled value="{ ordine.get('utente').get('cognome') }">
                                </div>
                            </div>
                            <div if="{ ordine && ordine.get('utente') && ordine.get('utente').get('tipo_utente') == 'azienda' }" class="form-group">
                                <label for="ragionesociale" class="col-sm-2 control-label">Ragione sociale</label>
                                <div class="col-sm-10">
                                    <input class="form-control " type="text" placeholder="Ragione sociale" name="ragionesociale" disabled value="{ ordine.get('utente').get('ragionesociale') }">
                                </div>
                            </div>
                            <div if="{ ordine && ordine.get('utente') && ordine.get('utente').get('tipo_utente') == 'azienda' }" class="form-group">
                                <label for="piva" class="col-sm-2 control-label">P. IVA</label>
                                <div class="col-sm-10">
                                    <input class="form-control " type="text" placeholder="P. IVA" name="piva" disabled value="{ ordine.get('utente').get('piva') }">
                                </div>
                            </div>
                            <div if="{ ordine && ordine.get('utente') && ordine.get('utente').get('tipo_utente') == 'azienda' && ordine.get('utente').get('stato') == 'Italy' }" class="form-group">
                                <label for="sdi" class="col-sm-2 control-label">Codice SDI</label>
                                <div class="col-sm-10">
                                    <input class="form-control " type="text" placeholder="Codice SDI" name="sdi" disabled value="{ ordine.get('utente').get('sdi') }">
                                </div>
                            </div>
                            <div if="{ ordine && ordine.get('utente') && ordine.get('utente').get('tipo_utente') == 'azienda' && ordine.get('utente').get('stato') == 'Italy' }" class="form-group">
                                <label for="pec" class="col-sm-2 control-label">PEC</label>
                                <div class="col-sm-10">
                                    <input class="form-control " type="email" placeholder="PEC" name="pec" disabled value="{ ordine.get('utente').get('pec') }">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="rivenditore" class="col-sm-2 control-label">Rivenditore</label>
                                <div class="col-sm-10">
                                    <div class="form-control" if="{ (ordine && ordine.get('utente') && ordine.get('utente').get('isRivenditore')) }">Il cliente &egrave; <strong>rivenditore</strong></div>
                                    <div class="form-control" if="{ !(ordine && ordine.get('utente') && ordine.get('utente').get('isRivenditore')) }">Il cliente <strong>NON</strong> &egrave; rivenditore</div>
                                </div>
                            </div>
                        </div>
                    </form>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <button type="button" class="btn btn-default btn-flat pull-right" disabled="{ !ordine }" onclick="{
                                    gocliente
                                }"><i class="fas fa-external-link-alt"></i> Vai al cliente</button>
                    </div>
                </div>
                <!-- /.box -->
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">Spedizione</h3>
                    </div>
                    <form role="form" class="form-horizontal form_order">
                        <div class="box-body">
                            <div class="form-group">
                                <label for="co" class="col-sm-2 control-label">Presso</label>
                                <div class="col-sm-10">
                                    <input class="form-control " type="text" placeholder="Presso" name="co" required value="{ ordine ? ordine.get('co') : '' }">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="stato" class="col-sm-2 control-label">Stato</label>
                                <div class="col-sm-10">
                                    <select class="form-control" name="stato">
                                        <option value='Afghanistan' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Afghanistan' }">Afghanistan</option>
                                        <option value='Albania' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Albania' }">Albania</option>
                                        <option value='Algeria' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Algeria' }">Algeria</option>
                                        <option value='Andorra' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Andorra' }">Andorra</option>
                                        <option value='Angola' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Angola' }">Angola</option>
                                        <option value='Antigua and Barbuda' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Antigua and Barbuda' }">Antigua and Barbuda</option>
                                        <option value='Argentina' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Argentina' }">Argentina</option>
                                        <option value='Armenia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Armenia' }">Armenia</option>
                                        <option value='Australia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Australia' }">Australia</option>
                                        <option value='Austria' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Austria' }">Austria</option>
                                        <option value='Azerbaijan' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Azerbaijan' }">Azerbaijan</option>
                                        <option value='Bahamas' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Bahamas' }">Bahamas</option>
                                        <option value='Bahrain' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Bahrain' }">Bahrain</option>
                                        <option value='Bangladesh' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Bangladesh' }">Bangladesh</option>
                                        <option value='Barbados' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Barbados' }">Barbados</option>
                                        <option value='Belarus' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Belarus' }">Belarus</option>
                                        <option value='Belgium' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Belgium' }">Belgium</option>
                                        <option value='Belize' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Belize' }">Belize</option>
                                        <option value='Benin' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Benin' }">Benin</option>
                                        <option value='Bhutan' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Bhutan' }">Bhutan</option>
                                        <option value='Bolivia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Bolivia' }">Bolivia</option>
                                        <option value='Bosnia and Herzegovina' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Bosnia and Herzegovina' }">Bosnia and Herzegovina</option>
                                        <option value='Botswana' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Botswana' }">Botswana</option>
                                        <option value='Brazil' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Brazil' }">Brazil</option>
                                        <option value='Brunei ' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Brunei' }">Brunei </option>
                                        <option value='Bulgaria' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Bulgaria' }">Bulgaria</option>
                                        <option value='Burkina Faso' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Burkina Faso' }">Burkina Faso</option>
                                        <option value='Burundi' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Burundi' }">Burundi</option>
                                        <option value='Cote d Ivoire' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Cote d Ivoire' }">C&ocirc;te d'Ivoire</option>
                                        <option value='Cabo Verde' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Cabo Verde' }">Cabo Verde</option>
                                        <option value='Cambodia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Cambodia' }">Cambodia</option>
                                        <option value='Cameroon' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Cameroon' }">Cameroon</option>
                                        <option value='Canada' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Canada' }">Canada</option>
                                        <option value='Central African Republic' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Central African Republic' }">Central African Republic</option>
                                        <option value='Chad' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Chad' }">Chad</option>
                                        <option value='Chile' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Chile' }">Chile</option>
                                        <option value='China' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'China' }">China</option>
                                        <option value='Colombia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Colombia' }">Colombia</option>
                                        <option value='Comoros' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Comoros' }">Comoros</option>
                                        <option value='Congo (Congo-Brazzaville)' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Congo (Congo-Brazzaville)' }">Congo (Congo-Brazzaville)</option>
                                        <option value='Costa Rica' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Costa Rica' }">Costa Rica</option>
                                        <option value='Croatia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Croatia' }">Croatia</option>
                                        <option value='Cuba' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Cuba' }">Cuba</option>
                                        <option value='Cyprus' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Cyprus' }">Cyprus</option>
                                        <option value='Czech Republic' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Czech Republic' }">Czech Republic</option>
                                        <option value='Democratic Republic of the Congo' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Democratic Republic of the Congo' }">Democratic Republic of the Congo</option>
                                        <option value='Denmark' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Denmark' }">Denmark</option>
                                        <option value='Djibouti' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Djibouti' }">Djibouti</option>
                                        <option value='Dominica' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Dominica' }">Dominica</option>
                                        <option value='Dominican Republic' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Dominican Republic' }">Dominican Republic</option>
                                        <option value='Ecuador' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Ecuador' }">Ecuador</option>
                                        <option value='Egypt' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Egypt' }">Egypt</option>
                                        <option value='El Salvador' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'El Salvador' }">El Salvador</option>
                                        <option value='Equatorial Guinea' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Equatorial Guinea' }">Equatorial Guinea</option>
                                        <option value='Eritrea' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Eritrea' }">Eritrea</option>
                                        <option value='Estonia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Estonia' }">Estonia</option>
                                        <option value='Ethiopia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Ethiopia' }">Ethiopia</option>
                                        <option value='Fiji' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Fiji' }">Fiji</option>
                                        <option value='Finland' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Finland' }">Finland</option>
                                        <option value='France' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'France' }">France</option>
                                        <option value='Gabon' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Gabon' }">Gabon</option>
                                        <option value='Gambia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Gambia' }">Gambia</option>
                                        <option value='Georgia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Georgia' }">Georgia</option>
                                        <option value='Germany' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Germany' }">Germany</option>
                                        <option value='Ghana' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Ghana' }">Ghana</option>
                                        <option value='Greece' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Greece' }">Greece</option>
                                        <option value='Grenada' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Grenada' }">Grenada</option>
                                        <option value='Guatemala' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Guatemala' }">Guatemala</option>
                                        <option value='Guinea' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Guinea' }">Guinea</option>
                                        <option value='Guinea-Bissau' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Guinea-Bissau' }">Guinea-Bissau</option>
                                        <option value='Guyana' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Guyana' }">Guyana</option>
                                        <option value='Haiti' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Haiti' }">Haiti</option>
                                        <option value='Holy See' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Holy See' }">Holy See</option>
                                        <option value='Honduras' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Honduras' }">Honduras</option>
                                        <option value='Hungary' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Hungary' }">Hungary</option>
                                        <option value='Iceland' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Iceland' }">Iceland</option>
                                        <option value='India' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'India' }">India</option>
                                        <option value='Indonesia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Indonesia' }">Indonesia</option>
                                        <option value='Iran' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Iran' }">Iran</option>
                                        <option value='Iraq' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Iraq' }">Iraq</option>
                                        <option value='Ireland' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Ireland' }">Ireland</option>
                                        <option value='Israel' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Israel' }">Israel</option>
                                        <option value='Italy' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Italy' }">Italy</option>
                                        <option value='Jamaica' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Jamaica' }">Jamaica</option>
                                        <option value='Japan' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Japan' }">Japan</option>
                                        <option value='Jordan' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Jordan' }">Jordan</option>
                                        <option value='Kazakhstan' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Kazakhstan' }">Kazakhstan</option>
                                        <option value='Kenya' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Kenya' }">Kenya</option>
                                        <option value='Kiribati' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Kiribati' }">Kiribati</option>
                                        <option value='Kuwait' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Kuwait' }">Kuwait</option>
                                        <option value='Kyrgyzstan' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Kyrgyzstan' }">Kyrgyzstan</option>
                                        <option value='Laos' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Laos' }">Laos</option>
                                        <option value='Latvia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Latvia' }">Latvia</option>
                                        <option value='Lebanon' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Lebanon' }">Lebanon</option>
                                        <option value='Lesotho' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Lesotho' }">Lesotho</option>
                                        <option value='Liberia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Liberia' }">Liberia</option>
                                        <option value='Libya' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Libya' }">Libya</option>
                                        <option value='Liechtenstein' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Liechtenstein' }">Liechtenstein</option>
                                        <option value='Lithuania' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Lithuania' }">Lithuania</option>
                                        <option value='Luxembourg' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Luxembourg' }">Luxembourg</option>
                                        <option value='Macedonia (FYROM)' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Macedonia' }">Macedonia (FYROM)</option>
                                        <option value='Madagascar' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Madagascar' }">Madagascar</option>
                                        <option value='Malawi' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Malawi' }">Malawi</option>
                                        <option value='Malaysia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Malaysia' }">Malaysia</option>
                                        <option value='Maldives' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Maldives' }">Maldives</option>
                                        <option value='Mali' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Mali' }">Mali</option>
                                        <option value='Malta' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Malta' }">Malta</option>
                                        <option value='Marshall Islands' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Marshall Islands' }">Marshall Islands</option>
                                        <option value='Mauritania' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Mauritania' }">Mauritania</option>
                                        <option value='Mauritius' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Mauritius' }">Mauritius</option>
                                        <option value='Mexico' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Mexico' }">Mexico</option>
                                        <option value='Micronesia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Micronesia' }">Micronesia</option>
                                        <option value='Moldova' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Moldova' }">Moldova</option>
                                        <option value='Monaco' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Monaco' }">Monaco</option>
                                        <option value='Mongolia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Mongolia' }">Mongolia</option>
                                        <option value='Montenegro' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Montenegro' }">Montenegro</option>
                                        <option value='Morocco' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Morocco' }">Morocco</option>
                                        <option value='Mozambique' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Mozambique' }">Mozambique</option>
                                        <option value='Myanmar (formerly Burma)' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Myanmar (formerly Burma)' }">Myanmar (formerly Burma)</option>
                                        <option value='Namibia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Namibia' }">Namibia</option>
                                        <option value='Nauru' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Nauru' }">Nauru</option>
                                        <option value='Nepal' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Nepal' }">Nepal</option>
                                        <option value='Netherlands' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Netherlands' }">Netherlands</option>
                                        <option value='New Zealand' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'New Zealand' }">New Zealand</option>
                                        <option value='Nicaragua' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Nicaragua' }">Nicaragua</option>
                                        <option value='Niger' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Niger' }">Niger</option>
                                        <option value='Nigeria' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Nigeria' }">Nigeria</option>
                                        <option value='North Korea' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'North Korea' }">North Korea</option>
                                        <option value='Norway' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Norway' }">Norway</option>
                                        <option value='Oman' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Oman' }">Oman</option>
                                        <option value='Pakistan' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Pakistan' }">Pakistan</option>
                                        <option value='Palau' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Palau' }">Palau</option>
                                        <option value='Palestine State' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Palestine State' }">Palestine State</option>
                                        <option value='Panama' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Panama' }">Panama</option>
                                        <option value='Papua New Guinea' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Papua New Guinea' }">Papua New Guinea</option>
                                        <option value='Paraguay' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Paraguay' }">Paraguay</option>
                                        <option value='Peru' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Peru' }">Peru</option>
                                        <option value='Philippines' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Philippines' }">Philippines</option>
                                        <option value='Poland' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Poland' }">Poland</option>
                                        <option value='Portugal' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Portugal' }">Portugal</option>
                                        <option value='Qatar' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Qatar' }">Qatar</option>
                                        <option value='Romania' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Romania' }">Romania</option>
                                        <option value='Russia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Russia' }">Russia</option>
                                        <option value='Rwanda' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Rwanda' }">Rwanda</option>
                                        <option value='Saint Kitts and Nevis' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Saint Kitts and Nevis' }">Saint Kitts and Nevis</option>
                                        <option value='Saint Lucia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Saint Lucia' }">Saint Lucia</option>
                                        <option value='Saint Vincent and the Grenadines' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Saint Vincent and the Grenadines' }">Saint Vincent and the Grenadines</option>
                                        <option value='Samoa' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Samoa' }">Samoa</option>
                                        <option value='San Marino' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'San Marino' }">San Marino</option>
                                        <option value='Sao Tome and Principe' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Sao Tome and Principe' }">Sao Tome and Principe</option>
                                        <option value='Saudi Arabia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Saudi Arabia' }">Saudi Arabia</option>
                                        <option value='Senegal' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Senegal' }">Senegal</option>
                                        <option value='Serbia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Serbia' }">Serbia</option>
                                        <option value='Seychelles' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Seychelles' }">Seychelles</option>
                                        <option value='Sierra Leone' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Sierra Leone' }">Sierra Leone</option>
                                        <option value='Singapore' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Singapore' }">Singapore</option>
                                        <option value='Slovakia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Slovakia' }">Slovakia</option>
                                        <option value='Slovenia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Slovenia' }">Slovenia</option>
                                        <option value='Solomon Islands' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Solomon Islands' }">Solomon Islands</option>
                                        <option value='Somalia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Somalia' }">Somalia</option>
                                        <option value='South Africa' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'South Africa' }">South Africa</option>
                                        <option value='South Korea' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'South Korea' }">South Korea</option>
                                        <option value='South Sudan' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'South Sudan' }">South Sudan</option>
                                        <option value='Spain' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Spain' }">Spain</option>
                                        <option value='Sri Lanka' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Sri Lanka' }">Sri Lanka</option>
                                        <option value='Sudan' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Sudan' }">Sudan</option>
                                        <option value='Suriname' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Suriname' }">Suriname</option>
                                        <option value='Swaziland' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Swaziland' }">Swaziland</option>
                                        <option value='Sweden' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Sweden' }">Sweden</option>
                                        <option value='Switzerland' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Switzerland' }">Switzerland</option>
                                        <option value='Syria' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Syria' }">Syria</option>
                                        <option value='Tajikistan' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Tajikistan' }">Tajikistan</option>
                                        <option value='Tanzania' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Tanzania' }">Tanzania</option>
                                        <option value='Thailand' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Thailand' }">Thailand</option>
                                        <option value='Timor-Leste' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Timor-Leste' }">Timor-Leste</option>
                                        <option value='Togo' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Togo' }">Togo</option>
                                        <option value='Tonga' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Tonga' }">Tonga</option>
                                        <option value='Trinidad and Tobago' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Trinidad and Tobago' }">Trinidad and Tobago</option>
                                        <option value='Tunisia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Tunisia' }">Tunisia</option>
                                        <option value='Turkey' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Turkey' }">Turkey</option>
                                        <option value='Turkmenistan' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Turkmenistan' }">Turkmenistan</option>
                                        <option value='Tuvalu' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Tuvalu' }">Tuvalu</option>
                                        <option value='Uganda' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Uganda' }">Uganda</option>
                                        <option value='Ukraine' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Ukraine' }">Ukraine</option>
                                        <option value='United Arab Emirates' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'United Arab Emirates' }">United Arab Emirates</option>
                                        <option value='United Kingdom' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'United Kingdom' }">United Kingdom</option>
                                        <option value='United States of America' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'United States of America' }">United States of America</option>
                                        <option value='Uruguay' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Uruguay' }">Uruguay</option>
                                        <option value='Uzbekistan' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Uzbekistan' }">Uzbekistan</option>
                                        <option value='Vanuatu' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Vanuatu' }">Vanuatu</option>
                                        <option value='Venezuela' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Venezuela' }">Venezuela</option>
                                        <option value='Viet Nam' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Viet Nam' }">Viet Nam</option>
                                        <option value='Yemen' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Yemen' }">Yemen</option>
                                        <option value='Zambia' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Zambia' }">Zambia</option>
                                        <option value='Zimbabwe' selected="{ ordine && ordine.get('utente') && ordine.get('utente').get('stato') == 'Zimbabwe' }">Zimbabwe</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="indirizzo" class="col-sm-2 control-label">Indirizzo</label>
                                <div class="col-sm-10">
                                    <input class="form-control " type="text" placeholder="Indirizzo" name="indirizzo" required value="{ ordine ? ordine.get('indirizzo') : '' }">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="citta" class="col-sm-2 control-label">Citt&agrave;</label>
                                <div class="col-sm-10">
                                    <input class="form-control " type="text" placeholder="Città" name="citta" required value="{ ordine ? ordine.get('citta') : '' }">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="provincia" class="col-sm-2 control-label">Provincia</label>
                                <div class="col-sm-10">
                                    <input class="form-control " type="text" placeholder="Provincia" name="provincia" required value="{ ordine ? ordine.get('provincia') : '' }">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="cap" class="col-sm-2 control-label">CAP</label>
                                <div class="col-sm-10">
                                    <input class="form-control " type="text" placeholder="CAP" name="cap" required value="{ ordine ? ordine.get('cap') : '' }">
                                </div>
                            </div>
                            <input type="hidden" name="id" value="{ ordine ? ordine.id : '' }">
                        </div>
                    </form>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <button type="button" class="btn btn-primary btn-flat pull-right" disabled="{ !ordine }" onclick="{
                                    save
                                }"><i class='fa fa-save'></i> Salva</button>
                    </div>
                </div>
                <!-- /.box -->
            </div>
            <div class="col-md-6">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">Dettaglio ordine</h3>
                    </div>
                    <div class="box-body">
                        <div class="table-responsive">
                            <table id="righe" class="table table-condensed table-striped">
                                <thead>
                                    <tr>
                                        <th>Codice</th>
                                        <th>Colore</th>
                                        <th>Numero pezzi</th>
                                        <th>Prezzo unitario</th>
                                        <th>Prezzo totale</th>
                                        <!--<th></th>-->
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr each="{ r in righe }" data-id="{ r.id }">
                                        <td>{ r.get('variante').get('codice') }</td>
                                        <td><span><i class='fa fa-circle fa-2x' style="color: { r.get('colore').get('esadecimale') }"></i></span></td>
                                        <td>{ r.get('quantita') }</td>
                                        <td>{ r.get('prezzo').toFixed(2) }</td>
                                        <td>{ (Math.round(r.get('quantita') * r.get('prezzo') * 100) / 100).toFixed(2) }</td>
                                        <!--<td>
                                            <button type="button" class="btn btn-sm btn-success btn-flat" onclick="{
                                                        saverow.bind(this, r.id)
                                                    }"><i class="far fa-save"></i></button>
                                            <button type="button" class="btn btn-sm btn-danger btn-flat" onclick="{
                                                        deleterow.bind(this, r.id)
                                                    }"><i class="fas fa-trash"></i></button>
                                        </td>-->
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        <div if="{ ordine }" class="totale">
                            <form role="form" class="form-horizontal">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">Imponibile:</label>
                                    <div class="col-sm-10">
                                        <input class="form-control " type="text" disabled value="{ ordine.get('totale').toFixed(2) } €">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">IVA</label>
                                    <div class="col-sm-10">
                                        <input class="form-control " type="text" disabled value="{ (ordine.get('totale') * IVA).toFixed(2) } €">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">Totale ordine</label>
                                    <div class="col-sm-10">
                                        <input class="form-control " type="text" disabled value="{ (ordine.get('totale') * (1 + IVA)).toFixed(2) } €">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">ID Stripe</label>
                                    <div class="col-sm-10">
                                        <input class="form-control " type="text" disabled value="{ ordine.get('stripe_id') }">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">Stato dell'ordine</label>
                                    <div class="col-sm-10">
                                        <div class='form-control'>
                                            <strong if="{ ordine.get('statoOrdine') == 1 }">Ordine pagato, in attesa di elaborazione</strong>
                                            <strong if="{ ordine.get('statoOrdine') == 2 }">Ordine spedito</strong>
                                            <strong if="{ ordine.get('statoOrdine') == 3 }">Ordine consegnato</strong>
                                            <strong if="{ ordine.get('statoOrdine') == 999 }">Ordine annullato</strong>
                                        </div>
                                    </div>
                                </div>
                            </form>

                        </div>
                    </div>
                    <div class="box-footer text-right">
                        <button type="button" class="btn btn-warning btn-flat" disabled="{ !ordine || ordine.get('statoOrdine') != 1 }" onclick="{
                                    setcompleted
                                }"><i class="fas fa-check"></i> Produzione completata</button>
                        <button type="button" class="btn btn-success btn-flat" disabled="{ !ordine || ordine.get('statoOrdine') != 2 }" onclick="{
                                    setdelivered
                                }"><i class="fas fa-check"></i> Ordine consegnato</button>
                    </div>
                </div>
                <!-- /.box -->
                <div if="{ ordine && (ordine.get('statoOrdine') == 2 || ordine.get('statoOrdine') == 3) }" class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">Tracking</h3>
                    </div>
                    <form role="form" class="form-horizontal form_tracking">
                        <div class="box-body">
                            <div class="form-group">
                                <label for="tracking" class="col-sm-2 control-label">URL tracking</label>
                                <div class="col-sm-10">
                                    <input class="form-control "  disabled="{ ordine.get('statoOrdine') == 3 }" type="text" placeholder="URL tracking" name="tracking" value="{ ordine.get('tracking') }">
                                </div>
                            </div>
                            <input type="hidden" name="id" value="{ ordine.id }">
                        </div>
                    </form>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <button type="button" class="btn btn-primary btn-flat pull-right" disabled="{ ordine.get('statoOrdine') == 3 }" onclick="{
                                    settracking
                                }"><i class='fa fa-save'></i> Salva</button>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <style>
    </style>

    <script>
        var tag = this;
        tag.ordine = null;
        tag.righe = null;

        tag.on('mount', function () {
            RiotBus.getInstance().on('ordine::got', tag.ordersFound);
            RiotBus.getInstance().on('ordine::details::response', tag.rowsFound);
            RiotBus.getInstance().on('ordine::saved', tag.ordersSaved);
            //RiotBus.getInstance().on('ordine::details::saved', tag.detailsSaved);
            //RiotBus.getInstance().on('ordine::details::deleted', tag.detailsDeleted);
            RiotBus.getInstance().trigger('ordine::get', opts.id_object);
            RiotBus.getInstance().trigger('ordine::details::request', opts.id_object);
        });

        tag.on('unmount', function () {
            RiotBus.getInstance().off('ordine::got', tag.ordersFound);
            RiotBus.getInstance().off('ordine::details::response', tag.rowsFound);
            RiotBus.getInstance().off('ordine::saved', tag.ordersSaved);
            //RiotBus.getInstance().off('ordine::details::saved', tag.detailsSaved);
            //RiotBus.getInstance().off('ordine::details::deleted', tag.detailsDeleted);
        });

        tag.save = function (e) {
            var data = {};
            $('.form_order [name]').each(function () {
                data[this.name] = this.value;
            });
            RiotBus.getInstance().trigger('ordine::save', data);
        };

        /*
         tag.saverow = function (id) {
         var quantita = parseInt($("[data-id='" + id + "'] [name='quantita']").val());
         var prezzo = parseFloat($("[data-id='" + id + "'] [name='prezzo']").val());
         var data = {
         id: id,
         quantita: quantita,
         prezzo: prezzo
         };
         RiotBus.getInstance().trigger('ordine::details::save', data);
         };
         
         tag.deleterow = function (id) {
         RiotBus.getInstance().trigger('ordine::details::delete', id);
         };
         */

        tag.ordersFound = function (o) {
            tag.ordine = o;
            tag.update();
        };

        tag.ordersSaved = function (o) {
            RiotBus.getInstance().trigger('ordine::get', opts.id_object);
        };

        /*
         tag.detailsSaved = function (o) {
         RiotBus.getInstance().trigger('ordine::details::request', opts.id_object);
         };
         
         tag.detailsDeleted = function (o) {
         RiotBus.getInstance().trigger('ordine::details::request', opts.id_object);
         };
         */

        tag.rowsFound = function (o) {
            tag.righe = o;
            tag.update();
        };

        tag.gocliente = function () {
            tag.routeTo("/inserisci-user?id_object=" + tag.ordine.get("utente").id);
        };

        tag.setcompleted = function () {
            RiotBus.getInstance().trigger('ordine::completed', opts.id_object);
        };

        tag.setdelivered = function () {
            RiotBus.getInstance().trigger('ordine::delivered', opts.id_object);
        };

        tag.settracking = function () {
            var data = {};
            $('.form_tracking [name]').each(function () {
                data[this.name] = this.value;
            });
            RiotBus.getInstance().trigger('ordine::save', data);
        };

    </script>
</inserisci-ordine>
