
<!-- [ 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">
                                    <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 active">
                                    <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">
                                <h5 class="mb-2">Rapor</h5>
                                <p class="text-muted mb-0">Çalışana veya müşteriyi Seçip Tarih aralıgını Girin ve Arama Yapın</p>
							</div>
                            <div class="card-body">
							 <?php if(isset($nere)){ 
							 
								 if($nere=="calisan")
								 {
									 $calisantab1="active";
									 $calisantab2="active show";
									 
									 $musteritab1="";
									 $musteritab2="";
								 }else if($nere=="musteri")
								{
									 $calisantab1="";
									 $calisantab2="";
									 
									 $musteritab1="active";
									 $musteritab2="active show";
								 }
									
							 
							 }else{
									$calisantab1="active";
									 $calisantab2="active show";
									 
									 $musteritab1="";
									 $musteritab2="";
								 
							 };
							 ?> 	
						
						<div class="row">
							<div class="col-md-3 col-sm-12">
								<ul class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
									<li><a class="nav-link text-left has-ripple <?php echo $calisantab1; ?> "  data-toggle="pill" href="#calisan" role="tab" aria-controls="v-pills-home" aria-selected="true">Çalışan<span class="ripple ripple-animate" style="height: 273.75px; width: 273.75px; animation-duration: 0.7s; animation-timing-function: linear; background: rgb(70, 128, 255); opacity: 0.4; top: -101.875px; left: -37.875px;"></span></a></li>
									<li><a class="nav-link text-left has-ripple <?php echo $musteritab1; ?>"  data-toggle="pill" href="#musteri" role="tab" aria-controls="v-pills-profile" aria-selected="false">Müşteri<span class="ripple ripple-animate" style="height: 273.75px; width: 273.75px; animation-duration: 0.7s; animation-timing-function: linear; background: rgb(70, 128, 255); opacity: 0.4; top: -111.875px; left: -35.875px;"></span></a></li>
								</ul>
							</div>
							<div class="col-md-9 col-sm-12">
								<div class="tab-content" id="v-pills-tabContent">
									<div class="tab-pane fade <?php echo $calisantab2; ?>" id="calisan" role="tabpanel" aria-labelledby="v-pills-home-tab">
									
					<?php echo form_open('gmuhasebe/rapor'); ?>
                    <div class="row">
						
					<div class="col-sm-3">
						<div class="form-group">
							<label class="control-label" for="calisan">Çalışan</label>
							<select name="calisan" class="form-control"  id="calisan" required>
								<option value="">Çalışan Seçiniz</option>
								<?php 
								foreach($all_calisan as $calisan)
								{
									if ($calisan['tur']!=1)
									{
									$selected = ($calisan['id'] == $donencalisan ) ? ' selected="selected"' : "";

									echo '<option value="'.$calisan['id'].'" '.$selected.'>'.$calisan['ad'].'</option>';
									}
								} 
								?>
							</select>
						</div>
					</div>
				
                  
                        <div class="col-sm-3">
                            <div class="form-group">
                                <label class="control-label" >Başlangıç Tarihi</label>
                                <input name="bastarih" id="bastarih" type="date"  class="form-control"  >
                            </div>
                        </div>
                       <div class="col-sm-3">
                            <div class="form-group">
                                <label class="control-label" >Bitiş Tarihi</label>
                                <input name="bittarih" id="bittarih" type="date"   class="form-control"  >
                            </div>
                        </div>
                         <input type="Hidden" name="nere" value="calisan" />
                        <div class="col-sm-3">
                            <button class="btn btn-primary">Arama</button>
                       
                        </div>
                    </div>
                </form>	
										
									</div>
									<div class="tab-pane fade <?php echo $musteritab2; ?>" id="musteri" role="tabpanel" aria-labelledby="v-pills-profile-tab">
										
					<?php echo form_open('gmuhasebe/rapor'); ?>
                    <div class="row">
						
					<div class="col-sm-3">
						<div class="form-group">
						<label for="musteri" class="control-label">Müşteri</label>
							<select name="musteri" class="form-control" data-plugin="select2" required>
								<option value="">Müşteri Seçiniz</option>
								<?php 
								foreach($all_musteri as $musteri)
								{
									$selected = ($musteri['id'] == $donenmusteri) ? ' selected="selected"' : "";

									echo '<option value="'.$musteri['id'].'" '.$selected.'>'.$musteri['ad'].'</option>';
								} 
								?>
							</select>
						</div>
					</div>
				
                  
                        <div class="col-sm-3">
                            <div class="form-group">
                                <label class="control-label" >Başlangıç Tarihi</label>
                                <input name="bastarih" id="bastarih" type="date"   class="form-control"  >
                            </div>
                        </div>
                       <div class="col-sm-3">
                            <div class="form-group">
                                <label class="control-label" >Bitiş Tarihi</label>
                                <input name="bittarih" id="bittarih" type="date" class="form-control"  >
                            </div>
                        </div>
                        <input type="Hidden" name="nere" value="musteri" />
                        <div class="col-sm-3">
                            <button class="btn btn-primary">Arama</button>
                       
                        </div>
                    </div>
                </form>	
							
										
										
									</div>
								</div>
							</div>
						</div>
					
					
						   </div>
                        </div>
                       <?php if(isset($nere)){ ?> 	
		

					    <div class="card">
                            <div class="card-header">
                                <h5 class="mb-2">Arama Sonuçlarınız</h5>
                            </div>
                            <div class="card-body">
					  
					 <?php if(count($CMsonuc)==0){ ?> 
					 <center><i>Bir Sonuç Bulunamadı</i></center>
					 <?php }else{ ?> 
					  
								
						<div class="table-responsive">
                            <table class="table table-hover mb-0">
                                <thead>
                                    <tr> 
                                        <th>Tür</th>
                                        <th>Tarih</th>
                                        <th>Açıklama</th>
                                        <th>Fiyat</th>
                                        <th>Detay</th>
                                    </tr>
                                </thead>
                                <tbody>
								 <?php
										$sonucgelir=0;
										$sonucgider=0;
										$sonucbekleme=0;

								 foreach($CMsonuc as $yg){ ?>
									<tr>
										<td>
										<?php 
										
											if (is_numeric($yg['fiyat']))
											{
												
												if($yg['tur']==1){
												$sonucgelir = $sonucgelir + $yg['fiyat'];	
												};
												if($yg['tur']==2){
												$sonucgider = $sonucgider + $yg['fiyat'];	
												};
												if($yg['tur']==3){
													$sonucbekleme = $sonucbekleme + $yg['fiyat'];
												}
											};
										
										
										
											if($yg['tur']==1){echo "Gelir";};
											if($yg['tur']==2){echo "Gider";};
											if($yg['tur']==3){echo "Ödeme Bekliyor";};  
											if($yg['tur']==4){echo "Alacak";};  
										?>
										</td>
										<td><?php echo tarihyazdir($yg['tarih']); ?></td>
										<td><?php echo substr($yg['aciklama'],0,50); ?></td>
										<td><?php echo $yg['fiyat']; ?></td>
										
										<td>
										
										<a href="#" data-target="#rapordetay<?php echo $yg['id']; ?>" data-toggle="modal"   class="btn btn-icon btn-outline-primary" data-style="slide-down" data-plugin="ladda" >
											<i class="feather icon-eye"></i>
										</a>
									
								<!-- Modal Bas -->	
								<div class="modal fade modal-primary" id="rapordetay<?php echo $yg['id']; ?>" aria-hidden="true" role="dialog" tabindex="-1">
									<div class="modal-dialog modal-lg modal-center">
									  <div class="modal-content">
										<div class="modal-body">
										
										</br> 
										 <?php
										
											if(isset($yg['isler']))
											{
												$musteriid=verigetir('isler',$yg['isler'],'musteri');
												
												echo "<b>Müşteri : </b> <p>". "   ".verigetir('musteri',$musteriid,'ad');
												echo "</br>";
												echo "<b>İş Açıklaması : </b>". "   ".verigetir('isler',$yg['isler'],'aciklama');
												echo "</p></br>";
												echo "</br>";
												
												$isialanid= verigetir('isler',$yg['isler'],'yapan');
												$isialan= verigetir('calisan',$isialanid,'ad');
												$dosyadonen=verigetir('isler',$yg['isler'],'dosyadonen');
													
												coklu_dosya_yazdir($dosyadonen,$isialan,"Onaylanan Çalışmalar"); 
												
											}else{
													echo "<b>Tür : </b>";
													if($yg['tur']==1){echo "Gelir";};
													if($yg['tur']==2){echo "Gider";};
													if($yg['tur']==3){echo "Ödeme Bekliyor";};  
													if($yg['tur']==4){echo "Alacak";};  
										
												
												echo "<b>Tarih : </b><p>". "   ".tarihyazdir($yg['tarih']);
												echo "</br>";
												echo "<b>Açıklama : </b>". "   ".$yg['aciklama'];
												echo "</br>";
												echo "<b>Fiyat : </b>". "   ".$yg['fiyat'];
												echo "</p></br>";
											}
										 ?>
									  
									   </div>
										<div class="modal-footer">
										  <button type="button" class="btn btn-default btn-pure" data-dismiss="modal">Kapat</button>
										</div>
									  </div>
									</div>
									</div>
								<!-- Modal Bitti -->	
										
										
										</td>
										
									</tr>
									<?php } ?>
                                                                      
                                </tbody>
                            </table>
                        </div>
						

						
					 <?php } ?> 	
						</div>
                        </div>
					  
					  <?php }; ?> 
					  
                    </div>
               </div>
            </div>
			<?php if(isset($donencalisan)){ ?> 	
			<div class="col-md-4">
                <div class="card">
                    <div class="card-header">
                        <h5>Sonuç -
						
						<?php 
						
							echo isimogren('yapan', $donencalisan);
							
						?>
						
						
						</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(Alınan Ücretler)</div>
							  <div class="p-2 flex-fill bd-highlight text-right"><?php if(isset($sonucgelir)){echo $sonucgelir." TL";}else{echo "0 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(Ödenen Ücretler)</div>
							  <div class="p-2 flex-fill bd-highlight text-right"><?php if(isset($sonucgider)){echo $sonucgider." TL";}else{echo "0 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(Ödenecek Ücretler)</div>
							  <div class="p-2 flex-fill bd-highlight text-right"><?php if(isset($sonucbekleme)){echo $sonucbekleme." TL";}else{echo "0 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">Durum
							  <?php 
							  if($sonucgider>$sonucbekleme){ echo " <b>Borçlu</b>"; };
							  if($sonucgider<$sonucbekleme){ echo " <b>Alacaklı</b>";}; 
							  ?>
							  </div>
							  <div class="p-2 flex-fill bd-highlight text-right">
							  <?php
								if($sonucgider>$sonucbekleme){ echo $sonucgider-$sonucbekleme." TL";};  
								if($sonucgider<$sonucbekleme){ echo $sonucbekleme-$sonucgider." TL";};  
							  ?>
							  </div>
							</div>
                        </li>
					</ul>
                   
                </div>
            </div>
        
			
           <?php }else { ?> 
		              <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>
         <?php }?> 
		   
		   
			    
        </div>
        <!-- [ Main Content ] end -->
    </div>
</div>

<!-- [ Main Content ] end -->







