

<div class="row">
    <div class="container">

        <ol class="breadcrumb">
            <li><a href="#">المشروعات</a></li>
            <li><a href="projectController.php?do=show"> المشروعات</a></li>
            <li class="active"> تعديل المشروع</li>
        </ol>


        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                <h3 class="panel-title">تعديل المشروع</h3>
            </div>
            <div class="panel-body">


                {literal}
                <form class="form-horizontal nameToBeChecked" role="form" action="projectController.php?do=update" method="post" id="project-form" enctype="multipart/form-data" >

                    {/literal}


                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">اسم المشروع</label>
                        <div class="col-lg-4">
                            <input type="text" name="txtName" id="projectName" class="form-control" data-id='{$editelement->id}' placeholder=" اسم المشروع" required="" value="{$editelement->name}"/>

                        </div>
                    </div>


                    {if $Programsettingdata->projectshownew eq 0 || $Programsettingdata->realestatedev eq 0} 
                    <div class="form-group" >
                         <label class="col-lg-2 control-label">انواع  المشروعات</label>
                        <div class="col-lg-4">
                            <select class="select2 wdt100" name="projectkindid" id="projectkindid" >
                                <option value="-1" >اختر</option>
                                {foreach $allprojectkind as $projectkind}
                                <option value="{$projectkind->projectkindid}" {if $editelement->projectkindid eq $projectkind->projectkindid} selected="" {/if}>{$projectkind->projectkindname}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    {/if}

                    {if $Programsettingdata->realestatedev eq 0} 

                     <div class="form-group" >
                        <label for="userstoreid" class="col-lg-2 control-label">مراحل المشروعات</label>
                        <div class="col-lg-4">

                            <span id="spryselect4">
                                <select class="select2 wdt100" name="projectstageids[]" id="projectstageids" multiple="" data-placeholder="اختر ">
                                     {foreach $projectstages as $projectstage}
                                    <option value="{$projectstage->id}" {if $projectstage->id|in_array:$editelement->projectstageids} selected="selected" {/if}>{$projectstage->name}</option>

                                    {/foreach}

                                </select>
                                <span class="selectInvalidMsg"> *</span></span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="owner_name" class="col-lg-2 control-label">اسم المالك  </label>
                        <div class="col-lg-4">
                            <input type="text" name="owner_name" id="owner_name" data-id='' class="form-control" placeholder=" اسم المالك " required="" value="{$editelement->owner_name}"/>

                        </div>
                    </div>
                    
                    
                    <div class="form-group">
                        <label  class="col-lg-2 control-label"> نوع الاعمال  </label>
                        <div class="col-lg-4">
                          <input type="radio"  name="business_type" value="1" {if $editelement->business_type eq 1} checked="" {/if}>
                          <label >انشاءات </label>
                          <input type="radio"  name="business_type" value="2" {if $editelement->business_type eq 2} checked="" {/if}>
                          <label >تشطيبات </label>
                          <input type="radio"  name="business_type" value="3" {if $editelement->business_type eq 3} checked="" {/if}>
                          <label >اخرى  </label>
                        </div>
                    </div>

                   


                     <div class="form-group">
                        <label  class="col-lg-2 control-label"> نوع مبلغ الاشراف   </label>
                        <div class="col-lg-4">
                          <input type="radio"  name="supervision_type" value="1" {if $editelement->supervision_type eq 1} checked="" {/if} data-supervisionamount="{$currency}">
                          <label >قيمه </label>
                          <input type="radio"  name="supervision_type" value="2" {if $editelement->supervision_type eq 2} checked="" {/if} data-supervisionamount="%">
                          <label >نسبه</label>
                        </div>
                    </div>

                     <div class="form-group">
                        <label for="supervision_amount" class="col-lg-2 control-label"> مبلغ الاشراف   </label>
                        <div class="col-lg-4">
                               <div class="input-group">
                                <input type="text" name="supervision_amount"  id="supervision_amount" value="{$editelement->supervision_amount}"  class="form-control numberinput positiveNo" placeholder="  مبلغ الاشراف  " required=""/>
                                <span class="input-group-addon" id="supervisionamount" >{if $editelement->supervision_type eq 1} {$currency} {else}%  {/if} </span>
                            </div>

                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">كشف حساب مشروع  </label>
                        <div class="col-lg-4">
                             {if $editelement->filepdf !="." && $editelement->filepdf}
                            <a href="../upload/project/{$editelement->filepdf}"  target="_blank"  download="">  open file </a>
                            {/if}
                            <input type="hidden" name="oldfilepdf" id="oldfilepdf"  value="{$editelement->filepdf}" />
                            <input    type="file" name="filepdf" />
                        </div>
                    </div>


                    <div class="form-group">
                            <label for="txtName" class="col-lg-2 control-label"> اظهار كشف حساب مشروع</label>
                        <div class="col-lg-4">

                        <label class="sr-only"></label>
                          <input type="checkbox" class="form-control" name="showpdf" id="showpdf"  value="1" style="   width: 23px;"   {if $editelement->showpdf eq 1} checked="" {/if}>  
                        </div>
                    </div>

                    
                    

                   
                   
                    {/if}  


                    {if $Programsettingdata->projectshownew eq 0} 
                   
                    <div class="form-group">
                        <label  class="col-lg-2 control-label"> تم تصميم البانر </label>
                        <div class="col-lg-4">
                          <input type="radio"  name="bannerdesigned" value="1"  {if $editelement->bannerdesigned eq 1} checked="" {/if}>
                          <label >نعم </label>
                          <input type="radio"  name="bannerdesigned" value="2"  {if $editelement->bannerdesigned eq 2} checked="" {/if}>
                          <label >لا</label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-lg-2 control-label"> حالة المشروع </label>
                        <div class="col-lg-4">
                          <input type="radio"  name="projectsuit" value="1"  {if $editelement->projectsuit eq 1} checked="" {/if}>
                          <label >تم </label>
                          <input type="radio"  name="projectsuit" value="2"  {if $editelement->projectsuit eq 2} checked="" {/if}>
                          <label >تحت التنفيذ</label>
                          <input type="radio"  name="projectsuit" value="3"  {if $editelement->projectsuit eq 3} checked="" {/if}>
                          <label >لم يبدا بعد</label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-lg-2 control-label">تاريخ  الاضافه</label>
                        <div class="col-lg-4">
                           <input type="text" class="form-control awdatepicker " autocomplete="off"   data-date-format="yyyy-mm-dd" name="addeddate" value="{$editelement->addeddate}">
                        </div>
                    </div>
                     <div class="form-group">
                        <label  class="col-lg-2 control-label">تاريخ الانتهاء</label>
                        <div class="col-lg-4">
                           <input type="text" class="form-control awdatepicker " autocomplete="off"   data-date-format="yyyy-mm-dd" name="expirydate" value="{$editelement->expirydate}">
                        </div>
                    </div>
                    {/if} 




                    <!-- =================================================   -->

                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">صورة  التعاقد </label>
                        <div class="col-lg-4">
                            <input type="file" name="imagecontract" id="imagecontract" accept="image/*"     class="form-control"  />
                            <input id="hiddenfile" type="hidden" name="hiddenfile"  value="{$editelement->image}" />
                            {if {$editelement->image} neq '' && $editelement->image neq '.'}
                            <a href='../upload/project/{$editelement->image}' target="_new"><img src='../upload/project/{$editelement->image}' style=" width: 200px; height: 90px; "/></a>

                            {/if}
                        </div>
                    </div>
                    <!-- =================================================   -->



                    <div class="form-group">
                        <label for="txtDebt" class="col-lg-2 control-label"> اجمالى التعاقد</label>
                        <div class="col-lg-4">

                            <div class="input-group">
                                <input type="text" name="txtDebt" id="txtDebt"  class="form-control numberinput positiveNo" placeholder="اجمالى التعاقد" required  value="{$editelement->totalcontract}"/>
                                <span class="input-group-addon">{$currency}</span>
                            </div>

                        </div>
                    </div>

                    <!-- =================================================   -->

                    <div class="form-group">
                        <label for="textDetails" class="col-lg-2 control-label">بيانات عامة</label>
                        <div class="col-lg-4">

                            <textarea  class="form-control" rows="3" name="textDetails" id="textDetails" >{$editelement->detail}</textarea>

                        </div>
                    </div>


               

                       {if $Programsettingdata->realestatedev eq 0} 



                    
                    <div class="form-group">
                        <label  class="col-lg-2 control-label"> بيانات مراحل المشروع </label>
                        <div class="col-lg-4">
                          <input type="radio"  name="projectstagesdata" value="1" {if $editelement->projectstagesdata eq 1} checked="" {/if}>
                          <label >اظهار </label>
                          <input type="radio"  name="projectstagesdata" value="2" {if $editelement->projectstagesdata eq 2} checked="" {/if}>
                          <label >اخفاء</label>
                        </div>
                    </div>


                     <div class="form-group">
                        <label  class="col-lg-2 control-label"> برنامج زمنى </label>
                        <div class="col-lg-4">
                          <input type="radio"  name="projecttimetableitems" value="1" {if $editelement->projecttimetableitems eq 1} checked="" {/if}>
                          <label >اظهار </label>
                          <input type="radio"  name="projecttimetableitems" value="2" {if $editelement->projecttimetableitems eq 2} checked="" {/if}>
                          <label >اخفاء</label>
                        </div>
                    </div>


                      <div class="form-group">
                        <label  class="col-lg-2 control-label"> المصروفات </label>
                        <div class="col-lg-4">
                          <input type="radio"  name="expenses" value="1" {if $editelement->expenses eq 1} checked="" {/if}>
                          <label >اظهار </label>
                          <input type="radio"  name="expenses" value="2" {if $editelement->expenses eq 2} checked="" {/if}>
                          <label >اخفاء</label>
                        </div>
                    </div>



                    <div class="form-group">
                        <label  class="col-lg-2 control-label"> التحصيل </label>
                        <div class="col-lg-4">
                          <input type="radio"  name="income" value="1" {if $editelement->income eq 1} checked="" {/if}>
                          <label >اظهار </label>
                          <input type="radio"  name="income" value="2" {if $editelement->income eq 2} checked="" {/if}>
                          <label >اخفاء</label>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-12">
                             <div style="text-align: center;font-size: 19px;">
                                 برنامج زمنى به بنود
                              </div>
                              <div>
                                 <button type="button" class="btn green-meadow btn-sm pull-left addappend" data-container="timetableitems" data-itr='' data-link="projectControllerAjaxnew.php" data-views="projectview/timetableitems.html"  style="font-size: 10px;background: #ccc">اضافه البند </button>
                                  <input type="hidden" id="timetableitemsitr" name="timetableitemsitr" value="{1 + $projecttimetableitems|@count}" />
                              </div>
                              <div class="clearfix"></div>
                              <ul class="timetableitemscontainer" >
                                  <li   style="list-style-type: none;">
                                     <div class="col-lg-3">
                                        البند
                                     </div>
                                     <div class="col-lg-2">
                                         المبلغ
                                     </div>
                                     <div class="col-lg-2">
                                       المده
                                     </div>
                                     <div class="col-lg-2">
                                   تاريخ بدايه
                                     </div>
                                     <div class="col-lg-2">
                                     تاريخ نهايه
                                     </div>
                                   
                               </li>
                                {assign var=it1r value=1}
                                {assign var=amounts value=0}
                                {assign var=durations value=0}
                                {foreach $projecttimetableitems as $projecttimetableitem}
                                 <li  id="timetableitemsremove1{$projecttimetableitem->id}" class="container"  style="list-style-type: none;">
                                    <input type="hidden" name="projecttimetableitemid{$it1r}" value="{$projecttimetableitem->id}">
                                   <div class="col-lg-3">
                                       <input  required="required"    type="text" name="clause{$it1r}" class="form-control " placeholder="البند" data-table="" data-tablecol="" data-tableid="" data-parentid="" data-parentcol="" value="{$projecttimetableitem->clause}"/>
                                   </div>
                                   <div class="col-lg-2">
                                       <input  required="required"    type="text" name="amount{$it1r}" class="form-control floats amounts" placeholder="المبلغ" data-table="" data-tablecol="" data-tableid="" data-parentid="" data-parentcol="" value="{$projecttimetableitem->amount}" />
                                   </div>
                                   <div class="col-lg-2">
                                     <input  required="required"    type="text" name="duration{$it1r}" class="form-control nummbers durations" placeholder="المده" data-table="" data-tablecol="" data-tableid="" data-parentid="" data-parentcol="" value="{$projecttimetableitem->duration}" />
                                   </div>
                                   <div class="col-lg-2">
                                    <input     type="text" name="startdate{$it1r}" class="form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd" placeholder="تاريخ بدايه" data-table="" data-tablecol="" data-tableid="" data-parentid="" data-parentcol="" value="{$projecttimetableitem->startdate}" />
                                   </div>
                                   <div class="col-lg-2">
                                    <input     type="text" name="enddate{$it1r}" class="form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd" placeholder=" تاريخ نهايه" data-table="" data-tablecol="" data-tableid="" data-parentid="" data-parentcol="" value="{$projecttimetableitem->enddate}" />
                                   </div>
                                    {if $it1r neq 1}
                                    <div class="col-lg-1 pull-right">
                                     <a href="javascript:;"  data-id="{$projecttimetableitem->id}" data-edit="1" data-link="projectControllerAjaxnew.php" data-table="projecttimetableitems"  data-container="timetableitems" class="btn btn-xs red pull-right removeappend"> x
                                     </a>
                                    </div> 
                                    {/if}
                                </li>
                                {capture assign=it1r}{$it1r+1}{/capture}
                                {capture assign=amounts}{$amounts+$projecttimetableitem->amount}{/capture}
                                {capture assign=durations}{$durations+$projecttimetableitem->duration}{/capture}
                                {/foreach}
                            </ul> 

                            <div class="clearfix"></div>
                              <div class="container" style="    text-align: center;">
                                   <div class="col-lg-3">
                                      <h3> الاجمالى   </h3>
                                   </div>
                                   <div class="col-lg-2">
                                     <span id="amounts" style="font-size: 20px">{$amounts}</span> {$currency}
                                   </div>
                                   <div class="col-lg-2" >
                                     <span id="durations" style="font-size: 20px">{$durations}</span> يوم
                                   </div>
                                   <div class="col-lg-2">
                                   </div>
                                   <div class="col-lg-2">
                                   </div>
                              </div>


                           
                        </div>
                    </div>
                    {/if}

                    <!-- =================================================   -->
                    <input type="hidden" name="editid" value="{$editelement->id}" />
                    <input type="hidden" name="clientid" value="{$editelement->clientid}" />
                    <input type="hidden" name="costcenterid"  value="{$editelement->costcenterid}"/>
                    <input type="hidden" name="treeid" value='{$editelement->treeid}'/>
                    <input type="hidden" name="treeproid" value='{$editelement->treeproid}'/>
                    <input type="hidden" name="entryid" value='{$editelement->entryid}'/>
                    <input type="hidden" name="sysdate" value="{$editelement->sysdate}" />
                    <input type="hidden" name="del" value="{$editelement->del}" />

                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="submit" id="project_save_btn" class="btn btn-primary pull-left">حفظ الامر</button>
                        </div>
                    </div>




                </form>
            </div>
        </div>




    </div>
</div>





{literal}
<script type="text/javascript">
   
    // $('input[name="storeSupervisor"]').live('change', function () {
    //     if ($('input[name="storeSupervisor"]:checked').val() == 1) {
    //         $('#storeSupervisorStoresDiv').show();
    //     } else {
    //         $('#storeSupervisorStoresDiv').hide();
    //     }
    // });

    $('input[name="supervision_type"]').live('change', function () {
      $('#supervisionamount').html($('input[name="supervision_type"]:checked').attr('data-supervisionamount'));
    });

  
</script>
{/literal}