
<!-- [ Main Content ] start -->
<div class="pcoded-main-container">
    <div class="pcoded-content">
        <!-- [ breadcrumb ] start -->
        <div class="page-header">
            <div class="page-block">
                <div class="row align-items-center">
                    <div class="col-md-12">
                        <div class="page-header-title">
                            <h5 class="m-b-10">Muhasebe</h5>
                        </div>
                        <ul class="breadcrumb">
                            <li class="breadcrumb-item"><a href="<?php echo site_url('anasayfa');?>"><i class="feather icon-home"></i></a></li>
                            <li class="breadcrumb-item"><a href="#!">Muhasebe</a></li>
                           
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <!-- [ breadcrumb ] end -->
        <!-- [ Main Content ] start -->
        <div class="row">
            <div class="col-md-8">
                <div class="card">
                    <div class="card-body">
                       <ul class="nav nav-pills bg-nav-pills nav-justified mb-0">
                            <li class="nav-item">
                                <a href="<?php echo site_url('gmuhasebe/genel');?>"  class="nav-link ">
                                    <i class="fas fa-wallet f-18"></i>
                                    <span class="d-none d-lg-inline-block m-l-10">Genel</span>
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="<?php echo site_url('gmuhasebe/gelirgider');?>" class="nav-link ">
                                    <i class="fas fa-truck f-18"></i>
                                    <span class="d-none d-lg-inline-block m-l-10">Gelir-Gider</span>
                                </a>
                            </li>
							<li class="nav-item">
                                <a href="<?php echo site_url('gmuhasebe/alacak');?>" class="nav-link active">
                                    <i class="fas fa-money-bill-wave-alt f-18"></i>
                                    <span class="d-none d-lg-inline-block m-l-10">Alacaklar</span>
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="<?php echo site_url('gmuhasebe/rapor');?>" class="nav-link ">
                                    <i class="fas fa-money-check-alt f-18"></i>
                                    <span class="d-none d-lg-inline-block m-l-10">Rapor</span>
                                </a>
                            </li>
                        </ul> 
                    </div>
                </div>
                <div class="tab-content">
                  <div class="tab-pane  show active" id="GG">
                        <div class="card">
                            <div class="card-header">
								<button class="btn btn-primary float-right has-ripple" data-toggle="modal" data-target="#ekle"><i class="feather icon-plus"></i>Yeni</button>
                                
								<h5 class="mb-2">Alacaklar</h5>
                                <p class="text-muted mb-0">Alınacak paraları ekleyebilir,alınca alacaktan düşürüp gidere geçirebilirsiniz</p>
								<br>
									<div class="input-group">
										<input type="search" id="arama" placeholder="Arama...">
									</div>
							
							</div>
                            <div class="card-body">

<div class="modal fade" id="ekle" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Alacak Ekleme</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <?php echo form_open('gmuhasebe/alacakekle'); ?>
                    <div class="row">
						<div class="col-sm-12">
						  <div class="form-group">
                                        <label class="form-label">Tip</label>
                                        <div class="custom-controls-stacked">
                                            <label class="custom-control custom-radio">
                                                <input name="nere" value="0" type="radio" class="custom-control-input">
                                                <span class="custom-control-label">Diğer</span>
                                            </label>
                                            <label class="custom-control custom-radio">
                                                <input name="nere" value="1" type="radio" class="custom-control-input">
                                                <span class="custom-control-label">Çalışan</span>
                                            </label>
                                            <label class="custom-control custom-radio">
                                                <input name="nere"  value="2" type="radio" class="custom-control-input">
                                                <span class="custom-control-label">Müşteri</span>
                                            </label>
                                        </div>
                                    </div>
                            
                        </div>
					<div class="col-sm-12 calisan">
						<div class="form-group">
							<label class="control-label" for="calisan">Çalışan</label>
							<select name="calisan" class="form-control"  id="calisan">
								<option value=" ">Yok</option>
								<?php 
								foreach($all_calisan as $calisan)
								{
									if ($calisan['tur']!=1)
									{
									$selected = ($calisan['id'] == $this->input->post('yapan')) ? ' selected="selected"' : "";

									echo '<option value="'.$calisan['id'].'" '.$selected.'>'.$calisan['ad'].'</option>';
									}
								} 
								?>
							</select>
						</div>
					</div>
					<div class="col-sm-12 musteri">
						<div class="form-group">
						<label for="musteri" class="control-label">Müşteri</label>
							<select name="musteri" class="form-control" data-plugin="select2">
								<option value=" ">Yok</option>
								<?php 
								foreach($all_musteri as $musteri)
								{
									$selected = ($musteri['id'] == $this->input->post('musteri')) ? ' selected="selected"' : "";

									echo '<option value="'.$musteri['id'].'" '.$selected.'>'.$musteri['ad'].'</option>';
								} 
								?>
							</select>
						</div>
					</div>
                     <div class="col-sm-12">
						<label for="aciklama" class="control-label">Açıklama</label>
						<div class="form-group">
							<textarea name="aciklama" class="form-control" rows="3" style="width:100%" value="<?php echo $this->input->post('aciklama'); ?>" ><?=set_value('aciklama')?></textarea>
							
						</div>
					</div>
                       
                        <div class="col-sm-6">
                            <div class="form-group">
                                <label class="control-label" for="fiyat">Fiyat</label>
                                <input name="fiyat" type="number" class="form-control" id="fiyat" required>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <div class="form-group">
                                <label class="control-label">Tarih</label>
                                <input name="tarih" id="buguntarih" type="date"  class="form-control" required>
                            </div>
                        </div>
						<script>
							document.getElementById("buguntarih").value = "<?php echo date('d.m.Y'); ?>";
						 
						</script> 
                       
                        
                        <div class="col-sm-12">
                            <button class="btn btn-primary">Ekle</button>
                       
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

					<div class="table-responsive">
                            <table class="table table-hover mb-0">
                                <thead>
                                    <tr> 
                                        <th>Tür</th>
										<th>Tarih</th>
                                        <th>Tip</th>
                                        <th>Açıklama</th>
                                        <th>Fiyat</th>
                                        <th>İşlem</th>
                                    </tr>
                                </thead>
                                <tbody>
								 <?php foreach($alacaklar as $gd){ ?>
									<tr>
										<td>
										<?php 
										if($gd['tur']==1){echo "Gelir";};
										if($gd['tur']==2){echo "Gider";};
										if($gd['tur']==4){echo "Alacaklar";};
										?>
										</td>
										<td><?php echo tarihyazdir($gd['tarih']);  ?></td>
										<td><?php if($gd['calisan']!=0){echo "Çalışan ".isimogren('yapan', $gd['calisan']);
												}else if($gd['musteri']!=0){echo "Müşteri ".isimogren('musteri', $gd['musteri']);
												}else{echo "Diğer";}; ?></td>
										<td><?php echo $gd['aciklama']; ?></td>
										<td><?php echo $gd['fiyat']; ?></td>
										<td>
										<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#ode<?php echo $gd['id']; ?>">Alındı</button>
				  
										<a href="#" data-toggle="modal" data-target="#sil<?php echo $gd['id']; ?>" class="btn btn-icon btn-outline-danger"><i class="feather icon-trash-2"></i></a>
										
										
										<div class="modal fade modal-default" id="sil<?php echo $gd['id']; ?>" aria-hidden="true" role="dialog" tabindex="-1">
										<div class="modal-dialog">
										  <div class="modal-content modal-simple modal-center">
											<div class="modal-header">
											
											  <h4 class="modal-title">Silmek İstediğinize Emin Misiniz ?</h4>
											</div>
											<div class="modal-body">
												<?php if($gd['calisan']!=0){echo "Çalışan ".isimogren('yapan', $gd['calisan']);
												}else if($gd['musteri']!=0){echo "Müşteri ".isimogren('musteri', $gd['musteri']);
												}else{echo "Diğer";}; ?></br>
											 Açıklama :<?php echo $gd['aciklama']; ?></br>
											 Fiyat : <?php echo $gd['fiyat']; ?></br>
										
											</div>
											<div class="modal-footer">
											  <button type="button" class="btn btn-default btn-pure" data-dismiss="modal">Kapat</button>
											  <a href="<?php echo site_url('gmuhasebe/gelirgidersil/'.$gd['id']); ?>" class="btn btn-success btn-sm waves-effect waves-classic">Sil</a>
											</div>
										  </div>
										</div>
									  </div>
										
										
										
										
										
<div class="modal fade" id="ode<?php echo $gd['id']; ?>" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Alacak Ekleme</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <?php echo form_open('gmuhasebe/alacakodendi/'.$gd['id']); ?>
                    <div class="row">
						<div class="col-sm-12">
						  <div class="form-group">
                                        <label class="form-label">Alınan Ücret</label>
                                        <div class="custom-controls-stacked">
                                            <label class="custom-control custom-radio">
                                                <input name="nekadar" value="0" type="radio" class="custom-control-input" >
                                                <span class="custom-control-label">Tamamı</span>
                                            </label>
                                            <label class="custom-control custom-radio">
                                                <input name="nekadar" value="1" type="radio" class="custom-control-input">
                                                <span class="custom-control-label">Eksik</span>
                                            </label>
                                            
                                        </div>
                                    </div>
                            
                        </div>
						<div class="col-sm-6 eksik">
                            <div class="form-group">
                                <label class="control-label" for="fiyat">Alınan Ücret</label>
                                <input name="fiyat" type="number" class="form-control" id="fiyat" >
                            </div>
                        </div>
                        <div class="col-sm-6 eksik">
                            <div class="form-group">
                                <label class="control-label">Tarih</label>
                                <input name="tarih" id="buguntarih" type="date"  class="form-control" >
                            </div>
                        </div>
						
                       
                        
                        <div class="col-sm-12">
                            <button class="btn btn-primary">Ödeme Alındı</button>
						</div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
										
										
										
										</td>
										
									</tr>
									<?php } ?>
                                                                      
                                </tbody>
                            </table>
                        </div>
						   
						  

						   </div>
                        </div>
                      
                    </div>
               </div>
            </div>
            <div class="col-md-4">
                <div class="card">
                    <div class="card-header">
                        <h5>Genel</h5>
                    </div>
                    <ul class="list-group list-group-flush">
                        <li class="list-group-item py-0">
							<div class="d-flex bd-highlight ">
							  <div class="p-2 flex-fill bd-highlight">Toplam Gelir</div>
							  <div class="p-2 flex-fill bd-highlight text-right"><?php echo toplamgelir()." TL";  ?></div>
							</div>
                        </li>
                       <li class="list-group-item py-0">
					   
							<div class="d-flex bd-highlight ">
							  <div class="p-2 flex-fill bd-highlight">Toplam Gider</div>
							  <div class="p-2 flex-fill bd-highlight text-right"><?php echo toplamgider()." TL";  ?></div>
							</div>
                           
                        </li>
						<li class="list-group-item py-0">
							<div class="d-flex bd-highlight ">
							  <div class="p-2 flex-fill bd-highlight">Ödeme Bekleyen (Çalışanlara Ödenecek Paralar)</div>
							  <div class="p-2 flex-fill bd-highlight text-right"><?php echo toplambekleme()." TL";  ?></div>
							</div>
                        </li>
						<li class="list-group-item py-0">
							<div class="d-flex bd-highlight ">
							  <div class="p-2 flex-fill bd-highlight">Alacaklar (Gelecek Olan Paralar)</div>
							  <div class="p-2 flex-fill bd-highlight text-right"><?php echo toplamalinacak()." TL";  ?></div>
							</div>
                          
                        </li>
					</ul>
                    <div class="card-body py-2">
							<div class="d-flex bd-highlight ">
							  <div class="p-2 flex-fill bd-highlight">Kasa : </div>
							  <div class="p-2 flex-fill bd-highlight text-right font-weight-semibold"><?php echo 	toplamgelir()-toplamgider() ." TL";  ?></div>
							</div>
                       
                    </div>
                </div>
            </div>
        </div>
        <!-- [ Main Content ] end -->
    </div>
</div>

<!-- [ Main Content ] end -->
 
<script>
    $(document).ready(function () {
		
		
		<?php if ($this->session->flashdata('alacakodendi')) { ?>
			swal("İşlem Başarılı", "<?= $this->session->flashdata('alacakodendi') ?>", "success");
		<?php } ?>

		
		
		
				$(".calisan").hide();
                $(".musteri").hide();
				
                $(".eksik").hide();
				
        $('form').change(function () {
            if ($("input[name='nere']:checked").val() == '0') {
                $(".calisan").hide();
                $(".musteri").hide();
            }
            if ($("input[name='nere']:checked").val() == '1') {
                 $(".calisan").show();
                $(".musteri").hide();
            }
			if ($("input[name='nere']:checked").val() == '2') {
                 $(".calisan").hide();
				$(".musteri").show();
            }
		
			if ($(this).find("input[name='nekadar']:checked").val() == '0') {
				//tamamı
               $(this).find(".eksik").hide();
			   $("input").attr("required", false);
            }
			if ($(this).find("input[name='nekadar']:checked").val() == '1') {
				//eksik
               $(this).find(".eksik").show();
			   $("input").attr("required", true);
            }
        });
    });
	
	
	
</script>
	
